if (GeomAlgoAPI_ShapeTools::volume(aPartitionAlgo.shape()) > 1.e-7) {
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-
aResultBody->store(aPartitionAlgo.shape());
-
-// LoadNamingDS(aResultBody, anObject, aTools, aPartitionAlgo);
-
+ loadNamingDS(aResultBody, anObject, aTools, aPartitionAlgo);
setResult(aResultBody, aResultIndex);
aResultIndex++;
}
// remove the rest results if there were produced in the previous pass
removeResults(aResultIndex);
}
+
+//=================================================================================================
+void FeaturesPlugin_Partition::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const ListOfShape& theTools,
+ const GeomAlgoAPI_Partition& thePartitionAlgo)
+{
+ //load result
+ if(theBaseShape->isEqual(thePartitionAlgo.shape())) {
+ theResultBody->store(thePartitionAlgo.shape());
+ } else {
+ const int aModifyTag = 1;
+ const int aDeletedTag = 2;
+ const int aSubsolidsTag = 3; /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
+
+ theResultBody->storeModified(theBaseShape, thePartitionAlgo.shape(), aSubsolidsTag);
+
+ std::shared_ptr<GeomAlgoAPI_MakeShape> aMkShape = thePartitionAlgo.makeShape();
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = thePartitionAlgo.mapOfShapes();
+
+ std::string aModName = "Modified";
+ theResultBody->loadAndOrientModifiedShapes(aMkShape.get(), theBaseShape, GeomAPI_Shape::FACE,
+ aModifyTag, aModName, *aMapOfShapes.get());
+ theResultBody->loadDeletedShapes(aMkShape.get(), theBaseShape, GeomAPI_Shape::FACE, aDeletedTag);
+
+ for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
+ theResultBody->loadAndOrientModifiedShapes(aMkShape.get(), *anIter, GeomAPI_Shape::FACE,
+ aModifyTag, aModName, *aMapOfShapes.get());
+ theResultBody->loadDeletedShapes(aMkShape.get(), *anIter, GeomAPI_Shape::FACE, aDeletedTag);
+ }
+ }
+}
#include "FeaturesPlugin.h"
#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Partition.h>
+
/**\class FeaturesPlugin_Partition
* \ingroup Plugins
* \brief Feature for applying of Partition operations on Solids. Partition makes conjunctional
private:
std::shared_ptr<GeomAPI_Shape> getShape(const std::string& theAttrName);
+ /// Load Naming data structure of the feature to the document
+ void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const ListOfShape& theTools,
+ const GeomAlgoAPI_Partition& thePartitionAlgo);
+
};
#endif
myMkShape.reset(new GeomAlgoAPI_MakeShape(anOperation, GeomAlgoAPI_MakeShape::BOPAlgoBuilder));
// Getting objects.
- TopTools_ListOfShape anObjects;
for (ListOfShape::const_iterator anObjectsIt = theObjects.begin(); anObjectsIt != theObjects.end(); anObjectsIt++) {
const TopoDS_Shape& aShape = (*anObjectsIt)->impl<TopoDS_Shape>();
anOperation->AddArgument(aShape);
}
// Getting tools.
- TopTools_ListOfShape aTools;
for (ListOfShape::const_iterator aToolsIt = theTools.begin(); aToolsIt != theTools.end(); aToolsIt++) {
const TopoDS_Shape& aShape = (*aToolsIt)->impl<TopoDS_Shape>();
anOperation->AddTool(aShape);
}
myShape.reset(new GeomAPI_Shape());
myShape->setImpl(new TopoDS_Shape(aResult));
-
}
//=================================================================================================