+/// registers the name of the shape in the label (theID == 0) of sub label (theID is a tag)
+/// if theID is zero,
+static void registerSubShape(TDF_Label& theMainLabel, TopoDS_Shape theShape,
+ const int theID, const FeaturePtr& theContextFeature, std::shared_ptr<Model_Document> theDoc,
+ std::string theAdditionalName,
+ Handle(TDataStd_IntPackedMap) theRefs = Handle(TDataStd_IntPackedMap)())
+{
+ TDF_Label aLab = theID == 0 ? theMainLabel : theMainLabel.FindChild(theID);
+ TNaming_Builder aBuilder(aLab);
+ aBuilder.Generated(theShape);
+ std::stringstream aName;
+ aName<<theContextFeature->name()<<"/";
+ if (!theAdditionalName.empty())
+ aName<<theAdditionalName<<"/";
+ if (theShape.ShapeType() == TopAbs_FACE) aName<<"Face";
+ else if (theShape.ShapeType() == TopAbs_EDGE) aName<<"Edge";
+ else if (theShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex";
+
+ if (theRefs.IsNull()) {
+ aName<<"_"<<theID;
+ } else { // make a compisite name from all sub-elements indexes: "1_2_3_4"
+ TColStd_MapIteratorOfPackedMapOfInteger aRef(theRefs->GetMap());
+ for(; aRef.More(); aRef.Next()) {
+ aName<<"_"<<aRef.Key();
+ }
+ }
+
+ theDoc->addNamingName(aLab, aName.str());
+ TDataStd_Name::Set(aLab, aName.str().c_str());
+}
+