int aModTag = aSubTag + 10000;
const std::string aModName = "Modified";
- aResultBody->storeModified(aBaseShape, theResultShape, aSubTag);
+ // issue #2241 : make result of partition modified from all input objects (except planes)
+ bool aIsModifierStored = false;
+ for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) {
+ GeomShapePtr anObjectShape = *anIt;
+ GeomShapePtr aCandidate =
+ findBase(anObjectShape, theResultShape, GeomAPI_Shape::VERTEX, theMakeShape);
+ if(!aCandidate.get()) {
+ aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::EDGE, theMakeShape);
+ }
+ if (!aCandidate.get())
+ aCandidate = findBase(anObjectShape, theResultShape, GeomAPI_Shape::FACE, theMakeShape);
+
+ if(aCandidate.get()) {
+ aResultBody->storeModified(aCandidate, theResultShape, aSubTag, !aIsModifierStored);
+ aIsModifierStored = true;
+ }
+ }
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfSubShapes = theMakeShape->mapOfSubShapes();
theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end());
Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_9f-SketchLine_10r-SketchArc_1_2f-SketchArc_2_2r")])
Face_3 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2")])
Face_4 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")])
-Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1")])
Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")])
Group_1.result().setName("eau")
Group_1.result().setColor(0, 170, 255)
Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_4_1")])
Group_2.result().setName("acier")
Group_2.result().setColor(170, 85, 0)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1")])
Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOY"))
SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0)
SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "Partition_1_1_1/Modified_Edge_15_6&Partition_1_1_1/Modified_Edge_15_5"))
}
void Model_BodyBuilder::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag,
+ const bool theClean)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
- TDF_Label& aShapeLab = aData->shapeLab();
// clean builders
- clean();
+ if (theClean)
+ clean();
// store the new shape as primitive
- TNaming_Builder aBuilder(aShapeLab);
+ TNaming_Builder* aBuilder = builder(0);
if (!theOldShape || !theNewShape)
return; // bad shape
TopoDS_Shape aShapeOld = theOldShape->impl<TopoDS_Shape>();
TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
if (aShapeNew.IsNull())
return; // null shape inside
- aBuilder.Modify(aShapeOld, aShapeNew);
- if(!aBuilder.NamedShape()->IsEmpty()) {
+ aBuilder->Modify(aShapeOld, aShapeNew);
+ if(!aBuilder->NamedShape()->IsEmpty()) {
Handle(TDataStd_Name) anAttr;
- if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
+ if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) {
std::string aName (TCollection_AsciiString(anAttr->Get()).ToCString());
if(!aName.empty()) {
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(document());
- aDoc->addNamingName(aBuilder.NamedShape()->Label(), aName);
+ aDoc->addNamingName(aBuilder->NamedShape()->Label(), aName);
}
}
}
std::map<int, TNaming_Builder*>::iterator aFind = myBuilders.find(theTag);
if (aFind == myBuilders.end()) {
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
- myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
+ TDF_Label aLab = theTag == 0 ? aData->shapeLab() : aData->shapeLab().FindChild(theTag);
+ myBuilders[theTag] = new TNaming_Builder(aLab);
aFind = myBuilders.find(theTag);
}
return aFind->second;
/// theNewShape is compound of solids, if zero it is not used
MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const int theDecomposeSolidsTag = 0);
+ const int theDecomposeSolidsTag = 0,
+ const bool theClean = true);
/// Stores the shape without naming support
/// \param theShape shape to store
}
void Model_ResultCompSolid::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag,
+ const bool theClean)
{
- ModelAPI_ResultCompSolid::storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+ ModelAPI_ResultCompSolid::storeModified(theOldShape, theNewShape, theDecomposeSolidsTag,
+ theClean);
updateSubs(theNewShape);
}
/// Stores the modified shape. Creates sub-results for compsolid.
MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0,
+ const bool theClean = true);
/// load and orient modified shapes for sub-objects
MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
/// Stores the modified shape (called by the execution method).
virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const int theDecomposeSolidsTag = 0) = 0;
+ const int theDecomposeSolidsTag = 0,
+ const bool theClean = true) = 0;
/// Stores the shape without naming support
virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const int theDecomposeSolidsTag)
+ const int theDecomposeSolidsTag, const bool theClean)
{
- myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
+ myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag, theClean);
myConnect = ConnectionNotComputed;
static Events_Loop* aLoop = Events_Loop::loop();
/// Stores the modified shape (called by the execution method).
MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0,
+ const bool theClean = true);
/// Stores the shape without naming support
MODELAPI_EXPORT virtual void storeWithoutNaming(