]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #19990: Error when loading geometrical dump
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Wed, 16 Sep 2020 19:41:11 +0000 (22:41 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Wed, 16 Sep 2020 19:41:11 +0000 (22:41 +0300)
Process special case of geometric selection related to ImportResult feature, due to its reference to results from another parts.

src/Model/Model_AttributeSelection.cpp
src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp
src/ModelHighAPI/CMakeLists.txt
src/ModelHighAPI/Test/Test19990.py [deleted file]
src/ModelHighAPI/Test/Test19990_1.py [new file with mode: 0644]
src/ModelHighAPI/Test/Test19990_2.py [new file with mode: 0644]

index e0b1a84ccf8d9128bd6e112f5ff3d7e9b00a6279..bb1767a06a9bc5a0cd663a15d4b51b0354f45bfa 100644 (file)
@@ -1055,7 +1055,22 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType,
   // collect features from PartSet and the current part
   SessionPtr aSession = ModelAPI_Session::get();
   std::list<FeaturePtr> aFeatures = aSession->moduleDocument()->allFeatures();
-  if (aSession->moduleDocument() != owner()->document()) {
+  if (anOwner->getKind() == "ImportResult") {
+    // special case: feature "ImportResult" refers to the results from another parts,
+    // thus, it is necessary to go through the features of these parts too.
+    std::list<FeaturePtr> aPartSetFeatures = aFeatures;
+    aFeatures.clear();
+    for (std::list<FeaturePtr>::iterator it = aPartSetFeatures.begin();
+         it != aPartSetFeatures.end(); ++it) {
+      aFeatures.push_back(*it);
+      if ((*it)->firstResult()->groupName() == ModelAPI_ResultPart::group()) {
+        ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>((*it)->firstResult());
+        std::list<FeaturePtr> aPartFeatures = aPart->partDoc()->allFeatures();
+        aFeatures.insert(aFeatures.end(), aPartFeatures.begin(), aPartFeatures.end());
+      }
+    }
+  }
+  else if (aSession->moduleDocument() != owner()->document()) {
     std::list<FeaturePtr> aPartFeatures = owner()->document()->allFeatures();
     aFeatures.insert(aFeatures.end(), aPartFeatures.begin(), aPartFeatures.end());
   }
index 8406c9b8cb72ba4d26ce3f8f8e28302f4b2034c0..70b39c0adedb8539b7c6d593ae605583647f9b83 100644 (file)
@@ -87,7 +87,7 @@ namespace ModelGeomAlgo_Shape
       bool isFound = aDistance < theTolerance;
       // issue #19019: special workaround for faces, because if the face contains B-spline contour,
       // the middle point is calculated with respect to its poles, but not a curve itself.
-      // Thus is some operations (like BOP) the curve may have different number of poles
+      // Thus, in some operations (like BOP) the curve may have different number of poles
       // from time to time, as a result, the face parametric boundaries are floating
       // as well as the middle point.
       // The workaround is to find a distance from the picking point to the face, if the distance
@@ -216,7 +216,7 @@ namespace ModelGeomAlgo_Shape
                            const GeomAPI_Shape::ShapeType& theShapeType,
                            std::list<SubshapeOfResult>& theSelected)
   {
-    static const double TOLERANCE = 1.e-6;
+    static const double TOLERANCE = 1.5e-6;
 
     theSelected.clear();
 
index f578998af2990159306f1b72a2da1d4736958edc..9824505804f5b5b877c16ccb51fc97d9bbedd125 100644 (file)
@@ -126,5 +126,6 @@ ADD_UNIT_TESTS(
   Test2488.py
   Test18451.py
   Test19031.py
-  Test19990.py
+  Test19990_1.py
+  Test19990_2.py
 )
diff --git a/src/ModelHighAPI/Test/Test19990.py b/src/ModelHighAPI/Test/Test19990.py
deleted file mode 100644 (file)
index 20bdfef..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright (C) 2020  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
-#
-
-from salome.shaper import model
-
-model.begin()
-partSet = model.moduleDocument()
-
-### Create Part
-Part_1 = model.addPart(partSet)
-Part_1_doc = Part_1.document()
-
-### Create Sketch
-Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
-
-### Create SketchArc
-SketchArc_1 = Sketch_1.addArc(56.24665913968287, -62.02452773486242, 35.57563613077872, -17.19150878248001, 88.70981046865168, -24.82997724138561, False)
-
-### Create SketchLine
-SketchLine_1 = Sketch_1.addLine(88.70981046865168, -24.82997724138561, 35.57563613077872, -17.19150878248001)
-Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint())
-Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
-model.do()
-
-### Create Extrusion
-Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", (56.24665913968287, -64.29248088508524, 0))], model.selection(), 50, 0)
-
-### Create Sketch
-Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", (56.24665913968287, -64.29248088508524, 50)))
-
-### Create SketchProjection
-SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", (56.24665913968287, -62.02452773486242, 50)), False)
-SketchPoint_1 = SketchProjection_1.createdFeature()
-
-### Create SketchArc
-SketchArc_2 = Sketch_2.addArc(56.24665913968287, -62.02452773486242, 45.34418302532956, -36.70999577489869, 82.89389484228845, -54.98078276603709, False)
-Sketch_2.setCoincident(SketchPoint_1.result(), SketchArc_2.center())
-
-### Create SketchLine
-SketchLine_2 = Sketch_2.addLine(82.89389484228843, -54.98078276603709, 45.34418302532956, -36.70999577489869)
-Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_2.startPoint())
-Sketch_2.setCoincident(SketchArc_2.startPoint(), SketchLine_2.endPoint())
-model.do()
-
-### Create ExtrusionCut
-ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", (64.11903893380899, -45.84538927046789, 50))], model.selection(), 0, 10, [model.selection("SOLID", (55.99758335516852, -63.75630399502394, 25))])
-
-model.end()
-
-from GeomAPI import *
-
-model.testNbResults(ExtrusionCut_1, 1)
-model.testNbSubResults(ExtrusionCut_1, [0])
-model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1])
-model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [7])
-model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [24])
-model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [48])
-model.testResultsVolumes(ExtrusionCut_1, [347314.47596])
-
-assert(model.checkPythonDump())
diff --git a/src/ModelHighAPI/Test/Test19990_1.py b/src/ModelHighAPI/Test/Test19990_1.py
new file mode 100644 (file)
index 0000000..20bdfef
--- /dev/null
@@ -0,0 +1,76 @@
+# Copyright (C) 2020  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
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchArc
+SketchArc_1 = Sketch_1.addArc(56.24665913968287, -62.02452773486242, 35.57563613077872, -17.19150878248001, 88.70981046865168, -24.82997724138561, False)
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(88.70981046865168, -24.82997724138561, 35.57563613077872, -17.19150878248001)
+Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint())
+Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
+model.do()
+
+### Create Extrusion
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", (56.24665913968287, -64.29248088508524, 0))], model.selection(), 50, 0)
+
+### Create Sketch
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", (56.24665913968287, -64.29248088508524, 50)))
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", (56.24665913968287, -62.02452773486242, 50)), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+
+### Create SketchArc
+SketchArc_2 = Sketch_2.addArc(56.24665913968287, -62.02452773486242, 45.34418302532956, -36.70999577489869, 82.89389484228845, -54.98078276603709, False)
+Sketch_2.setCoincident(SketchPoint_1.result(), SketchArc_2.center())
+
+### Create SketchLine
+SketchLine_2 = Sketch_2.addLine(82.89389484228843, -54.98078276603709, 45.34418302532956, -36.70999577489869)
+Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_2.startPoint())
+Sketch_2.setCoincident(SketchArc_2.startPoint(), SketchLine_2.endPoint())
+model.do()
+
+### Create ExtrusionCut
+ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", (64.11903893380899, -45.84538927046789, 50))], model.selection(), 0, 10, [model.selection("SOLID", (55.99758335516852, -63.75630399502394, 25))])
+
+model.end()
+
+from GeomAPI import *
+
+model.testNbResults(ExtrusionCut_1, 1)
+model.testNbSubResults(ExtrusionCut_1, [0])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [7])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(ExtrusionCut_1, [347314.47596])
+
+assert(model.checkPythonDump())
diff --git a/src/ModelHighAPI/Test/Test19990_2.py b/src/ModelHighAPI/Test/Test19990_2.py
new file mode 100644 (file)
index 0000000..6de5251
--- /dev/null
@@ -0,0 +1,61 @@
+# Copyright (C) 2020  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
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Box
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+
+model.do()
+
+### Create Part
+Part_2 = model.addPart(partSet)
+Part_2_doc = Part_2.document()
+
+### Create ImportResult
+ImportResult_1 = model.addImportResult(Part_2_doc, [model.selection("SOLID", (5.000000000000001, 5.000000000000001, 5))])
+
+model.end()
+
+from GeomAPI import *
+
+model.testNbResults(Part_1, 1)
+model.testNbSubResults(Part_1, [0])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Part_1, [1000])
+
+model.testNbResults(Part_2, 1)
+model.testNbSubResults(Part_2, [0])
+model.testNbSubShapes(Part_2, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Part_2, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Part_2, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Part_2, GeomAPI_Shape.VERTEX, [48])
+model.testResultsVolumes(Part_2, [1000])
+
+assert(model.checkPythonDump())