From c7cdd28de75790aa806458c9784d14218b852cb1 Mon Sep 17 00:00:00 2001 From: szy Date: Fri, 23 Jan 2015 17:39:42 +0300 Subject: [PATCH] Fix for the issue #365. --- src/Model/Model_AttributeSelection.cpp | 40 +++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index cda2ef0d3..7d2c9fa1b 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -618,7 +618,7 @@ std::string Model_AttributeSelection::namingName() TopAbs_ShapeEnum aType = aSubShape.ShapeType(); switch (aType) { case TopAbs_FACE: - // the Face should be in DF. If it is not a case, it is an error ==> to be dbugged + // the Face should be in DF. If it is not the case, it is an error ==> to be debugged break; case TopAbs_EDGE: { @@ -677,6 +677,7 @@ std::string Model_AttributeSelection::namingName() case TopAbs_VERTEX: // name structure (Monifold Topology): // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case. + // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, but it should be kept as is to obtain safe recomputation // 2) F1 | F2 - intersection of 2 faces definses a vertex - applicable for case // when 1 faces is cylindrical, conical, spherical or revolution and etc. // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell @@ -691,7 +692,7 @@ std::string Model_AttributeSelection::namingName() TopTools_ListOfShape aList; TopTools_MapOfShape aFMap; #ifdef FIX_BUG1 - //int n = aList2.Extent(); //bug! + //int n = aList2.Extent(); //bug! duplication // fix is below TopTools_ListIteratorOfListOfShape itl2(aList2); for (int i = 1;itl2.More();itl2.Next(),i++) { @@ -700,14 +701,33 @@ std::string Model_AttributeSelection::namingName() } //n = aList.Extent(); #endif - TopTools_ListIteratorOfListOfShape itl(aList); - for (int i = 1;itl.More();itl.Next(),i++) { - const TopoDS_Shape& aFace = itl.Value(); - std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel()); - if(i == 1) - aName = aFaceName; - else - aName += "|" + aFaceName; + int n = aList.Extent(); + if(n < 3) { // open topology case => via edges + TopTools_IndexedDataMapOfShapeListOfShape aMap; + TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap); + const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape); + if(aList2.Extent() >= 2) { // regular solution + TopTools_ListIteratorOfListOfShape itl(aList2); + for (int i = 1;itl.More();itl.Next(),i++) { + const TopoDS_Shape& anEdge = itl.Value(); + std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel()); + if(i == 1) + aName = anEdgeName; + else + aName += "|" + anEdgeName; + } + } + } + else { + TopTools_ListIteratorOfListOfShape itl(aList); + for (int i = 1;itl.More();itl.Next(),i++) { + const TopoDS_Shape& aFace = itl.Value(); + std::string aFaceName = GetShapeName(aDoc, aFace, selectionLabel()); + if(i == 1) + aName = aFaceName; + else + aName += "|" + aFaceName; + } } } break; -- 2.39.2