From: dbv Date: Tue, 20 Sep 2016 08:40:49 +0000 (+0300) Subject: Fixed naming in Partition and in GeomAlgoAPI_MakeShapeList. X-Git-Tag: V_2.5.1~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dd8b39697f5344f3f832af2c0d89107bdf454978;p=modules%2Fshaper.git Fixed naming in Partition and in GeomAlgoAPI_MakeShapeList. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index 4e84bef15..c9869f124 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -24,10 +24,17 @@ #include #include +#include #include +#include #include +static GeomShapePtr findBase(const GeomShapePtr theObjectShape, + const GeomShapePtr theResultShape, + const GeomAPI_Shape::ShapeType theShapeType, + const std::shared_ptr theMakeShape); + //================================================================================================= FeaturesPlugin_Partition::FeaturesPlugin_Partition() { @@ -126,14 +133,12 @@ void FeaturesPlugin_Partition::storeResult(const ListOfShape& theObjects, GeomShapePtr aBaseShape; for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) { GeomShapePtr anObjectShape = *anIt; - ListOfShape aModifiedShapes; - theMakeShape->modified(anObjectShape, aModifiedShapes); - for(ListOfShape::const_iterator aModIt = aModifiedShapes.cbegin(); aModIt != aModifiedShapes.cend(); ++aModIt) { - GeomShapePtr aModShape = *aModIt; - if(theResultShape->isSubShape(aModShape)) { - aBaseShape = anObjectShape; - break; - } + aBaseShape = findBase(anObjectShape, theResultShape, GeomAPI_Shape::VERTEX, theMakeShape); + if(!aBaseShape.get()) { + aBaseShape = findBase(anObjectShape, theResultShape, GeomAPI_Shape::EDGE, theMakeShape); + } + if(!aBaseShape.get()) { + aBaseShape = findBase(anObjectShape, theResultShape, GeomAPI_Shape::FACE, theMakeShape); } if(aBaseShape.get()) { break; @@ -160,17 +165,51 @@ void FeaturesPlugin_Partition::storeResult(const ListOfShape& theObjects, std::shared_ptr aMapOfSubShapes = theMakeShape->mapOfSubShapes(); int anIndex = 1; for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) { + GeomShapePtr aShape = *anIt; std::string aModEdgeName = aModName + "_Edge_" + std::to_string((long long)anIndex); std::string aModFaceName = aModName + "_Face_" + std::to_string((long long)anIndex++); - aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt, GeomAPI_Shape::EDGE, + aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::EDGE, aModTag, aModEdgeName, *aMapOfSubShapes.get(), true); - aModTag += 1000; - aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt, GeomAPI_Shape::FACE, + aModTag += 10000; + aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, aModTag, aModFaceName, *aMapOfSubShapes.get(), true); - aModTag += 1000; - aResultBody->loadDeletedShapes(theMakeShape.get(), *anIt, GeomAPI_Shape::EDGE, aDelTag); - aResultBody->loadDeletedShapes(theMakeShape.get(), *anIt, GeomAPI_Shape::FACE, aDelTag); + aModTag += 10000; + aResultBody->loadDeletedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::EDGE, aDelTag); + aResultBody->loadDeletedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, aDelTag); } setResult(aResultBody, theIndex); } + + +//================================================================================================= +GeomShapePtr findBase(const GeomShapePtr theObjectShape, + const GeomShapePtr theResultShape, + const GeomAPI_Shape::ShapeType theShapeType, + const std::shared_ptr theMakeShape) +{ + GeomShapePtr aBaseShape; + std::shared_ptr aMapOfSubShapes = theMakeShape->mapOfSubShapes(); + for(GeomAPI_ShapeExplorer anObjectSubShapesExp(theObjectShape, theShapeType); + anObjectSubShapesExp.more(); + anObjectSubShapesExp.next()) { + GeomShapePtr anObjectSubShape = anObjectSubShapesExp.current(); + ListOfShape aModifiedShapes; + theMakeShape->modified(anObjectSubShape, aModifiedShapes); + for(ListOfShape::const_iterator aModIt = aModifiedShapes.cbegin(); aModIt != aModifiedShapes.cend(); ++aModIt) { + GeomShapePtr aModShape = *aModIt; + if(aMapOfSubShapes->isBound(aModShape)) { + aModShape = aMapOfSubShapes->find(aModShape); + } + if(theResultShape->isSubShape(aModShape)) { + aBaseShape = theObjectShape; + break; + } + } + if(aBaseShape.get()) { + break; + } + } + + return aBaseShape; +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp index 7be7d7c12..3c00ea205 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp @@ -6,6 +6,8 @@ #include "GeomAlgoAPI_MakeShapeList.h" + +#include #include #include @@ -95,9 +97,11 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS } NCollection_Map anAlgoShapes; - NCollection_Map aResultShapes; + NCollection_Map aResultShapesMap; + NCollection_List aResultShapesList; anAlgoShapes.Add(theShape->impl()); - aResultShapes.Add(theShape->impl()); + aResultShapesMap.Add(theShape->impl()); + aResultShapesList.Append(theShape->impl()); for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) { std::shared_ptr aMakeShape = *aBuilderIt; @@ -109,25 +113,39 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS ListOfShape aGeneratedShapes; aMakeShape->generated(aShape, aGeneratedShapes); for(ListOfShape::const_iterator anIt = aGeneratedShapes.cbegin(); anIt != aGeneratedShapes.cend(); anIt++) { - aTempShapes.Add((*anIt)->impl()); - aResultShapes.Add((*anIt)->impl()); + const TopoDS_Shape& anItShape = (*anIt)->impl(); + aTempShapes.Add(anItShape); + if(aResultShapesMap.Add(anItShape) == Standard_True) { + aResultShapesList.Append(anItShape); + } hasResults = true; } ListOfShape aModifiedShapes; aMakeShape->modified(aShape, aModifiedShapes); for(ListOfShape::const_iterator anIt = aModifiedShapes.cbegin(); anIt != aModifiedShapes.cend(); anIt++) { - aTempShapes.Add((*anIt)->impl()); - aResultShapes.Add((*anIt)->impl()); + const TopoDS_Shape& anItShape = (*anIt)->impl(); + aTempShapes.Add(anItShape); + if(aResultShapesMap.Add(anItShape) == Standard_True) { + aResultShapesList.Append(anItShape); + } hasResults = true; } if(hasResults) { - aResultShapes.Remove(aShape->impl()); + const TopoDS_Shape& aTopoDSShape = aShapeIt.Value(); + if(aResultShapesMap.Remove(aTopoDSShape) == Standard_True) { + for(NCollection_List::Iterator aResIt(aResultShapesList); aResIt.More(); aResIt.Next()) { + if(aTopoDSShape.IsEqual(aResIt.Value())) { + aResultShapesList.Remove(aResIt); + break; + } + } + } } } anAlgoShapes.Unite(aTempShapes); } - for(NCollection_Map::Iterator aShapeIt(aResultShapes); aShapeIt.More(); aShapeIt.Next()) { + for(NCollection_List::Iterator aShapeIt(aResultShapesList); aShapeIt.More(); aShapeIt.Next()) { std::shared_ptr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(aShapeIt.Value())); theHistory.push_back(aShape);