X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_MakeShapeList.cpp;h=eff0d0fe0ee185a2cdcdc84add88616d042c99bc;hb=5fa5757dc6fe8956fc410811126019bf14c97bdd;hp=7cf3b3fb44c74768de6adb32fa4162565cc9fe33;hpb=b3695c3af5289903f1c0fa01bbb7c40203c5e544;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp index 7cf3b3fb4..eff0d0fe0 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// 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_MakeShapeList.h" @@ -25,19 +24,19 @@ #include #include -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList() : GeomAlgoAPI_MakeShape() {} -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList(const ListOfMakeShape& theMakeShapeList) : GeomAlgoAPI_MakeShape() { init(theMakeShapeList); } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList) { if(myMap.get()) { @@ -54,9 +53,15 @@ void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList) } } -//================================================================================================= +const ListOfMakeShape& GeomAlgoAPI_MakeShapeList::list() const +{ + return myListOfMakeShape; +} + + +//================================================================================================== void GeomAlgoAPI_MakeShapeList::appendAlgo( - const std::shared_ptr theMakeShape) + const GeomMakeShapePtr theMakeShape) { myListOfMakeShape.push_back(theMakeShape); if(!myMap.get()) { @@ -65,38 +70,41 @@ void GeomAlgoAPI_MakeShapeList::appendAlgo( myMap->merge(theMakeShape->mapOfSubShapes()); } -//================================================================================================= -const std::shared_ptr GeomAlgoAPI_MakeShapeList::shape() const +//================================================================================================== +const GeomShapePtr GeomAlgoAPI_MakeShapeList::shape() const { - std::shared_ptr aShape = GeomAlgoAPI_MakeShape::shape(); + GeomShapePtr aShape = GeomAlgoAPI_MakeShape::shape(); if(aShape.get() && !aShape->impl().IsNull()) { return aShape; } else if(!myListOfMakeShape.empty()) { return myListOfMakeShape.back()->shape(); } - return std::shared_ptr(); + return GeomShapePtr(); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeList::generated(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { - result(theShape, GeomAlgoAPI_MakeShapeList::Generated, theHistory); + result(theOldShape, theNewShapes); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeList::modified(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { - result(theShape, GeomAlgoAPI_MakeShapeList::Modified, theHistory); + result(theOldShape, theNewShapes); } -bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeList::isDeleted(const GeomShapePtr theOldShape) { - for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); - aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) { - std::shared_ptr aMakeShape = *aBuilderIt; - if(aMakeShape->isDeleted(theShape)) { + for (ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); + aBuilderIt != myListOfMakeShape.end(); + ++aBuilderIt) + { + GeomMakeShapePtr aMakeShape = *aBuilderIt; + if(aMakeShape->isDeleted(theOldShape)) { return true; } } @@ -104,9 +112,9 @@ bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr t return false; } -void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theShape, - OperationType theOperationType, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::result(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { if(myListOfMakeShape.empty()) { return; @@ -115,24 +123,35 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS NCollection_Map anAlgoShapes; NCollection_Map aResultShapesMap; NCollection_List aResultShapesList; - anAlgoShapes.Add(theShape->impl()); - aResultShapesMap.Add(theShape->impl()); - aResultShapesList.Append(theShape->impl()); + anAlgoShapes.Add(theOldShape->impl()); + aResultShapesMap.Add(theOldShape->impl()); + aResultShapesList.Append(theOldShape->impl()); for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); - aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) { - std::shared_ptr aMakeShape = *aBuilderIt; + aBuilderIt != myListOfMakeShape.end(); + ++aBuilderIt) + { + GeomMakeShapePtr aMakeShape = *aBuilderIt; NCollection_Map aTempShapes; - for(NCollection_Map::Iterator - aShapeIt(anAlgoShapes); aShapeIt.More(); aShapeIt.Next()) { + for (NCollection_Map::Iterator aShapeIt(anAlgoShapes); + aShapeIt.More(); + aShapeIt.Next()) + { bool hasResults = false; - std::shared_ptr aShape(new GeomAPI_Shape); + bool anArgumentIsInResult = false; + GeomShapePtr aShape(new GeomAPI_Shape); aShape->setImpl(new TopoDS_Shape(aShapeIt.Value())); ListOfShape aGeneratedShapes; aMakeShape->generated(aShape, aGeneratedShapes); - for(ListOfShape::const_iterator - anIt = aGeneratedShapes.cbegin(); anIt != aGeneratedShapes.cend(); anIt++) { + for (ListOfShape::const_iterator anIt = aGeneratedShapes.cbegin(); + anIt != aGeneratedShapes.cend(); + ++anIt) + { const TopoDS_Shape& anItShape = (*anIt)->impl(); + if (anItShape.IsSame(aShapeIt.Value())) { + anArgumentIsInResult = true; + continue; + } aTempShapes.Add(anItShape); if(aResultShapesMap.Add(anItShape) == Standard_True) { aResultShapesList.Append(anItShape); @@ -141,16 +160,22 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS } ListOfShape aModifiedShapes; aMakeShape->modified(aShape, aModifiedShapes); - for(ListOfShape::const_iterator - anIt = aModifiedShapes.cbegin(); anIt != aModifiedShapes.cend(); anIt++) { + for (ListOfShape::const_iterator anIt = aModifiedShapes.cbegin(); + anIt != aModifiedShapes.cend(); + ++anIt) + { const TopoDS_Shape& anItShape = (*anIt)->impl(); + if (anItShape.IsSame(aShapeIt.Value())) { + anArgumentIsInResult = true; + continue; + } aTempShapes.Add(anItShape); if(aResultShapesMap.Add(anItShape) == Standard_True) { aResultShapesList.Append(anItShape); } hasResults = true; } - if(hasResults) { + if(hasResults && !anArgumentIsInResult) { const TopoDS_Shape& aTopoDSShape = aShapeIt.Value(); if(aResultShapesMap.Remove(aTopoDSShape) == Standard_True) { for(NCollection_List::Iterator @@ -166,10 +191,14 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS anAlgoShapes.Unite(aTempShapes); } - for(NCollection_List::Iterator - aShapeIt(aResultShapesList); aShapeIt.More(); aShapeIt.Next()) { - std::shared_ptr aShape(new GeomAPI_Shape()); + for (NCollection_List::Iterator aShapeIt(aResultShapesList); + aShapeIt.More(); + aShapeIt.Next()) + { + GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(aShapeIt.Value())); - theHistory.push_back(aShape); + if (!isValidForHistory(aShape)) continue; + fixOrientation(aShape); + theNewShapes.push_back(aShape); } }