static void storeSubShape(ResultBodyPtr theResultBody,
const GeomShapePtr theShape,
const GeomAPI_Shape::ShapeType theType,
- const std::string theName,
- int& theShapeIndex);
+ const std::string& theName);
//=================================================================================================
void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int theInitFlags)
}
// Store shapes.
- int aShapeIndex = 1;
- int aFaceIndex = 1;
for(ListOfShape::const_iterator anIt = theShapes.cbegin(); anIt != theShapes.cend(); ++anIt) {
GeomShapePtr aShape = *anIt;
if(aShapeTypeToExplore == GeomAPI_Shape::COMPOUND) {
std::string aName = theName + (aShape->shapeType() == GeomAPI_Shape::EDGE ? "Edge" : "Face");
- storeSubShape(theResultBody,
- aShape,
- aShape->shapeType(),
- aName,
- aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex);
+ storeSubShape(theResultBody, aShape, aShape->shapeType(), aName);
} else {
std::string aName = theName + aShapeTypeStr;
- storeSubShape(theResultBody,
- aShape,
- aShapeTypeToExplore,
- aName,
- aShapeIndex);
+ storeSubShape(theResultBody, aShape, aShapeTypeToExplore, aName);
if (theBaseShapeType == GeomAPI_Shape::WIRE) { // issue 2289: special names also for vertices
aName = theName + "Vertex";
- storeSubShape(theResultBody,
- aShape,
- GeomAPI_Shape::VERTEX,
- aName,
- aShapeIndex);
+ storeSubShape(theResultBody, aShape, GeomAPI_Shape::VERTEX, aName);
}
}
}
void storeSubShape(ResultBodyPtr theResultBody,
const GeomShapePtr theShape,
const GeomAPI_Shape::ShapeType theType,
- const std::string theName,
- int& theShapeIndex)
+ const std::string& theName)
{
for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
GeomShapePtr aSubShape = anExp.current();
- std::ostringstream aStr;
- aStr << theName << "_" << theShapeIndex++;
- theResultBody->generated(aSubShape, aStr.str());
+ theResultBody->generated(aSubShape, theName);
}
}
TopoDS_Shape aShape = theNewShape->impl<TopoDS_Shape>();
builder(myFreePrimitiveTag)->Generated(aShape);
if (!theName.empty()) {
- buildName(myFreePrimitiveTag, theName);
+ std::string aName = theName;
+ if (myPrimitivesNamesIndexMap.find(theName) != myPrimitivesNamesIndexMap.end()) {
+ IndexTags& anIndexTags = myPrimitivesNamesIndexMap.find(theName)->second;
+ aName += "_" + std::to_string(++(anIndexTags.index));
+ anIndexTags.tags.push_back(myFreePrimitiveTag);
+ if (anIndexTags.index == 2) {
+ buildName(anIndexTags.tags.front(), theName + "_1");
+ }
+ }
+ else {
+ IndexTags anIndexTags;
+ anIndexTags.index = 1;
+ anIndexTags.tags.push_back(myFreePrimitiveTag);
+ myPrimitivesNamesIndexMap[theName] = anIndexTags;
+ }
+
+ buildName(myFreePrimitiveTag, aName);
}
++myFreePrimitiveTag;
}