]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #2289: Naming of vertices incorrect after extrusion
authormpv <mpv@opencascade.com>
Tue, 21 Nov 2017 11:32:18 +0000 (14:32 +0300)
committermpv <mpv@opencascade.com>
Tue, 21 Nov 2017 11:32:18 +0000 (14:32 +0300)
src/Config/Config_ModuleReader.cpp
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/Test/Test2289.py [new file with mode: 0644]
src/PythonAPI/model/tests/tests.py

index 67b4ee990d1c4c77fa670541ba093130f80e18f1..452fc4ca3a9291602ec9c71f7b4488de442c1332 100644 (file)
@@ -104,7 +104,7 @@ void Config_ModuleReader::processNode(xmlNodePtr theNode)
     std::string aPluginScript = getProperty(theNode, PLUGIN_SCRIPT);
     std::string aPluginName = addPlugin(aPluginLibrary, aPluginScript, aPluginConf);
     std::string aUsesPlugin = getProperty(theNode, PLUGIN_USES);
-    if (!aUsesPlugin.empty()) { // send information about hte plugin dependencies
+    if (!aUsesPlugin.empty()) { // send information about the plugin dependencies
       std::shared_ptr<Config_PluginMessage> aMess(new Config_PluginMessage(
         Events_Loop::loop()->eventByName(Config_PluginMessage::EVENT_ID()), aPluginName));
       aMess->setUses(aUsesPlugin);
index 53b6ad50eb1e8e3c229e3e54efc54835d4695d69..9fc5d6d3f17e39aa4b34c6f6ea62bea7c047d002 100644 (file)
@@ -185,4 +185,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test2248.py
                Test2251.py
                Test2255.py
+               Test2289.py
 )
index adde95a0b22668d6cf0d1cf82976265096529ca3..a3018be53df4c5a9a3d8ed67cf708ad68f538408 100644 (file)
@@ -506,6 +506,11 @@ void FeaturesPlugin_CompositeSketch::storeShapes(ResultBodyPtr theResultBody,
       std::string aName = theName + aShapeTypeStr;
       storeSubShape(theResultBody, aShape, aShapeTypeToExplore,
                     theMapOfSubShapes, aName, aShapeIndex, theTag);
+      if (theBaseShapeType == GeomAPI_Shape::WIRE) { // issue 2289: special names also for vertices
+        aName = theName + "Vertex";
+        storeSubShape(theResultBody, aShape, GeomAPI_Shape::VERTEX,
+                      theMapOfSubShapes, aName, aShapeIndex, theTag);
+      }
     }
   }
 }
diff --git a/src/FeaturesPlugin/Test/Test2289.py b/src/FeaturesPlugin/Test/Test2289.py
new file mode 100644 (file)
index 0000000..7597676
--- /dev/null
@@ -0,0 +1,56 @@
+## 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>
+##
+
+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(55.30809111108014, 52.50335568234566, -47.4076783683968, 52.50335568234566)
+SketchLine_2 = Sketch_1.addLine(-47.4076783683968, 52.50335568234566, -77.7205049049542, 0)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(-77.7205049049542, 0, -47.4076783683968, -52.50335568234565)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchLine_4 = Sketch_1.addLine(-47.4076783683968, -52.50335568234565, 55.30809111108014, -52.50335568234565)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchLine_5 = Sketch_1.addLine(55.30809111108014, -52.50335568234565, 55.30809111108014, 52.50335568234566)
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result())
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_6 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.result(), SketchLine_3.startPoint())
+SketchConstraintAngle_1 = Sketch_1.setAngleBackward(SketchLine_2.result(), SketchLine_3.result(), 120)
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_3.result())
+SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_4.result())
+model.do()
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5")])
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 10, 0)
+model.do()
+
+model.testHaveNamingVertices(Extrusion_1, model, Part_1_doc)
+
+model.end()
+
+assert(model.checkPythonDump())
index ce6c3933288a6944447620e92cdccd649407128d..49fdcdd1306ebc165b4a42158f609de2001c8357 100644 (file)
@@ -166,7 +166,7 @@ def testHaveNamingFaces(theFeature, theModel, thePartDoc) :
     assert(name != ""), "String empty"
 
 def testHaveNamingEdges(theFeature, theModel, thePartDoc) :
-  """ Tests if all faces of result have a name
+  """ Tests if all edges of result have a name
   :param theFeature: feature to test.
   """
   # Get feature result/sub-result
@@ -198,6 +198,49 @@ def testHaveNamingEdges(theFeature, theModel, thePartDoc) :
     assert(shape.isEdge())
     assert(name != ""), "String empty"
 
+def testHaveNamingVertices(theFeature, theModel, thePartDoc) :
+  """ Tests if all vertices of result have a unique name
+  :param theFeature: feature to test.
+  """
+  # Get feature result/sub-result
+  aResult = theFeature.results()[0].resultSubShapePair()[0]
+  # Get result/sub-result shape
+  shape = aResult.shape()
+  # Create shape explorer with desired shape type
+  shapeExplorer = GeomAPI_ShapeExplorer(shape, GeomAPI_Shape.VERTEX)
+  # Create list, and store selections in it
+  selectionList = []
+  shapesList = [] # to append only unique shapes (not isSame)
+  while shapeExplorer.more():
+    aDuplicate = False
+    for alreadyThere in shapesList:
+      if alreadyThere.isSame(shapeExplorer.current()):
+        aDuplicate = True
+    if aDuplicate:
+      shapeExplorer.next()
+      continue
+    shapesList.append(shapeExplorer.current())
+    selection = theModel.selection(aResult, shapeExplorer.current()) # First argument should be result/sub-result, second is sub-shape on this result/sub-result
+    selectionList.append(selection)
+    shapeExplorer.next()
+  # Create group with this selection list
+  Group_1 = theModel.addGroup(thePartDoc, selectionList)
+  theModel.do()
+
+  # Check that all selected shapes in group have right shape type and unique name.
+  groupFeature = Group_1.feature()
+  groupSelectionList = groupFeature.selectionList("group_list")
+  assert(groupSelectionList.size() == len(selectionList))
+  presented_names = set()
+  for index in range(0, groupSelectionList.size()):
+    attrSelection = groupSelectionList.value(index)
+    shape = attrSelection.value()
+    name = attrSelection.namingName()
+    assert(shape.isVertex())
+    assert(name != ""), "String empty"
+    presented_names.add(name)
+  assert(len(presented_names) == groupSelectionList.size()), "Some names are not unique"
+
 
 def testNbSubFeatures(theComposite, theKindOfSub, theExpectedCount):
   """ Tests number of sub-features of the given type