Salome HOME
Fix for the issue #2233
authormpv <mpv@opencascade.com>
Wed, 26 Jul 2017 11:51:54 +0000 (14:51 +0300)
committermpv <mpv@opencascade.com>
Wed, 26 Jul 2017 11:51:54 +0000 (14:51 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/Test/Test2233.py [new file with mode: 0644]

index 4434a3cdc0bf892ab10d1f4adf268abe55e30264..4d4c5215a1a5340f8edc0aefb09b56a3e8b068e0 100644 (file)
@@ -175,4 +175,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test2197_4.py
                Test2215.py
                Test2222.py
+               Test2233.py
 )
index fa777220521b29f16a7a4d3d9d66f7cc2a1ace52..adde95a0b22668d6cf0d1cf82976265096529ca3 100644 (file)
@@ -387,6 +387,20 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes
             anEdgesFromVertices.bind(anEdgesExp.current(), anEdgesExp.current());
           }
         }
+      } else if (aFacesFromFromEdges.size() == 1) { // 2233: sphere created by the revolution:
+        // vertices at degenerated edges will have the same name
+        GeomAPI_DataMapOfShapeShape aVertices;
+        GeomAPI_ShapeExplorer aVertExp(theMakeShape->shape(), GeomAPI_Shape::VERTEX);
+        for(int anIndex = 1; aVertExp.more(); aVertExp.next()) {
+          if (!aVertices.isBound(aVertExp.current())) {
+            // found a base edge
+            std::ostringstream aStream;
+            aStream<<"Vertex_"<<anIndex++;
+            theResultBody->generated(aVertExp.current(), aStream.str(), theTag++);
+            // only one orientation is needed
+            aVertices.bind(aVertExp.current(), aVertExp.current());
+          }
+        }
       }
     } else { // issue #2197, test case 4 : edges that produce fully-revolved face,
       // but contain only 2 edges (on apex of revolution)
diff --git a/src/FeaturesPlugin/Test/Test2233.py b/src/FeaturesPlugin/Test/Test2233.py
new file mode 100644 (file)
index 0000000..5c6d5f2
--- /dev/null
@@ -0,0 +1,54 @@
+## Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+##
+
+# check that revolution that produces a sphere has correctly named 2 vertices with different names
+
+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("YOZ"))
+SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
+SketchLine_1 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OZ"))
+SketchArc_1 = Sketch_1.addArc(0, 0, 0, 50, 0, -50, True)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_1.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 50, 0, -50)
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.endPoint())
+model.do()
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), 360, 0)
+Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Revolution_1_1/Vertex_1"), model.selection("VERTEX", "Revolution_1_1/Vertex_2")])
+model.end()
+
+# check that resulting group selection is valid and names are different
+from ModelAPI import *
+aFactory = ModelAPI_Session.get().validators()
+assert(aFactory.validate(Group_1.feature()))
+assert(Group_1.groupList().size() == 2)
+assert(Group_1.groupList().value(0).value().shapeTypeStr() == "VERTEX")
+assert(len(Group_1.groupList().value(0).namingName()) > 0)
+assert(Group_1.groupList().value(1).value().shapeTypeStr() == "VERTEX")
+assert(Group_1.groupList().value(0).namingName() != Group_1.groupList().value(1).namingName())
+
+assert(model.checkPythonDump())