From: dbv Date: Tue, 27 Dec 2016 15:38:46 +0000 (+0300) Subject: Issue #1920: Wrong naming of faces' edges after translation X-Git-Tag: V_2.7.0~351^2~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=408106edec8b1cb06156c57fc1d1ee63120c137e;p=modules%2Fshaper.git Issue #1920: Wrong naming of faces' edges after translation Added test case for Issue #1920; Fixed TDF_Label Model_Document::findNamingName(std::string theName). Now it check if shape without suffix stored. --- diff --git a/src/BuildPlugin/CMakeLists.txt b/src/BuildPlugin/CMakeLists.txt index 0fef6b358..3cb6433d2 100644 --- a/src/BuildPlugin/CMakeLists.txt +++ b/src/BuildPlugin/CMakeLists.txt @@ -73,4 +73,5 @@ ADD_UNIT_TESTS(TestVertex.py TestWire.py TestFace.py TestShell.py - TestSubShapes.py) + TestSubShapes.py + Test1920.py) diff --git a/src/BuildPlugin/Test/Test1920.py b/src/BuildPlugin/Test/Test1920.py new file mode 100644 index 000000000..4d2439623 --- /dev/null +++ b/src/BuildPlugin/Test/Test1920.py @@ -0,0 +1,39 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(0, 50, 100, 50) +SketchLine_2 = Sketch_1.addLine(100, 50, 100, 0) +SketchLine_3 = Sketch_1.addLine(100, 0, 0, 0) +SketchLine_4 = Sketch_1.addLine(0, 0, 0, 50) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +SketchLine_5 = Sketch_1.addLine(50, 50, 50, 0) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_1.result()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_3.result()) +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_5f")]) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OY"), 100) +Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Translation_1_1/Translated_Edge_1"), model.selection("EDGE", "Translation_1_1/Translated_Edge_2"), model.selection("EDGE", "Translation_1_1/Translated_Edge_3"), model.selection("EDGE", "Translation_1_1/Translated_Edge_4"), model.selection("EDGE", "Translation_1_2/Translated_Edge_1"), model.selection("EDGE", "Translation_1_2/Translated_Edge_2"), model.selection("EDGE", "Translation_1_2/Translated_Edge_3"), model.selection("EDGE", "Translation_1_2/Translated_Edge_4")]) +aGroupFeature = Group_1.feature() +aSelectionList = aGroupFeature.selectionList("group_list") +model.end() +assert(aSelectionList.size() == 8) +for index in range(0, aSelectionList.size()): + attrSelection = aSelectionList.value(index) + shape = attrSelection.value() + name = attrSelection.namingName() + assert(shape.isEdge()) + assert(name) + +assert(model.checkPythonDump()) \ No newline at end of file diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index e3af397f3..4311f40f6 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1239,6 +1239,20 @@ TDF_Label Model_Document::findNamingName(std::string theName) if (aName->Get() == aSubName) return aName->Label(); } + // If not found child label with the exact sub-name, then try to find compound with + // such sub-name without suffix. + Standard_Integer aSuffixPos = aSubName.SearchFromEnd('_'); + if (aSuffixPos != -1) { + TCollection_ExtendedString anIndexStr = aSubName.Split(aSuffixPos); + aSubName.Remove(aSuffixPos); + aNamesIter.Initialize(aFind->second, TDataStd_Name::GetID(), Standard_True); + for(; aNamesIter.More(); aNamesIter.Next()) { + Handle(TDataStd_Name) aName = Handle(TDataStd_Name)::DownCast(aNamesIter.Value()); + if (aName->Get() == aSubName) { + return aName->Label(); + } + } + } } } return TDF_Label(); // not found