From e9545c62b3002f0e9b91e0c32adbc5b1c11138e0 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Wed, 16 Sep 2020 22:41:11 +0300 Subject: [PATCH] Issue #19990: Error when loading geometrical dump Process special case of geometric selection related to ImportResult feature, due to its reference to results from another parts. --- src/Model/Model_AttributeSelection.cpp | 17 +++++- src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp | 4 +- src/ModelHighAPI/CMakeLists.txt | 3 +- .../Test/{Test19990.py => Test19990_1.py} | 0 src/ModelHighAPI/Test/Test19990_2.py | 61 +++++++++++++++++++ 5 files changed, 81 insertions(+), 4 deletions(-) rename src/ModelHighAPI/Test/{Test19990.py => Test19990_1.py} (100%) create mode 100644 src/ModelHighAPI/Test/Test19990_2.py diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index e0b1a84cc..bb1767a06 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -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 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 aPartSetFeatures = aFeatures; + aFeatures.clear(); + for (std::list::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((*it)->firstResult()); + std::list aPartFeatures = aPart->partDoc()->allFeatures(); + aFeatures.insert(aFeatures.end(), aPartFeatures.begin(), aPartFeatures.end()); + } + } + } + else if (aSession->moduleDocument() != owner()->document()) { std::list aPartFeatures = owner()->document()->allFeatures(); aFeatures.insert(aFeatures.end(), aPartFeatures.begin(), aPartFeatures.end()); } diff --git a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp index 8406c9b8c..70b39c0ad 100644 --- a/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp +++ b/src/ModelGeomAlgo/ModelGeomAlgo_Shape.cpp @@ -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& theSelected) { - static const double TOLERANCE = 1.e-6; + static const double TOLERANCE = 1.5e-6; theSelected.clear(); diff --git a/src/ModelHighAPI/CMakeLists.txt b/src/ModelHighAPI/CMakeLists.txt index f578998af..982450580 100644 --- a/src/ModelHighAPI/CMakeLists.txt +++ b/src/ModelHighAPI/CMakeLists.txt @@ -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_1.py similarity index 100% rename from src/ModelHighAPI/Test/Test19990.py rename to src/ModelHighAPI/Test/Test19990_1.py diff --git a/src/ModelHighAPI/Test/Test19990_2.py b/src/ModelHighAPI/Test/Test19990_2.py new file mode 100644 index 000000000..6de525124 --- /dev/null +++ b/src/ModelHighAPI/Test/Test19990_2.py @@ -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()) -- 2.39.2