+ GeomShapePtr aGeomNewShape(new GeomAPI_Shape());
+ aGeomNewShape->setImpl(new TopoDS_Shape(aNewShape));
+ if(!aRoot.IsSame(aNewShape) && aResultShape->isSubShape(aGeomNewShape, false) &&
+ !aResultShape->isSame(*anIt)) { // to avoid put of same shape on main label and sub
+ int aBuilderTag = aTag;
+ if (!theIsStoreSeparate)
+ aSameParentShapes++;
+
+ static const int THE_ANCHOR_TAG = 100000;
+ int aCurShapeType = (int)((*anIt)->shapeType());
+ bool needSuffix = false; // suffix for the name based on the shape type
+ if (aSameParentShapes > 0) { // store in other label
+ aBuilderTag = THE_ANCHOR_TAG - aSameParentShapes * 10 - aCurShapeType;
+ needSuffix = true;
+ } else if (aCurShapeType != theKindOfShape) {
+ // modified shape has different type => set another tag
+ // to avoid shapes of different types on the same label
+ aBuilderTag = THE_ANCHOR_TAG - aCurShapeType;
+ needSuffix = true;
+ }
+ std::string aSuffix;
+ if (needSuffix) {
+ switch (aCurShapeType) {
+ case GeomAPI_Shape::VERTEX: aSuffix = "_v"; break;
+ case GeomAPI_Shape::EDGE: aSuffix = "_e"; break;
+ case GeomAPI_Shape::FACE: aSuffix = "_f"; break;
+ default: break;
+ }
+ }
+
+ if(theIsStoreAsGenerated) {
+ // Here we store shapes as generated, to avoid problem when one parent shape produce
+ // several child shapes. In this case naming could not determine which shape to select.
+ builder(aBuilderTag)->Generated(aRoot, aNewShape);
+ } else {
+ builder(aBuilderTag)->Modify(aRoot, aNewShape);
+ }
+ if(isBuilt) {
+ aStream.str(std::string());
+ aStream.clear();
+ aStream << theName;
+ if(theIsStoreSeparate)
+ aStream << "_" << anIndex++;
+
+ if (aSameParentShapes > 0) {
+ aStream.str(std::string());
+ aStream.clear();
+ aStream << aName << "_" << aSameParentShapes << "divided";
+ }
+
+ aStream << aSuffix;
+ buildName(aBuilderTag, aStream.str());
+ }
+ if(theIsStoreSeparate) {
+ aTag++;
+ }
+ } else if (aResultShape->isSame(*anIt)) {
+ // keep the modification evolution on the root level (2241 - history propagation issue)
+ if(theIsStoreAsGenerated) {
+ builder(0)->Generated(aRoot, aNewShape);
+ } else {
+ builder(0)->Modify(aRoot, aNewShape);
+ }