Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Children

        void _InitChildren()
        {
            if (_Children != null)
            {
                return;
            }

            if (BrepShape == null)
            {
                return;
            }

            _Children = new BRepTopologyTreeNodes();

            switch (BrepShape.ShapeType())
            {
            case TopAbs_ShapeEnum.TopAbs_COMPOUND:
                _AddShapeCollection(BrepShape.Solids(), true);
                _AddShapeCollection(BrepShape.Shells(), true);
                _AddShapeCollection(BrepShape.Faces(), true);
                _AddShapeCollection(BrepShape.Wires(), true);
                _AddShapeCollection(BrepShape.Edges(), true);
                _AddShapeCollection(BrepShape.Vertices(), true);
                break;

            case TopAbs_ShapeEnum.TopAbs_COMPSOLID:
                _AddShapeCollection(BrepShape.Solids());
                break;

            case TopAbs_ShapeEnum.TopAbs_SOLID:
                _AddShapeCollection(BrepShape.Shells(), true);
                _AddShapeCollection(BrepShape.Faces(), true);
                _AddShapeCollection(BrepShape.Wires(), true);
                _AddShapeCollection(BrepShape.Edges(), true);
                _AddShapeCollection(BrepShape.Vertices(), true);
                break;

            case TopAbs_ShapeEnum.TopAbs_SHELL:
                _AddShapeCollection(BrepShape.Faces(), true);
                _AddShapeCollection(BrepShape.Wires(), true);
                _AddShapeCollection(BrepShape.Edges(), true);
                _AddShapeCollection(BrepShape.Vertices(), true);
                break;

            case TopAbs_ShapeEnum.TopAbs_FACE:
                _AddShapeCollection(BrepShape.Wires());
                break;

            case TopAbs_ShapeEnum.TopAbs_WIRE:
                _AddShapeCollection(BrepShape.Edges());
                break;

            case TopAbs_ShapeEnum.TopAbs_EDGE:
                _AddShapeCollection(BrepShape.Vertices());
                break;
            }
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region C'tor and Setter

        public BRepTopologyTreeNode(Shape shape)
        {
            Shape          = shape;
            BrepShape      = shape?.GetBRep();
            _TopLevelShape = BrepShape;

            Name = "Invalid Shape";
            if (BrepShape != null)
            {
                Name = _GetShapeTypeName(BrepShape.ShapeType());
            }
        }
Exemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------

        void _AddDefaultProperties()
        {
            var cat = "Shape";

            var trsf        = BrepShape.Location().Transformation();
            var translation = trsf.TranslationPart();

            _AddProperty(cat, "Position", $"({translation.X.ToRoundedString()}, {translation.Y.ToRoundedString()}, {translation.Z.ToRoundedString()})");
            var euler = trsf.GetRotation().ToEuler();

            _AddProperty(cat, "Rotation", $"({euler.yaw.ToRoundedString()}, {euler.pitch.ToRoundedString()}, {euler.roll.ToRoundedString()})");

            string flags = "";

            if (BrepShape.Closed())
            {
                flags += "Closed ";
            }
            if (BrepShape.Infinite())
            {
                flags += "Infinite ";
            }
            if (BrepShape.Convex())
            {
                flags += "Convex ";
            }
            if (BrepShape.Orientable())
            {
                flags += "Orientable ";
            }
            if (BrepShape.Free())
            {
                flags += "Free ";
            }
            if (BrepShape.Locked())
            {
                flags += "Locked ";
            }
            if (BrepShape.Modified())
            {
                flags += "Modified ";
            }
            if (!flags.IsEmpty())
            {
                _AddProperty(cat, "Flags", flags);
            }

            if (BrepShape.Orientable())
            {
                _AddProperty(cat, "Orientation", BrepShape.Orientation().ToString().Replace("TopAbs_", ""));
            }
        }
Exemplo n.º 4
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Property List

        void _InitProperties()
        {
            if (_Properties != null)
            {
                return;
            }

            _Properties = new List <BRepTopologyTreeProperty>();
            try
            {
                _AddDefaultProperties();

                switch (BrepShape.ShapeType())
                {
                case TopAbs_ShapeEnum.TopAbs_SHELL:
                    _AddShellProperties(BrepShape as TopoDS_Shell ?? TopoDS.Shell(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_FACE:
                    _AddFaceProperties(BrepShape as TopoDS_Face ?? TopoDS.Face(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_WIRE:
                    _AddWireProperties(BrepShape as TopoDS_Wire ?? TopoDS.Wire(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_EDGE:
                    _AddEdgeProperties(BrepShape as TopoDS_Edge ?? TopoDS.Edge(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_VERTEX:
                    _AddVertexProperties(BrepShape as TopoDS_Vertex ?? TopoDS.Vertex(BrepShape));
                    break;
                }
            }
            catch (Exception e)
            {
                Messages.Exception($"Error getting properties for B-Rep shape {Name}", e);
            }
        }