]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #2401
authormpv <mpv@opencascade.com>
Tue, 16 Jan 2018 14:42:06 +0000 (17:42 +0300)
committermpv <mpv@opencascade.com>
Tue, 16 Jan 2018 14:42:26 +0000 (17:42 +0300)
src/Model/Model_ResultConstruction.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/Test2401.py [new file with mode: 0644]

index a5230dd33fac08b7429bf882be57fcb3d1662e6f..25116990809bb0440cca76236c6da66721d37312 100644 (file)
@@ -473,8 +473,9 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
   // iterate and store the result ids of sub-elements and sub-elements to sub-labels
   Handle(TDataStd_IntPackedMap) aRefs = TDataStd_IntPackedMap::Set(aLab);
   const int aSubNum = aComposite->numberOfSubs();
-  // subs are placed one by one  because of #2248): sketch curve may produce several edges
-  int aSubLabId = 1;
+  // subs are placed on unique labels because of #2248: sketch curve may produce several edges,
+  // but #2401 - on stable labels
+  NCollection_Map<int> aUsedIDMap; // already used lab tags for placement of shapes
 
   for(int a = 0; a < aSubNum; a++) {
     FeaturePtr aSub = aComposite->subFeature(a);
@@ -504,11 +505,12 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
                   Standard_Real aFirst, aLast;
                   Handle(Geom_Curve) aFaceCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
                   if (aFaceCurve == aCurve) {
+                    while(aUsedIDMap.Contains(anID))
+                      anID += 100000;
+                    aUsedIDMap.Add(anID);
                     TDF_Label aSubLab = aLab.FindChild(anID);
-                    TDF_Label aShapeSubLab = aLab.FindChild(aSubLabId++);
                     std::string aFullNameSub = fullName(aComposite, anEdge);
-                    saveSubName(aComposite,
-                      aShapeSubLab, isSelectionMode, anEdge, aMyDoc, aFullNameSub);
+                    saveSubName(aComposite, aSubLab, isSelectionMode, anEdge, aMyDoc, aFullNameSub);
 
                     int anOrient = Model_SelectionNaming::edgeOrientation(aSubShape, anEdge);
                     if (anOrient != 0) {
@@ -522,10 +524,12 @@ int Model_ResultConstruction::select(const std::shared_ptr<GeomAPI_Shape>& theSu
                 for(TopExp_Explorer anEdgeExp(aSubShape, TopAbs_VERTEX);
                       anEdgeExp.More(); anEdgeExp.Next()) {
                     TopoDS_Vertex aV = TopoDS::Vertex(anEdgeExp.Current());
-                    TDF_Label aShapeSubLab = aLab.FindChild(aSubLabId++);
+                    while(aUsedIDMap.Contains(anID))
+                      anID += 100000;
+                    aUsedIDMap.Add(anID);
+                    TDF_Label aSubLab = aLab.FindChild(anID);
                     std::string aFullNameSub = fullName(aComposite, aV);
-                    saveSubName(aComposite,
-                      aShapeSubLab, isSelectionMode, aV, aMyDoc, aFullNameSub);
+                    saveSubName(aComposite, aSubLab, isSelectionMode, aV, aMyDoc, aFullNameSub);
                 }
               }
             }
index 918c55999e128a935205f74d18d68690b58bb6f0..b9818c04c8e3bfa684716136b5f6183bec80d1dc 100644 (file)
@@ -199,4 +199,5 @@ ADD_UNIT_TESTS(TestConstants.py
                Test2358_1.py
                Test2358_2.py
                Test2396.py
+               Test2401.py
 )
diff --git a/src/ModelAPI/Test/Test2401.py b/src/ModelAPI/Test/Test2401.py
new file mode 100644 (file)
index 0000000..e65e74c
--- /dev/null
@@ -0,0 +1,85 @@
+## 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(0, 0, 0, 3)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_2 = SketchProjection_2.createdFeature()
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
+SketchLine_3 = Sketch_1.addLine(0, 3, 4, 7)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
+SketchLine_4 = Sketch_1.addLine(4, 7, 8, 3)
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchLine_5 = Sketch_1.addLine(8, 3, 8, 0)
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_6 = SketchProjection_3.createdFeature()
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
+SketchLine_7 = Sketch_1.addLine(8, 0, 0, 0)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_7.endPoint())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_3.result())
+SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_3.result(), SketchLine_4.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result())
+SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 3)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_7.result(), 8)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_7r")], model.selection(), 5, 0)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), 5, True)
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
+SketchLine_8 = Sketch_2.addLine(7.560741003605092, 9.43062705614625, -1.095841663628257, 9.43062705614625)
+SketchLine_9 = Sketch_2.addLine(-1.095841663628257, 9.43062705614625, -1.095841663628257, -5.449377136847041)
+SketchLine_10 = Sketch_2.addLine(-1.095841663628257, -5.449377136847041, 7.560741003605092, -5.449377136847041)
+SketchLine_11 = Sketch_2.addLine(7.560741003605092, -5.449377136847041, 7.560741003605092, 9.43062705614625)
+SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
+SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_8.result())
+SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_9.result())
+SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_10.result())
+SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_11.result())
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchLine_11f")])
+Boolean_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("FACE", "Face_1_1")])
+model.do()
+
+# now add an additional edge to the first sketch as it is described in the issue
+SketchLine_8 = Sketch_1.addLine(0, 3, 8, 3)
+SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_8.endPoint())
+model.do()
+Part_1_doc.setCurrentFeature(Boolean_1.feature())
+model.end()
+
+# check that the plane is located as previously
+model.testNbSubResults(Boolean_1, [2])
+model.testResultsVolumes(Boolean_1, [120])
+assert(model.checkPythonDump())