X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Partition.cpp;h=e7e74c68e91a6d69aab4e473bb11793e084df74c;hb=4fc2dc9fdc0c14fab5f2780598eccdc1368d81b9;hp=2a584910c218521ee7350e879b2a02d8122ec9ca;hpb=404d3f9cf25a17875338b7097b234ea8ed06a7cf;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index 2a584910c..e7e74c68e 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -47,20 +48,6 @@ void FeaturesPlugin_Partition::initAttributes() data()->addAttribute(COMBINE_ID(), ModelAPI_AttributeBoolean::typeId()); } -//================================================================================================= -std::shared_ptr FeaturesPlugin_Partition::getShape(const std::string& theAttrName) -{ - std::shared_ptr aObjRef = - std::dynamic_pointer_cast(data()->attribute(theAttrName)); - if (aObjRef) { - std::shared_ptr aConstr = - std::dynamic_pointer_cast(aObjRef->value()); - if (aConstr) - return aConstr->shape(); - } - return std::shared_ptr(); -} - //================================================================================================= void FeaturesPlugin_Partition::execute() { @@ -92,7 +79,7 @@ void FeaturesPlugin_Partition::execute() aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aContext->shape(), aBoundingPoints); std::shared_ptr aMkShCustom(new GeomAlgoAPI_MakeShapeCustom); aMkShCustom->addModified(aContext->shape(), aTool); - aMakeShapeList.append(aMkShCustom); + aMakeShapeList.appendAlgo(aMkShCustom); aTools.push_back(aTool); aToolsForNaming.push_back(aContext->shape()); } @@ -115,30 +102,36 @@ void FeaturesPlugin_Partition::execute() if(isCombine) { // Create single result. - GeomAlgoAPI_Partition aPartitionAlgo(anObjects, aTools); + if(!aTools.empty()) { + // This is a workaround for naming. Passing compound of objects as argument instead each object separately. + std::shared_ptr aCompoud = GeomAlgoAPI_CompoundBuilder::compound(anObjects); + anObjects.clear(); + anObjects.push_back(aCompoud); + } + std::shared_ptr aPartitionAlgo(new GeomAlgoAPI_Partition(anObjects, aTools)); // Checking that the algorithm worked properly. - if (!aPartitionAlgo.isDone()) { + if (!aPartitionAlgo->isDone()) { static const std::string aFeatureError = "Partition algorithm failed"; setError(aFeatureError); return; } - if (aPartitionAlgo.shape()->isNull()) { + if (aPartitionAlgo->shape()->isNull()) { static const std::string aShapeError = "Resulting shape is Null"; setError(aShapeError); return; } - if (!aPartitionAlgo.isValid()) { + if (!aPartitionAlgo->isValid()) { std::string aFeatureError = "Warning: resulting shape is not valid"; setError(aFeatureError); return; } - if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) { + if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo->shape()) > 1.e-7) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - aMakeShapeList.append(aPartitionAlgo.makeShape()); - GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get(); - loadNamingDS(aResultBody, anObjects.front(), aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes); + aMakeShapeList.appendAlgo(aPartitionAlgo); + GeomAPI_DataMapOfShapeShape& aMapOfShapes = *aPartitionAlgo->mapOfSubShapes().get(); + loadNamingDS(aResultBody, anObjects.front(), aToolsForNaming, aPartitionAlgo->shape(), aMakeShapeList, aMapOfShapes); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -147,30 +140,31 @@ void FeaturesPlugin_Partition::execute() for (ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) { std::shared_ptr anObject = *anObjectsIt; ListOfShape aListWithObject; aListWithObject.push_back(anObject); - GeomAlgoAPI_Partition aPartitionAlgo(aListWithObject, aTools); + std::shared_ptr aPartitionAlgo(new GeomAlgoAPI_Partition(aListWithObject, aTools)); // Checking that the algorithm worked properly. - if (!aPartitionAlgo.isDone()) { + if (!aPartitionAlgo->isDone()) { static const std::string aFeatureError = "Partition algorithm failed"; setError(aFeatureError); return; } - if (aPartitionAlgo.shape()->isNull()) { + if (aPartitionAlgo->shape()->isNull()) { static const std::string aShapeError = "Resulting shape is Null"; setError(aShapeError); return; } - if (!aPartitionAlgo.isValid()) { + if (!aPartitionAlgo->isValid()) { std::string aFeatureError = "Warning: resulting shape is not valid"; setError(aFeatureError); return; } - if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) { + if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo->shape()) > 1.e-7) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - aMakeShapeList.append(aPartitionAlgo.makeShape()); - GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo.mapOfShapes().get(); - loadNamingDS(aResultBody, anObject, aToolsForNaming, aPartitionAlgo.shape(), aMakeShapeList, aMapOfShapes); + GeomAlgoAPI_MakeShapeList aMakeShapeListCopy = aMakeShapeList; + aMakeShapeListCopy.appendAlgo(aPartitionAlgo); + GeomAPI_DataMapOfShapeShape aMapOfShapes = *aPartitionAlgo->mapOfSubShapes().get(); + loadNamingDS(aResultBody, anObject, aToolsForNaming, aPartitionAlgo->shape(), aMakeShapeListCopy, aMapOfShapes); setResult(aResultBody, aResultIndex); aResultIndex++; }