/// <summary> /// Makes a list with the coliding candidates, generates a hidden fused face from them /// then generates visible face nodes pointing to the fused shapes /// </summary> public static List <Node> UpdateFaces(Document _document, List <Node> _candidates) { _generated.Clear(); var colidingShapes = new List <Node>(); DetectColidingCandidates(_candidates, colidingShapes); CreateFusedShape(colidingShapes, _document); int faceNumber; var faceExplorer = new TopExpExplorer(); // Build SubShapes with the Faces resulted after intersecting the candidates if (_nodeFused != null) { var bigFace = _nodeFused.Get <TopoDsShapeInterpreter>().Shape; faceNumber = 1; faceExplorer.Init(bigFace, TopAbsShapeEnum.TopAbs_FACE, TopAbsShapeEnum.TopAbs_SHAPE); while (faceExplorer.More) { var _faceNode = BuildSubShape(_document, _nodeFused, TopAbsShapeEnum.TopAbs_FACE, faceNumber, true); _generated.Add(_faceNode); faceNumber++; faceExplorer.Next(); } } var nonAdjacent = _candidates.Except(colidingShapes); foreach (var independent in nonAdjacent) { faceNumber = 1; var shape = independent.Get <TopoDsShapeInterpreter>().Shape; faceExplorer = new TopExpExplorer(); faceExplorer.Init(shape, TopAbsShapeEnum.TopAbs_FACE, TopAbsShapeEnum.TopAbs_SHAPE); while (faceExplorer.More) { var _faceNode = BuildSubShape(_document, independent, TopAbsShapeEnum.TopAbs_FACE, faceNumber, true); _generated.Add(_faceNode); faceNumber++; faceExplorer.Next(); } } if (_nodeFused != null) { _document.Root.Remove(_nodeFused.Index); } return(_generated); }
private static TopoDSShape MakePipe(TopoDSShape path, TopoDSShape profile) { try { var baseEx = new TopExpExplorer(); baseEx.Init(path, TopAbsShapeEnum.TopAbs_WIRE, TopAbsShapeEnum.TopAbs_SHAPE); var spline = TopoDS.Wire(baseEx.Current); return(new BRepOffsetAPIMakePipe(spline, profile).Shape); } catch (Exception ex) { Log.Error("Error on making pipe: " + ex.Message); return(null); } }
public static TopoDSShape ExtractSubShape( TopoDSShape originalShape, int facePosition, TopAbsShapeEnum shapeType) { if (originalShape == null) { return(null); } // Find the face var baseEx = new TopExpExplorer(); baseEx.Init(originalShape, shapeType, TopAbsShapeEnum.TopAbs_SHAPE); while (baseEx.More && (facePosition != 1)) { baseEx.Next(); facePosition--; } //if (!baseEx.More()) // return null; TopoDSShape shape = null; switch (shapeType) { case TopAbsShapeEnum.TopAbs_VERTEX: shape = TopoDS.Vertex(baseEx.Current); break; case TopAbsShapeEnum.TopAbs_EDGE: shape = TopoDS.Edge(baseEx.Current); break; case TopAbsShapeEnum.TopAbs_WIRE: shape = TopoDS.Wire(baseEx.Current); break; case TopAbsShapeEnum.TopAbs_FACE: shape = TopoDS.Face(baseEx.Current); break; case TopAbsShapeEnum.TopAbs_SOLID: case TopAbsShapeEnum.TopAbs_COMPOUND: return(originalShape); } return(shape); }