Salome HOME
Issue #20456: Another dump study fails
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 21 Dec 2020 20:22:24 +0000 (23:22 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 21 Dec 2020 20:22:24 +0000 (23:22 +0300)
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'.

src/ModelAPI/ModelAPI_Tools.cpp
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
test.hdfs/Test20456.hdf [new file with mode: 0644]
test.hdfs/Test20456.py [new file with mode: 0644]
test.hdfs/testme.py

index 69a882af62a66593745301585c3a47b7b5006a77..8c03b9ab3007f957e04ad704c09954659464e79d 100644 (file)
@@ -706,7 +706,8 @@ std::pair<std::wstring, bool> getDefaultName(const std::shared_ptr<ModelAPI_Resu
 
       // return name of reference result only if it has been renamed by the user,
       // in other case compose a default name
-      if (anObjRes->data()->hasUserDefinedName()) {
+      if (anObjRes->data()->hasUserDefinedName() ||
+          anObjRes->data()->name() != getDefaultName(anObjRes).first) {
         std::wstringstream aName;
         aName << anObjRes->data()->name();
         std::map<ResultPtr, int>::iterator aFound = aNbRefToObject.find(anObjRes);
index 324b827d0357be534a31ffe7b9e144975296c157..cb2323165a7bb9ca24b33b025f69f80418ee284c 100644 (file)
@@ -1457,6 +1457,8 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     bool isAdded = false;
     std::list<ObjectPtr>::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 (file)
index 0000000..dd6b2f8
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 (file)
index 0000000..f9295e1
--- /dev/null
@@ -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))
index 57d798fb084c669ac8e700e053fe5fa8ec9d9135..96c1580c28d52d7d47c015fdcec4a8f36fa4c0ce 100644 (file)
@@ -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: