//-------------------------------------------------------------------------------------------------- public IEnumerable <TopoDS_Edge> FindValidEdges(TopoDS_Shape sourceShape) { var analysis = new ShapeAnalysis_Edge(); var mapOfEdgesToFaces = new TopTools_IndexedDataMapOfShapeListOfShape(1); TopExp.MapShapesAndAncestors(sourceShape, TopAbs_ShapeEnum.TopAbs_EDGE, TopAbs_ShapeEnum.TopAbs_FACE, mapOfEdgesToFaces); foreach (var edge in sourceShape.Edges()) { var valid = true; var faces = mapOfEdgesToFaces.FindFromKey(edge).ToList(); // Check if we have no face if (faces.Count == 0) { continue; } // Check if it is a seam edge foreach (var face in faces) { if (analysis.IsSeam(edge, face.ToFace())) { valid = false; break; } } if (valid) { yield return(edge); } } }
//-------------------------------------------------------------------------------------------------- void _OnFaceSelected(SelectSubshapeAction selectAction) { if (selectAction.SelectedSubshapeType == SubshapeTypes.Face) { var face = TopoDS.Face(selectAction.SelectedSubshape); var brepAdaptor = new BRepAdaptor_Surface(face, true); if (brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Plane && brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Cylinder && brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Cone) { StatusText = "Selected face is not a plane, cylinder or cone type surface."; selectAction.Reset(); return; } selectAction.Stop(); _TargetFace = face; _Phase = Phase.BaseEdgeOrVertex; _SubshapesOfFace = new List <TopoDS_Shape>(); var edges = face.Edges().Where( edge => { var analysis = new ShapeAnalysis_Edge(); return(!analysis.IsSeam(edge, face)); }).ToList(); _SubshapesOfFace.AddRange(edges); var vertices = face.Vertices().Where( vertex => { var vertexEdges = edges.Where(edge => edge.Vertices().ContainsSame(vertex)); return(vertexEdges.Count() > 1); }); _SubshapesOfFace.AddRange(vertices); var newAction = new SelectSubshapeAction(this, _SubshapesOfFace); if (!WorkspaceController.StartToolAction(newAction)) { Stop(); return; } newAction.Previewed += _OnActionPreview; newAction.Finished += _OnActionFinished; StatusText = "Select base edge or vertex to define direction of taper."; WorkspaceController.HudManager?.SetCursor(Cursors.SelectEdge); } }