X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_SketchBuilder.cpp;h=8359b32448f7c4364eba15947190893696733dbb;hb=580f1752efd9d3e8c2890c4016b04dafd639bab7;hp=b7ef59f5d68b549f8198d52b6b88fbc69404ff4c;hpb=b2a34ee4bab2fe2d97f900cbdafcaf122344c46c;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp index b7ef59f5d..8359b3244 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp @@ -1,8 +1,11 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: GeomAlgoAPI_SketchBuilder.cpp // Created: 02 Jun 2014 // Author: Artem ZHIDKOV #include +#include #include @@ -79,11 +82,12 @@ static void removeWasteEdges(std::list::iterator& theStartVertex, void GeomAlgoAPI_SketchBuilder::createFaces( - const boost::shared_ptr& theOrigin, const boost::shared_ptr& theDirX, - const boost::shared_ptr& theDirY, const boost::shared_ptr& theNorm, - const std::list >& theFeatures, - std::list >& theResultFaces, - std::list >& theResultWires) + const std::shared_ptr& theOrigin, + const std::shared_ptr& theDirX, + const std::shared_ptr& theNorm, + const std::list >& theFeatures, + std::list >& theResultFaces, + std::list >& theResultWires) { if (theFeatures.empty()) return; @@ -94,10 +98,10 @@ void GeomAlgoAPI_SketchBuilder::createFaces( TopoDS_Shape aFeaturesCompound; // Obtain only edges from the features list - std::list > anEdges; - std::list >::const_iterator aFeatIt = theFeatures.begin(); + std::list > anEdges; + std::list >::const_iterator aFeatIt = theFeatures.begin(); for (; aFeatIt != theFeatures.end(); aFeatIt++) { - boost::shared_ptr aShape(*aFeatIt); + std::shared_ptr aShape(*aFeatIt); const TopoDS_Edge& anEdge = aShape->impl(); if (anEdge.ShapeType() == TopAbs_EDGE) anEdges.push_back(aShape); @@ -106,9 +110,9 @@ void GeomAlgoAPI_SketchBuilder::createFaces( if (anEdges.size() == 1) { // If there is only one feature, BOPAlgo_Builder will decline to work. Need to process it anyway aFeaturesCompound = anEdges.front()->impl(); } else { - std::list >::const_iterator anIt = anEdges.begin(); + std::list >::const_iterator anIt = anEdges.begin(); for (; anIt != anEdges.end(); anIt++) { - boost::shared_ptr aPreview(*anIt); + std::shared_ptr aPreview(*anIt); aBuilder.AddArgument(aPreview->impl()); } aPF.SetArguments(aBuilder.Arguments()); @@ -129,8 +133,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces( return; gp_Dir aDirX = theDirX->impl(); - gp_Dir aDirY = theDirY->impl(); gp_Dir aNorm = theNorm->impl(); + gp_Dir aDirY = aNorm.Crossed(aDirX); gp_Pln aPlane(theOrigin->impl(), aNorm); @@ -155,6 +159,8 @@ void GeomAlgoAPI_SketchBuilder::createFaces( while (aMapVE.Extent() > 0) { if (aCurVertex.IsNull()) return; + if (!aProcEdges.empty()) + aBindingEdge = aProcEdges.back(); findNextVertex(aCurVertex, aMapVE, aCurDir, aCurNorm, aNextVertex, aBindingEdge, aNextDir); aCurNorm = aNorm; @@ -216,7 +222,7 @@ void GeomAlgoAPI_SketchBuilder::createFaces( TopoDS_Face aPatch; createFace(*aVertIter, anEdgeIter, aProcEdges.end(), aPlane, aPatch); if (!aPatch.IsNull()) { - boost::shared_ptr aFace(new GeomAPI_Shape); + std::shared_ptr aFace(new GeomAPI_Shape); aFace->setImpl(new TopoDS_Face(aPatch)); theResultFaces.push_back(aFace); } @@ -320,7 +326,7 @@ void GeomAlgoAPI_SketchBuilder::createFaces( std::list::const_iterator aTailIter = aTail.begin(); for (; aTailIter != aTail.end(); aTailIter++) if (!aTailIter->IsNull()) { - boost::shared_ptr aWire(new GeomAPI_Shape); + std::shared_ptr aWire(new GeomAPI_Shape); aWire->setImpl(new TopoDS_Shape(*aTailIter)); theResultWires.push_back(aWire); } @@ -368,13 +374,40 @@ void GeomAlgoAPI_SketchBuilder::createFaces( fixIntersections(theResultFaces); } +void GeomAlgoAPI_SketchBuilder::createFaces(const std::shared_ptr& theOrigin, + const std::shared_ptr& theDirX, + const std::shared_ptr& theNorm, + const std::shared_ptr& theWire, + std::list >& theResultFaces) +{ + std::list > aFilteredWires; + std::shared_ptr aWire = + std::dynamic_pointer_cast(theWire); + if(aWire) { + // Filter wires, return only faces. + createFaces(theOrigin, theDirX, theNorm, + aWire->getEdges(), theResultFaces, aFilteredWires); + + return; + } else { // it may be only one circle + std::shared_ptr anEdge = std::dynamic_pointer_cast(theWire); + if (anEdge) { + std::list > aList; + aList.push_back(anEdge); + createFaces(theOrigin, theDirX, theNorm, + aList, theResultFaces, aFilteredWires); + } + } +} + + void GeomAlgoAPI_SketchBuilder::fixIntersections( - std::list >& theFaces) + std::list >& theFaces) { BRepClass_FaceClassifier aClassifier; - std::list >::iterator anIter1 = theFaces.begin(); - std::list >::iterator anIter2; + std::list >::iterator anIter1 = theFaces.begin(); + std::list >::iterator anIter2; for (; anIter1 != theFaces.end(); anIter1++) { anIter2 = anIter1; for (++anIter2; anIter2 != theFaces.end(); anIter2++) { @@ -410,7 +443,7 @@ void GeomAlgoAPI_SketchBuilder::fixIntersections( (*anIter2)->setImpl(new TopoDS_Shape(anExp.Current())); isFirstFace = false; } else { - boost::shared_ptr aShape(new GeomAPI_Shape); + std::shared_ptr aShape(new GeomAPI_Shape); aShape->setImpl(new TopoDS_Shape(anExp.Current())); theFaces.push_back(aShape); } @@ -427,7 +460,7 @@ void GeomAlgoAPI_SketchBuilder::fixIntersections( (*anIter1)->setImpl(new TopoDS_Shape(anExp.Current())); isFirstFace = false; } else { - boost::shared_ptr aShape(new GeomAPI_Shape); + std::shared_ptr aShape(new GeomAPI_Shape); aShape->setImpl(new TopoDS_Shape(anExp.Current())); theFaces.push_back(aShape); } @@ -466,6 +499,7 @@ void findNextVertex(const TopoDS_Vertex& theStartVertex, 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); @@ -505,6 +539,18 @@ void findNextVertex(const TopoDS_Vertex& theStartVertex, } } } + + // 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(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,