]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2873: Freeze when inserting a new folder
authorazv <azv@opencascade.com>
Wed, 27 Feb 2019 14:03:28 +0000 (17:03 +0300)
committerazv <azv@opencascade.com>
Wed, 27 Feb 2019 14:03:28 +0000 (17:03 +0300)
Fix incorrect naming new folder.

src/Model/Model_Objects.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/Test2873.py [new file with mode: 0644]

index 86c9e5e6f16f4153ca54a527fcd580f843a64c14..971f8a3051da67e66a5be5758220243b815f44e9 100644 (file)
@@ -770,7 +770,7 @@ void Model_Objects::setUniqueName(FolderPtr theFolder)
   NCollection_DataMap<TDF_Label, ObjectPtr>::Iterator anIt(myFolders);
   while (anIt.More()) {
     if (anIt.Value()->data()->name() == aName) {
-      aName = composeName(ModelAPI_Folder::ID(), aNbFolders);
+      aName = composeName(ModelAPI_Folder::ID(), ++aNbFolders);
       // reinitialize iterator to make sure a new name is unique
       anIt.Initialize(myFolders);
     } else
index 90f3e9963a4a1047caa2c7335a81e1182af7c32e..174b814046fc1a37ef5a98cac1f0ef79dafb9c07 100644 (file)
@@ -243,4 +243,5 @@ ADD_UNIT_TESTS(TestConstants.py
                Test2493.py
                Test2627.py
                Test2859.py
+               Test2873.py
 )
diff --git a/src/ModelAPI/Test/Test2873.py b/src/ModelAPI/Test/Test2873.py
new file mode 100644 (file)
index 0000000..d8e88bd
--- /dev/null
@@ -0,0 +1,62 @@
+# Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+    Test2873.py
+    Test for issue #2873 "Freeze when inserting a new folder"
+"""
+
+from salome.shaper import model
+from ModelAPI import *
+
+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(50, -50, -50, -50)
+SketchLine_2 = Sketch_1.addLine(-50, -50, -50, 50)
+SketchLine_3 = Sketch_1.addLine(-50, 50, 50, 50)
+SketchLine_4 = Sketch_1.addLine(50, 50, 50, -50)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.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())
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Face_1_1/Modified_Edge&Sketch_1/SketchLine_4")])
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "PartSet/Origin")])
+Folder_1 = model.addFolder(Part_1_doc, Face_1, Face_1)
+Folder_2 = model.addFolder(Part_1_doc, Edge_1, Edge_1)
+model.do()
+
+FeaturesToFind = FeatureList()
+FeaturesToFind.append(Sketch_1.feature())
+Part_1_doc.removeFolder(Part_1_doc.findFolderBelow(FeaturesToFind))
+model.do()
+
+Folder_3 = model.addFolder(Part_1_doc, Vertex_1, Vertex_1)
+model.do()
+model.end()
+
+assert(model.checkPythonDump())