コード例 #1
0
        private void tsmiCalculate_Click(object sender, EventArgs e)
        {
            cd.SetChangedPoints(changedPoints.ToArray(),false);
            Solver s = new Solver();
            s.Solve(cd);
            pbMain.Refresh();
            /* Создать Solver и вызывать Solver.Solve() */
            /* Поменять CommmonData.Coords в соответствии с решением */
            /* Вызвать DrawArea. Пока просто вызвать перерисовку pbMain.Refresh()*/
            Solver solver = new Solver();
            changedPoints = new List<int>(cd.ChangedPoints);
            double[] deltas = solver.Solve(cd);
            if (deltas != null)
            {
                int j;
                for (int i = 0; i < deltas.Length; i+=2)
                {
                    j = i / 2;
                    if (!changedPoints.Contains(j))
                    {
                        cd.Coords[i / 2].Dx += deltas[i];
                        cd.Coords[i / 2].Dy += deltas[i + 1];
                    }

                }
            }
            pbMain.Refresh();
            for (int i = 0; i < cd.NTotalNodes; i++)
            {
                cd.Coords[i].X += cd.Coords[i].Dx;
                cd.Coords[i].Y += cd.Coords[i].Dy;
                cd.Coords[i].Dx = 0;
                cd.Coords[i].Dy = 0;
            }
            changedPoints = new List<int>();
            cd.ChangedPointsClear();
        }
コード例 #2
0
        private double[] RunSolverTest(string f, double[] u)
        {
            Console.WriteLine("Loading data from {0}...", f);

            try
            {
                CommonData data = new CommonData();
                data.Load(test_samples_dir + f);
                for (int i = 0; i < u.Length; i+=2)
                {
                    data.Coords[i / 2].Dx = u[i];
                    data.Coords[i / 2].Dy = u[i+1];
                }
                Console.WriteLine("Data is loaded");
                Solver s = new Solver();
                return s.Solve(data);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return null;
            }
        }