Ejemplo n.º 1
0
        private void OnSelectElement(SelectionChangeArgs args)
        {
            if (!args.IsHighlightMode())
            {
                SelectedShapeQuery query = new SelectedShapeQuery();
                renderView.QuerySelection(query);
                var ids = query.GetIds();
                if (ids.Length > 0)
                {
                    var shape = query.GetGeometry();

                    if (shape != null)
                    {
                        GeomCurve curve = new GeomCurve();
                        if (curve.Initialize(shape))
                        {
                            TopoShapeProperty property = new TopoShapeProperty();
                            property.SetShape(shape);
                            var str = String.Format("Length:{0}", property.EdgeLength());
                            toolStripStatusLabel2.Text = str;

                            return;
                        }
                    }
                }
                else
                {
                    toolStripStatusLabel2.Text = "";
                }
            }
        }
Ejemplo n.º 2
0
        public override bool Run(FeatureContext context)
        {
            TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z);

            context.ShowGeometry(arc);


            TopoShapeProperty property = new TopoShapeProperty();

            property.SetShape(arc);

            double length = property.EdgeLength();

            MessageBox.Show(String.Format("Length: {0}", length));

            return(true);
        }
Ejemplo n.º 3
0
 private void OnSelectElement(SelectionChangeArgs args)
 {
     if (!args.IsHighlightMode())
     {
         SelectedShapeQuery query = new SelectedShapeQuery();
         renderView.QuerySelection(query);
         var shape = query.GetGeometry();
         if (shape != null)
         {
             GeomCurve curve = new GeomCurve();
             if (curve.Initialize(shape))
             {
                 TopoShapeProperty property = new TopoShapeProperty();
                 property.SetShape(shape);
                 Console.WriteLine("Edge Length {0}", property.EdgeLength());
             }
         }
     }
 }
Ejemplo n.º 4
0
        public FaceInfo(TopoShape face, int idx, double area)
        {
            Surface = new GeomSurface();
            Surface.Initialize(face);
            Index = idx;
            Area  = area;

            Direction = Surface.GetNormal(Surface.FirstUParameter(), Surface.FirstVParameter());

            TopoShapeProperty prop = new TopoShapeProperty();
            var edges = GlobalInstance.TopoExplor.ExplorEdges(face);

            for (int jj = 0; jj < edges.Size(); ++jj)
            {
                var edge = edges.GetAt(jj);
                prop.SetShape(edge);
                var edgeInfo = new EdgeInfo(edge, jj, idx, prop.EdgeLength());
                // 只加直线?
                Edges.Add(jj, edgeInfo);
            }
        }
Ejemplo n.º 5
0
        private void curveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            renderView.View3d.SetStandardView(3);

            LineStyle lineStyle = new LineStyle();

            lineStyle.SetLineWidth(0.5f);
            lineStyle.SetColor(ColorValue.BLUE);
            LineStyle lineStyle2 = new LineStyle();

            lineStyle2.SetLineWidth(0.5f);
            lineStyle2.SetColor(ColorValue.GREEN);

            TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z);

            renderView.ShowGeometry(arc, ++shapeId);

            {
                GeomeCurve curve = new GeomeCurve();
                curve.Initialize(arc);

                float paramStart = curve.FirstParameter();
                float paramEnd   = curve.LastParameter();

                float step = (paramEnd - paramStart) * 0.1f;

                for (float uu = paramStart; uu <= paramEnd; uu += step)
                {
                    Vector3 dir = curve.DN(uu, 1);
                    Vector3 pos = curve.Value(uu);

                    // 切线
                    {
                        TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir);
                        SceneNode node = renderView.ShowGeometry(line, ++shapeId);
                        node.SetLineStyle(lineStyle);
                    }
                    // 法线
                    {
                        Vector3   dirN = dir.CrossProduct(Vector3.UNIT_Z);
                        TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dirN);
                        SceneNode node = renderView.ShowGeometry(line, ++shapeId);
                        node.SetLineStyle(lineStyle2);
                    }
                }
            }

            TopoShapeProperty property = new TopoShapeProperty();

            property.SetShape(arc);

            float len = property.EdgeLength();

            TextNode text = new TextNode();

            text.SetText(String.Format("Arc Length: {0}", len));
            text.SetPosition(new Vector3(100, 100, 0));

            renderView.SceneManager.ClearNodes2d();
            renderView.SceneManager.AddNode2d(text);

            renderView.RequestDraw();
        }
Ejemplo n.º 6
0
        private void curveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            renderView.SetStandardView(EnumStandardView.SV_Top);

            Platform.LineStyle lineStyle = new Platform.LineStyle();
            lineStyle.SetLineWidth(0.5f);
            lineStyle.SetColor(ColorValue.BLUE);
            Platform.LineStyle lineStyle2 = new Platform.LineStyle();
            lineStyle2.SetLineWidth(0.5f);
            lineStyle2.SetColor(ColorValue.GREEN);

            Platform.TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z);
            renderView.ShowGeometry(arc, 100);
 
            {
                GeomCurve curve = new GeomCurve();
                curve.Initialize(arc);

                float paramStart = curve.FirstParameter();
                float paramEnd = curve.LastParameter();

                float step = (paramEnd - paramStart) * 0.1f;

                for (float uu = paramStart; uu <= paramEnd; uu += step)
                {
                    Vector3 dir = curve.DN(uu, 1);
                    Vector3 pos = curve.Value(uu);

                    // 切线
                    {
                        Platform.TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir);
                        Platform.SceneNode node = renderView.ShowGeometry(line, 101);
                        node.SetLineStyle(lineStyle);
                    }
                    // 法线
                    {
                        Vector3 dirN = dir.CrossProduct(Vector3.UNIT_Z);
                        Platform.TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dirN);
                        Platform.SceneNode node = renderView.ShowGeometry(line, 101);
                        node.SetLineStyle(lineStyle2);
                    }

                }

            }

            TopoShapeProperty property = new TopoShapeProperty();
            property.SetShape(arc);

            float len = property.EdgeLength();

            TextNode text = new TextNode();
            text.SetText(String.Format("Arc Length: {0}", len));
            text.SetPosition(new Vector3(100, 100, 0));

            renderView.SceneManager.ClearNodes2d();
            renderView.SceneManager.AddNode2d(text);

            renderView.RequestDraw();
        }