]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1920: Wrong naming of faces' edges after translation
authordbv <dbv@opencascade.com>
Tue, 27 Dec 2016 15:38:46 +0000 (18:38 +0300)
committerdbv <dbv@opencascade.com>
Tue, 27 Dec 2016 15:39:03 +0000 (18:39 +0300)
Added test case for Issue #1920;
Fixed TDF_Label Model_Document::findNamingName(std::string theName). Now it check if shape without suffix stored.

src/BuildPlugin/CMakeLists.txt
src/BuildPlugin/Test/Test1920.py [new file with mode: 0644]
src/Model/Model_Document.cpp

index 0fef6b358143deb1640b82939c4dd54e613c774f..3cb6433d2cfa3239901c6d69a8a170e9cdc94b97 100644 (file)
@@ -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 (file)
index 0000000..4d24396
--- /dev/null
@@ -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
index e3af397f36feadbbaac93639749c7ed852b43acb..4311f40f6580f05393d19b6690c9a7711bc75af0 100755 (executable)
@@ -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