//-------------------------------------------------------------------------------------------------- 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; }
//-------------------------------------------------------------------------------------------------- #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)); }
//-------------------------------------------------------------------------------------------------- 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); }
//-------------------------------------------------------------------------------------------------- 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); }
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(); } }
//-------------------------------------------------------------------------------------------------- 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(); } }
//-------------------------------------------------------------------------------------------------- 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; }
//-------------------------------------------------------------------------------------------------- public SubshapeTypeSelectionFilter(SubshapeType subshapeType) { _SubshapeType = subshapeType; }