Пример #1
0
        private void DrawElement(TriangularElement elem, Brush elemcolor, Brush nodecolor, Double opacity)
        {
            // 要素を描画する
            Polygon polygon = new Polygon();

            polygon.Fill            = elemcolor;
            polygon.Stroke          = Brushes.Black;
            polygon.StrokeThickness = 1;
            polygon.Opacity         = opacity;
            PointCollection Points = new PointCollection();

            for (int i = 0; i < 3; i++)
            {
                Point p = (Point)(elem.Nodes[i].Point * 15);
                p.X += 50;
                p.Y += 500;
                Points.Add(p);
            }
            polygon.Points = Points;
            this.Canvas.Children.Add(polygon);

            // 節点を描画する
            for (int i = 0; i < 3; i++)
            {
                Ellipse ellipse = new Ellipse();
                ellipse.Fill   = nodecolor;
                ellipse.Width  = 4;
                ellipse.Height = 4;
                Canvas.SetLeft(ellipse, elem.Nodes[i].Point.X * 15 - ellipse.Width * 0.5 + 50);
                Canvas.SetTop(ellipse, elem.Nodes[i].Point.Y * 15 - ellipse.Height * 0.5 + 500);

                this.Canvas.Children.Add(ellipse);
            }
        }
Пример #2
0
        private void AnalysisClicked(object sender, RoutedEventArgs e)
        {
            // 例外処理
            if (fem == null)
            {
                return;
            }

            // FEM解析を実行する
            fem.Analysis();

            // モデルを描画する
            List <TriangularElement> elems = fem.TriElems;
            DenseVector dispElemVector     = DenseVector.Create(6, 0.0);
            DenseVector dispVector         = fem.DispVector;

            for (int i = 0; i < elems.Count; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    dispElemVector[2 * j]     = dispVector[2 * (elems[i].Nodes[j].No - 1)];
                    dispElemVector[2 * j + 1] = dispVector[2 * (elems[i].Nodes[j].No - 1) + 1];
                }

                // 変形後の要素を計算する
                TriangularElement elem = elems[i].ShallowCopy();   // 変形前の要素をコピーする
                for (int j = 0; j < 3; j++)
                {
                    elem.Nodes[j].Point.X += dispElemVector[2 * j];
                    elem.Nodes[j].Point.Y += dispElemVector[2 * j + 1];
                }

                // 変形後の要素を描画する
                DrawElement(elem, Brushes.LightCoral, Brushes.Red, 0.5);
            }
        }