X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Partition.cpp;h=5272cd8188a8afb92283c3f1ece5ae6bde57f968;hb=21a0c85b52bb93f94680e2342370764e6510e387;hp=c9869f12446e83acb31d659f7c5cf7ade3d5970b;hpb=dd8b39697f5344f3f832af2c0d89107bdf454978;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index c9869f124..5272cd818 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -71,7 +71,8 @@ void FeaturesPlugin_Partition::execute() return; } - std::list > aBoundingPoints = GeomAlgoAPI_ShapeTools::getBoundingBox(anObjects, 1.0); + std::list > aBoundingPoints = + GeomAlgoAPI_ShapeTools::getBoundingBox(anObjects, 1.0); // Resize planes. ListOfShape aTools; @@ -86,7 +87,8 @@ void FeaturesPlugin_Partition::execute() } // Create single result. - std::shared_ptr aPartitionAlgo(new GeomAlgoAPI_Partition(anObjects, aTools)); + std::shared_ptr aPartitionAlgo( + new GeomAlgoAPI_Partition(anObjects, aTools)); // Checking that the algorithm worked properly. if (!aPartitionAlgo->isDone()) { @@ -108,14 +110,13 @@ void FeaturesPlugin_Partition::execute() GeomShapePtr aResultShape = aPartitionAlgo->shape(); int aResultIndex = 0; - anObjects.insert(anObjects.end(), aPlanes.begin(), aPlanes.end()); if(aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) { for(GeomAPI_ShapeIterator anIt(aResultShape); anIt.more(); anIt.next()) { - storeResult(anObjects, anIt.current(), aMakeShapeList, aResultIndex); + storeResult(anObjects, aPlanes, anIt.current(), aMakeShapeList, aResultIndex); ++aResultIndex; } } else { - storeResult(anObjects, aResultShape, aMakeShapeList, aResultIndex); + storeResult(anObjects, aPlanes, aResultShape, aMakeShapeList, aResultIndex); ++aResultIndex; } @@ -124,24 +125,29 @@ void FeaturesPlugin_Partition::execute() } //================================================================================================= -void FeaturesPlugin_Partition::storeResult(const ListOfShape& theObjects, - const GeomShapePtr theResultShape, - const std::shared_ptr theMakeShape, - const int theIndex) +void FeaturesPlugin_Partition::storeResult( + ListOfShape& theObjects, ListOfShape& thePlanes, + const GeomShapePtr theResultShape, + const std::shared_ptr theMakeShape, + const int theIndex) { - // Find base. + // Find base. The most complicated is the real modified object (#1799 if box is partitioned by + // two planes the box is the base, not planes, independently on the order in the list). GeomShapePtr aBaseShape; for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) { GeomShapePtr anObjectShape = *anIt; - aBaseShape = findBase(anObjectShape, theResultShape, GeomAPI_Shape::VERTEX, theMakeShape); - if(!aBaseShape.get()) { - aBaseShape = findBase(anObjectShape, theResultShape, GeomAPI_Shape::EDGE, theMakeShape); + GeomShapePtr aCandidate = + findBase(anObjectShape, theResultShape, GeomAPI_Shape::VERTEX, theMakeShape); + if(!aCandidate.get()) { + aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::EDGE, theMakeShape); } - if(!aBaseShape.get()) { - aBaseShape = findBase(anObjectShape, theResultShape, GeomAPI_Shape::FACE, theMakeShape); - } - if(aBaseShape.get()) { - break; + if (!aCandidate.get()) + aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::FACE, theMakeShape); + + if(aCandidate.get()) { + if (!aBaseShape.get() || aBaseShape->shapeType() > aCandidate->shapeType()) { + aBaseShape = aCandidate; + } } } @@ -156,13 +162,15 @@ void FeaturesPlugin_Partition::storeResult(const ListOfShape& theObjects, } const int aDelTag = 1; - const int aSubTag = 2; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids + /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids + const int aSubTag = 2; int aModTag = aSubTag + 10000; const std::string aModName = "Modified"; aResultBody->storeModified(aBaseShape, theResultShape, aSubTag); std::shared_ptr aMapOfSubShapes = theMakeShape->mapOfSubShapes(); + theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end()); int anIndex = 1; for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) { GeomShapePtr aShape = *anIt; @@ -196,7 +204,8 @@ GeomShapePtr findBase(const GeomShapePtr theObjectShape, GeomShapePtr anObjectSubShape = anObjectSubShapesExp.current(); ListOfShape aModifiedShapes; theMakeShape->modified(anObjectSubShape, aModifiedShapes); - for(ListOfShape::const_iterator aModIt = aModifiedShapes.cbegin(); aModIt != aModifiedShapes.cend(); ++aModIt) { + for(ListOfShape::const_iterator + aModIt = aModifiedShapes.cbegin(); aModIt != aModifiedShapes.cend(); ++aModIt) { GeomShapePtr aModShape = *aModIt; if(aMapOfSubShapes->isBound(aModShape)) { aModShape = aMapOfSubShapes->find(aModShape);