+ 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++;
+ } else if (aNotInTree) { // check this new shape can not be represented as
+ // a sub-shape of higher level sub-shapes
+ TopAbs_ShapeEnum aNewType = aNewShape.ShapeType();
+ TopAbs_ShapeEnum anAncestorType = typeOfAncestor(aNewType);
+ if (anAncestorType != TopAbs_VERTEX) {
+ bool aFound = false;
+ TopoDS_Shape aResultTShape = aResultShape->impl<TopoDS_Shape>();
+ TopExp_Explorer anAncestorExp(aResultTShape, anAncestorType);
+ for(; anAncestorExp.More() && !aFound; anAncestorExp.Next()) {
+ if (aResultTShape.IsSame(anAncestorExp.Current()))
+ continue;
+ TopExp_Explorer aSubExp(anAncestorExp.Current(), aNewType);
+ for(; aSubExp.More(); aSubExp.Next()) {
+ if (aNewShape.IsSame(aSubExp.Current())) {
+ aFound = true;
+ break;
+ }
+ }
+ }
+ if (aFound) {
+ continue; // not need to store this shape in the BRep structure
+ }
+ }
+ }
+
+ 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 if (aNotInTree) {
+ // not in tree -> store as primitive (stored as separated)
+ builder(aBuilderTag)->Generated(aNewShape);
+ } else if (aNewShape.ShapeType() > aRoot.ShapeType()) {
+ // if lower-level type is produced, make it as generated
+ 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) {