// Author: Artem ZHIDKOV
#include <GeomAlgoAPI_SketchBuilder.h>
+#include <GeomAPI_PlanarEdges.h>
#include <set>
while (aMapVE.Extent() > 0) {
if (aCurVertex.IsNull())
return;
+ if (!aProcEdges.empty())
+ aBindingEdge = aProcEdges.back();
findNextVertex(aCurVertex, aMapVE, aCurDir, aCurNorm, aNextVertex, aBindingEdge, aNextDir);
aCurNorm = aNorm;
fixIntersections(theResultFaces);
}
+void GeomAlgoAPI_SketchBuilder::createFaces(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirX,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirY,
+ const boost::shared_ptr<GeomAPI_Dir>& theNorm,
+ const boost::shared_ptr<GeomAPI_Shape>& theWire,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultFaces)
+{
+ boost::shared_ptr<GeomAPI_PlanarEdges> aWire = boost::dynamic_pointer_cast<GeomAPI_PlanarEdges>(theWire);
+ if(!aWire)
+ return;
+ // Filter wires, return only faces.
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFilteredWires;
+ createFaces(theOrigin, theDirX, theDirY, theNorm,
+ aWire->getEdges(), theResultFaces, aFilteredWires);
+}
+
+
void GeomAlgoAPI_SketchBuilder::fixIntersections(
std::list<boost::shared_ptr<GeomAPI_Shape> >& theFaces)
{
const gp_Dir& theStartDir, const gp_Dir& theNormal, TopoDS_Vertex& theNextVertex,
TopoDS_Edge& theNextEdge, gp_Dir& theNextDir)
{
+ theNextVertex = TopoDS_Vertex();
const BOPCol_ListOfShape& anEdgesList = theVertexEdgeMap.FindFromKey(theStartVertex);
int anEdgesNum = anEdgesList.Extent();
BOPCol_ListOfShape::Iterator aEdIter(anEdgesList);
}
}
}
+
+ // Probably there are two tangent edges. We will take the edge differs from current one
+ if (theNextVertex.IsNull() && anEdgesNum == 2) {
+ BOPCol_ListOfShape::Iterator aEdIter(anEdgesList);
+ if (aEdIter.Value() == theNextEdge)
+ aEdIter.Next();
+ theNextEdge = static_cast<const TopoDS_Edge&>(aEdIter.Value());
+ TopoDS_Vertex aV1, aV2;
+ TopExp::Vertices(theNextEdge, aV1, aV2);
+ theNextVertex = theStartVertex.IsSame(aV1) ? aV2 : aV1;
+ theNextDir = getOuterEdgeDirection(theNextEdge, theNextVertex);
+ }
}
static void addEdgeToWire(const TopoDS_Edge& theEdge, const BRep_Builder& theBuilder,