X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Partition.cpp;h=cd880734a65e4c56d03250784d6417e39b525aa8;hb=665435f0512e2f26abdbe7832b90af6f560b6451;hp=5db097c79ef8062c09e2c5ba19e98cd1f3706ad0;hpb=2532fb2df83ee1ddd9ff3e8b381d3788eaa15b69;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp index 5db097c79..cd880734a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp @@ -14,7 +14,8 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com // #include "GeomAlgoAPI_Partition.h" @@ -26,6 +27,7 @@ #include #include +#include //================================================================================================= std::shared_ptr GeomAlgoAPI_Partition::make(const ListOfShape& theObjects, @@ -45,6 +47,21 @@ GeomAlgoAPI_Partition::GeomAlgoAPI_Partition(const ListOfShape& theObjects, build(theObjects, theTools); } +static void prepareShapes(const TopoDS_Shape& theShape, + TopTools_ListOfShape& theSimpleList) +{ + if (theShape.ShapeType() != TopAbs_COMPOUND) { + theSimpleList.Append(theShape); + return; + } + + // explode compound on simple shapes to allow their intersections + TopoDS_Iterator It (theShape, Standard_True, Standard_True); + for (; It.More(); It.Next()) { + TopoDS_Shape curSh = It.Value(); + prepareShapes(curSh, theSimpleList); + } +} //================================================================================================= void GeomAlgoAPI_Partition::build(const ListOfShape& theObjects, @@ -59,11 +76,21 @@ void GeomAlgoAPI_Partition::build(const ListOfShape& theObjects, this->setImpl(anOperation); this->setBuilderType(OCCT_BOPAlgo_Builder); + TopTools_MapOfShape ShapesMap; // Getting objects. - for (ListOfShape::const_iterator + for(ListOfShape::const_iterator anObjectsIt = theObjects.begin(); anObjectsIt != theObjects.end(); anObjectsIt++) { const TopoDS_Shape& aShape = (*anObjectsIt)->impl(); - anOperation->AddArgument(aShape); + // #2240: decompose compounds to get the valid result + TopTools_ListOfShape aSimpleShapes; + prepareShapes(aShape, aSimpleShapes); + TopTools_ListIteratorOfListOfShape aSimpleIter(aSimpleShapes); + for (; aSimpleIter.More(); aSimpleIter.Next()) { + const TopoDS_Shape& aSimpleSh = aSimpleIter.Value(); + if (ShapesMap.Add(aSimpleSh)) { + anOperation->AddArgument(aSimpleSh); + } + } } // Getting tools.