From: Artem Zhidkov Date: Mon, 21 Dec 2020 20:22:24 +0000 (+0300) Subject: Issue #20456: Another dump study fails X-Git-Tag: V9_7_0a1~63 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4272679d61b119cad2da8185296ab470adfb92d7;p=modules%2Fshaper.git Issue #20456: Another dump study fails Implement additional check for user-defined name of a feature. This provides correct dump of names of features, which results have named after the feature name, but their default name has to be composed from the name of the concealed result. For example, in this case 'Face_1' feature conceals 'Pipe_1_1' result, so, the default name of face's result is 'Pipe_1_1', however, is was manually renamed to 'Face_1_1'. --- diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 69a882af6..8c03b9ab3 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -706,7 +706,8 @@ std::pair getDefaultName(const std::shared_ptrdata()->hasUserDefinedName()) { + if (anObjRes->data()->hasUserDefinedName() || + anObjRes->data()->name() != getDefaultName(anObjRes).first) { std::wstringstream aName; aName << anObjRes->data()->name(); std::map::iterator aFound = aNbRefToObject.find(anObjRes); diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 324b827d0..cb2323165 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -1457,6 +1457,8 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( bool isAdded = false; std::list::const_iterator anIt = aList.begin(); for (; anIt != aList.end(); ++anIt) { + if (!(*anIt)) + continue; if (!isDumped(ModelAPI_Feature::feature(*anIt))) break; // stop if the object is not dumped yet (parent feature should be postponed) diff --git a/test.hdfs/Test20456.hdf b/test.hdfs/Test20456.hdf new file mode 100644 index 000000000..dd6b2f864 Binary files /dev/null and b/test.hdfs/Test20456.hdf differ diff --git a/test.hdfs/Test20456.py b/test.hdfs/Test20456.py new file mode 100644 index 000000000..f9295e154 --- /dev/null +++ b/test.hdfs/Test20456.py @@ -0,0 +1,30 @@ +# 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 +# + +if __name__ == "__main__": + aPartFeature = locals()["Part_1"] + model.testNbResults(aPartFeature, 1) + model.testNbSubResults(aPartFeature, [0]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [2]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [22]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [88]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [176]) + model.testResultsVolumes(aPartFeature, [55179.3113664]) + + assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING)) diff --git a/test.hdfs/testme.py b/test.hdfs/testme.py index 57d798fb0..96c1580c2 100644 --- a/test.hdfs/testme.py +++ b/test.hdfs/testme.py @@ -47,7 +47,7 @@ if __name__ == '__main__': isOk = True error = "" - proc = subprocess.Popen(["runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--splash", "0", "--ns-port-log=" + portlogfile, "test_hdf.py", "args:" + hdffile + "," + testdatafile + "," + portlogfile + "," + testlogfile], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + proc = subprocess.Popen(["runSalome.py", "--modules", "SHAPER,GEOM,SHAPERSTUDY", "--gui", "--splash", "0", "--ns-port-log=" + portlogfile, "test_hdf.py", "args:" + hdffile + "," + testdatafile + "," + portlogfile + "," + testlogfile], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) try: proc.communicate(timeout = testTimeout) except TimeoutExpired: