示例#1
0
        //--------------------------------------------------------------------------------------------------

        public virtual SubshapeReference GetSubshapeReference(SubshapeType type, int index)
        {
            EnsureHistory();

            // Search in freshly built shape
            switch (type)
            {
            case SubshapeType.Face:
                var faces = GetBRep()?.Faces();
                if (faces == null || index >= faces.Count)
                {
                    return(null);
                }
                return(GetSubshapeReference(faces[index]));

            case SubshapeType.Edge:
                var edges = GetBRep()?.Edges();
                if (edges == null || index >= edges.Count)
                {
                    return(null);
                }
                return(GetSubshapeReference(edges[index]));

            case SubshapeType.Vertex:
                var vertices = GetBRep()?.Vertices();
                if (vertices == null || index >= vertices.Count)
                {
                    return(null);
                }
                return(GetSubshapeReference(vertices[index]));
            }

            return(null);
        }
        //--------------------------------------------------------------------------------------------------

        public SubshapeReference(SubshapeType type, Guid shapeId, string name, int index)
        {
            Type    = type;
            ShapeId = shapeId;
            Name    = name;
            Debug.Assert(!Name.Contains("-"));
            Index = index;
        }
示例#3
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Subshapes

        public override SubshapeReference GetSubshapeReference(SubshapeType type, int index)
        {
            if (Operands.Count > 1 && Operands[1] is BodyShapeOperand)
            {
                return((Operands[1] as BodyShapeOperand)?.Shape?.GetSubshapeReference(type, index));
            }

            return(base.GetSubshapeReference(type, index));
        }
示例#4
0
        //--------------------------------------------------------------------------------------------------

        public SelectSubshapeTool(SubshapeType subshapeType, Shape shape, string id, string statusText,
                                  SelectedFunc selectedFunc, ISelectionFilter selectionFilter = null)
        {
            _SubshapeType    = subshapeType;
            _TargetShape     = shape;
            _TargetBody      = shape.Body;
            _StatusText      = statusText;
            _SelectionFilter = selectionFilter;
            Id = id;
            Debug.Assert(_TargetShape != null);
            _SelectedFunc = selectedFunc;
            Debug.Assert(_SelectedFunc != null);
        }
示例#5
0
        //--------------------------------------------------------------------------------------------------

        public bool NeedActiveSubshapes(SubshapeType subshapeType)
        {
            switch (subshapeType)
            {
            case SubshapeType.Vertex:
                return(InteractiveContext.Current.EditorState.SnappingEnabled &&
                       InteractiveContext.Current.EditorState.SnapToVertexSelected &&
                       SupportedSnapModes.HasFlag(SnapMode.Vertex));

            case SubshapeType.Edge:
                return(InteractiveContext.Current.EditorState.SnappingEnabled &&
                       InteractiveContext.Current.EditorState.SnapToEdgeSelected &&
                       SupportedSnapModes.HasFlag(SnapMode.Edge));
            }
            return(false);
        }
示例#6
0
        public static SubshapeTypes GetTypes(SubshapeType topAbsShapeEnum)
        {
            switch (topAbsShapeEnum)
            {
            case SubshapeType.Face:
                return(SubshapeTypes.Face);

            case SubshapeType.Edge:
                return(SubshapeTypes.Edge);

            case SubshapeType.Wire:
                return(SubshapeTypes.Wire);

            case SubshapeType.Vertex:
                return(SubshapeTypes.Vertex);

            default:
                throw new NotImplementedException();
            }
        }
示例#7
0
        //--------------------------------------------------------------------------------------------------

        public static int ToAisSelectionMode(this SubshapeType type)
        {
            switch (type)
            {
            case SubshapeType.Vertex:
                return(1);

            case SubshapeType.Edge:
                return(2);

            case SubshapeType.Wire:
                return(3);

            case SubshapeType.Face:
                return(4);

            default:
                throw new NotImplementedException();
            }
        }
示例#8
0
        //--------------------------------------------------------------------------------------------------

        public static TopAbs_ShapeEnum ToTopAbs(this SubshapeType type)
        {
            switch (type)
            {
            case SubshapeType.Vertex:
                return(TopAbs_ShapeEnum.TopAbs_VERTEX);

            case SubshapeType.Edge:
                return(TopAbs_ShapeEnum.TopAbs_EDGE);

            case SubshapeType.Wire:
                return(TopAbs_ShapeEnum.TopAbs_WIRE);

            case SubshapeType.Face:
                return(TopAbs_ShapeEnum.TopAbs_FACE);

            default:
                throw new NotImplementedException();
            }
        }
        //--------------------------------------------------------------------------------------------------

        public SubshapeReference(SubshapeType type, Guid shapeId, int index)
        {
            Type    = type;
            ShapeId = shapeId;
            Index   = index;
        }
示例#10
0
        //--------------------------------------------------------------------------------------------------

        public SubshapeTypeSelectionFilter(SubshapeType subshapeType)
        {
            _SubshapeType = subshapeType;
        }