if(!theIsStoreSameShapes) {
Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aShape, aShapeLab);
- if(!aNS.IsNull() && !aNS->IsEmpty()) {
+ // the last condition is for the issue 2751 : existing shape may be found in compound-NS
+ if(!aNS.IsNull() && !aNS->IsEmpty() && aNS->Get().IsSame(aShape)) {
// This shape is already in document, store reference instead of shape;
const TDF_Label aFoundLabel = aNS->Label();
TDF_Reference::Set(aShapeLab, aFoundLabel);
return;
std::map<int, TNaming_Builder*>::iterator aBuilder = myBuilders.begin();
for(; aBuilder != myBuilders.end(); aBuilder++) {
+ Handle(TNaming_NamedShape) aNS = aBuilder->second->NamedShape();
delete aBuilder->second;
- // clear also shapes on cleaned sub-labels (#2241)
- Handle(TNaming_NamedShape) aNS;
- TDF_Label aSubLab = aLab.FindChild(aBuilder->first);
- if (aSubLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
- aNS->Clear();
- }
+ if (!aNS.IsNull() && !aNS->Label().IsNull())
+ aNS->Label().ForgetAttribute(TNaming_NamedShape::GetID());
}
myBuilders.clear();
myPrimitivesNamesIndexMap.clear();
TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str());
}
-void Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
- const std::string& theName)
+bool Model_BodyBuilder::generated(const GeomShapePtr& theNewShape,
+ const std::string& theName,
+ const bool theCheckIsInResult)
{
GeomShapePtr aResultShape = shape();
-
- bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
- if (aNewShapeIsNotInResultShape) {
- return;
+ if (theCheckIsInResult) {
+ bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false);
+ if (aNewShapeIsNotInResultShape) {
+ return false;
+ }
}
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
buildName(myFreePrimitiveTag, aName);
}
++myFreePrimitiveTag;
+ return true;
}
void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape,