1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_WireBuilder.cpp
4 // Created: 14 April 2016
5 // Author: Dmitry Bobylev
7 #include "GeomAlgoAPI_WireBuilder.h"
9 #include <BRepBuilderAPI_MakeWire.hxx>
11 #include <TopoDS_Wire.hxx>
12 #include <TopExp_Explorer.hxx>
14 //=================================================================================================
15 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_WireBuilder::wire(const ListOfShape& theShapes)
17 TopTools_ListOfShape aListOfEdges;
19 for(ListOfShape::const_iterator anIt = theShapes.cbegin(); anIt != theShapes.cend(); ++anIt) {
20 const TopoDS_Shape& aShape = (*anIt)->impl<TopoDS_Shape>();
21 switch(aShape.ShapeType()) {
23 aListOfEdges.Append(aShape);
27 for(TopExp_Explorer anExp(aShape, TopAbs_EDGE); anExp.More(); anExp.Next()) {
28 aListOfEdges.Append(anExp.Current());
33 return GeomShapePtr();
38 BRepBuilderAPI_MakeWire aWireBuilder;
39 aWireBuilder.Add(aListOfEdges);
40 if(aWireBuilder.Error() != BRepBuilderAPI_WireDone) {
41 return GeomShapePtr();
44 GeomShapePtr aResultShape(new GeomAPI_Shape());
45 aResultShape->setImpl(new TopoDS_Shape(aWireBuilder.Wire()));