- // check if the subShape is already in DF
- aName = GetShapeName(aDoc, aSubShape, selectionLabel());
- if(aName.empty() ) { // not in the document!
- TopAbs_ShapeEnum aType = aSubShape.ShapeType();
- switch (aType) {
- case TopAbs_FACE:
- // the Face should be in DF. If it is not the case, it is an error ==> to be debugged
- break;
- case TopAbs_EDGE:
- {
- // name structure: F1 | F2 [| F3 | F4], where F1 & F2 the faces which gives the Edge in trivial case
- // if it is not atrivial case we use localization by neighbours. F3 & F4 - neighbour faces
- if (BRep_Tool::Degenerated(TopoDS::Edge(aSubShape))) {
- aName = "Degenerated_Edge";
- break;
- }
- TopTools_IndexedDataMapOfShapeListOfShape aMap;
- TopExp::MapShapesAndAncestors(aContext, TopAbs_EDGE, TopAbs_FACE, aMap);
- TopTools_IndexedMapOfShape aSMap; // map for ancestors of the sub-shape
- bool isTrivialCase(true);
-/* for (int i = 1; i <= aMap.Extent(); i++) {
- const TopoDS_Shape& aKey = aMap.FindKey(i);
- //if (aKey.IsNotEqual(aSubShape)) continue; // find exactly the selected key
- if (aKey.IsSame(aSubShape)) continue;
- const TopTools_ListOfShape& anAncestors = aMap.FindFromIndex(i);
- // check that it is not a trivial case (F1 & F2: aNumber = 1)
- isTrivialCase = isTrivial(anAncestors, aSMap);
- break;
- }*/
- if(aMap.Contains(aSubShape)) {
- const TopTools_ListOfShape& anAncestors = aMap.FindFromKey(aSubShape);
- // check that it is not a trivial case (F1 & F2: aNumber = 1)
- isTrivialCase = isTrivial(anAncestors, aSMap);
- } else
- break;
- TopTools_ListOfShape aListOfNbs;
- if(!isTrivialCase) { // find Neighbors
- TNaming_Localizer aLocalizer;
- TopTools_MapOfShape aMap3;
- aLocalizer.FindNeighbourg(aContext, aSubShape, aMap3);
- //int n = aMap3.Extent();
- TopTools_MapIteratorOfMapOfShape it(aMap3);
- for(;it.More();it.Next()) {
- const TopoDS_Shape& aNbShape = it.Key(); // neighbor edge
- //TopAbs_ShapeEnum aType = aNbShape.ShapeType();
- const TopTools_ListOfShape& aList = aMap.FindFromKey(aNbShape);
- TopTools_ListIteratorOfListOfShape it2(aList);
- for(;it2.More();it2.Next()) {
- if(aSMap.Contains(it2.Value())) continue; // skip this Face
- aListOfNbs.Append(it2.Value());
- }
- }
- } // else a trivial case
-
- // build name of the sub-shape Edge
- for(int i=1; i <= aSMap.Extent(); i++) {
- const TopoDS_Shape& aFace = aSMap.FindKey(i);
- std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel());
- if(i == 1)
- aName = aFaceName;
- else
- aName += "|" + aFaceName;
- }
- TopTools_ListIteratorOfListOfShape itl(aListOfNbs);
- for (;itl.More();itl.Next()) {
- std::string aFaceName = GetShapeName(aDoc, itl.Value(), selectionLabel());
- aName += "|" + aFaceName;
- }
- }
- break;