]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue 2592: result after dump study / load script is different from initial
authormpv <mpv@opencascade.com>
Wed, 22 Aug 2018 12:42:01 +0000 (15:42 +0300)
committermpv <mpv@opencascade.com>
Wed, 22 Aug 2018 12:42:17 +0000 (15:42 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
src/FeaturesPlugin/FeaturesPlugin_Symmetry.h
src/FeaturesPlugin/Test/Test2592.py [new file with mode: 0644]
src/XGUI/XGUI_Workshop.cpp

index 98de6538387d275ca85e16cb850ec1bdcf43dcf5..db68e4533fe601b9aa9e4567733b8f986a192aec 100644 (file)
@@ -324,4 +324,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestBooleanCommon_CompSolidCompound_Shell.py
                TestBooleanCommon_CompSolidCompound_CompSolidCompound.py
                Test2596.py
+               Test2592.py
 )
index d3d058ed3a9f35e61b8ead2df25535d601968ed6..16e184688f85c6d12b2a7ed0a455ef7747f7126a 100644 (file)
@@ -23,6 +23,8 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomAlgoAPI_Copy.h>
+#include <GeomAlgoAPI_MakeShapeList.h>
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Face.h>
@@ -147,27 +149,28 @@ void FeaturesPlugin_Symmetry::performSymmetryByPoint()
       buildResult(anOrigin, aTrsf, aResultIndex);
     }
     else {
-      GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, aPoint);
+      std::shared_ptr<GeomAlgoAPI_Symmetry> aSymmetryAlgo(
+        new GeomAlgoAPI_Symmetry(aBaseShape, aPoint));
 
-      if (!aSymmetryAlgo.check()) {
-        setError(aSymmetryAlgo.getError());
+      if (!aSymmetryAlgo->check()) {
+        setError(aSymmetryAlgo->getError());
         return;
       }
 
-      aSymmetryAlgo.build();
+      aSymmetryAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aSymmetryAlgo.isDone()) {
+      if(!aSymmetryAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aSymmetryAlgo.shape()->isNull()) {
+      if(aSymmetryAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aSymmetryAlgo.isValid()) {
+      if(!aSymmetryAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
@@ -223,27 +226,28 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis()
       buildResult(anOrigin, aTrsf, aResultIndex);
     }
     else {
-      GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, anAxis);
+      std::shared_ptr<GeomAlgoAPI_Symmetry> aSymmetryAlgo(
+        new GeomAlgoAPI_Symmetry(aBaseShape, anAxis));
 
-      if (!aSymmetryAlgo.check()) {
-        setError(aSymmetryAlgo.getError());
+      if (!aSymmetryAlgo->check()) {
+        setError(aSymmetryAlgo->getError());
         return;
       }
 
-      aSymmetryAlgo.build();
+      aSymmetryAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aSymmetryAlgo.isDone()) {
+      if(!aSymmetryAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aSymmetryAlgo.shape()->isNull()) {
+      if(aSymmetryAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aSymmetryAlgo.isValid()) {
+      if(!aSymmetryAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
@@ -300,27 +304,28 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane()
       ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
       buildResult(anOrigin, aTrsf, aResultIndex);
     } else {
-      GeomAlgoAPI_Symmetry aSymmetryAlgo(aBaseShape, aPlane);
+      std::shared_ptr<GeomAlgoAPI_Symmetry> aSymmetryAlgo(
+        new GeomAlgoAPI_Symmetry(aBaseShape, aPlane));
 
-      if (!aSymmetryAlgo.check()) {
-        setError(aSymmetryAlgo.getError());
+      if (!aSymmetryAlgo->check()) {
+        setError(aSymmetryAlgo->getError());
         return;
       }
 
-      aSymmetryAlgo.build();
+      aSymmetryAlgo->build();
 
       // Checking that the algorithm worked properly.
-      if(!aSymmetryAlgo.isDone()) {
+      if(!aSymmetryAlgo->isDone()) {
         static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aSymmetryAlgo.shape()->isNull()) {
+      if(aSymmetryAlgo->shape()->isNull()) {
         static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aSymmetryAlgo.isValid()) {
+      if(!aSymmetryAlgo->isValid()) {
         std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
@@ -336,24 +341,30 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane()
 }
 
 //=================================================================================================
-void FeaturesPlugin_Symmetry::buildResult(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
-                                          std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                          int theResultIndex)
+void FeaturesPlugin_Symmetry::buildResult(
+  std::shared_ptr<GeomAlgoAPI_Symmetry>& theSymmetryAlgo,
+  std::shared_ptr<GeomAPI_Shape> theBaseShape, int theResultIndex)
 {
+  GeomAlgoAPI_MakeShapeList anAlgoList;
+  anAlgoList.appendAlgo(theSymmetryAlgo);
   // Compose source shape and the result of symmetry.
   GeomShapePtr aCompound;
   if (boolean(KEEP_ORIGINAL_RESULT())->value()) {
     ListOfShape aShapes;
-    aShapes.push_back(theBaseShape);
-    aShapes.push_back(theSymmetryAlgo.shape());
+    // add a copy of a base shape otherwise selection of this base shape is bad (2592)
+    std::shared_ptr<GeomAlgoAPI_Copy> aCopyAlgo(new GeomAlgoAPI_Copy(theBaseShape));
+    aShapes.push_back(aCopyAlgo->shape());
+    anAlgoList.appendAlgo(aCopyAlgo);
+
+    aShapes.push_back(theSymmetryAlgo->shape());
     aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
   } else
-    aCompound = theSymmetryAlgo.shape();
+    aCompound = theSymmetryAlgo->shape();
 
   // Store and name the result.
   ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
   aResultBody->storeModified(theBaseShape, aCompound);
-  loadNamingDS(theSymmetryAlgo, aResultBody, theBaseShape);
+  loadNamingDS(anAlgoList, aResultBody, theBaseShape);
   setResult(aResultBody, theResultIndex);
 }
 
@@ -376,14 +387,14 @@ void FeaturesPlugin_Symmetry::buildResult(ResultPartPtr theOriginal,
 }
 
 //=================================================================================================
-void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
+void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_MakeShapeList& theAlgo,
                                            std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                                            std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
   // Name the faces
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theSymmetryAlgo.mapOfSubShapes();
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theAlgo.mapOfSubShapes();
   std::string aReflectedName = "Symmetried";
-  FeaturesPlugin_Tools::storeModifiedShapes(theSymmetryAlgo, theResultBody,
+  FeaturesPlugin_Tools::storeModifiedShapes(theAlgo, theResultBody,
                                             theBaseShape, 1, 2, 3, aReflectedName,
                                             *aSubShapes.get());
 }
index f0b296b4663b5d386cab49156780b5b3347a12fb..a19d143cfa73448e098563a67d761957e3560310 100644 (file)
@@ -26,6 +26,7 @@
 #include <ModelAPI_Feature.h>
 
 #include <GeomAlgoAPI_Symmetry.h>
+#include <GeomAlgoAPI_MakeShapeList.h>
 
 class GeomAPI_Trsf;
 
@@ -137,12 +138,12 @@ private:
   void performSymmetryByPlane();
 
   /// Perform the naming
-  void loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
+  void loadNamingDS(GeomAlgoAPI_MakeShapeList& theSymmetryAlgo,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
 
   /// Create new result on given shapes and the index of result
-  void buildResult(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
+  void buildResult(std::shared_ptr<GeomAlgoAPI_Symmetry>& theSymmetryAlgo,
                    std::shared_ptr<GeomAPI_Shape> theBaseShape,
                    int theResultIndex);
 
diff --git a/src/FeaturesPlugin/Test/Test2592.py b/src/FeaturesPlugin/Test/Test2592.py
new file mode 100644 (file)
index 0000000..d102679
--- /dev/null
@@ -0,0 +1,33 @@
+## 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()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom"), True)
+Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Symmetry_1_1_1")], model.selection("EDGE", "PartSet/OX"), True)
+model.end()
+
+# check python dump failed before the bug fix: selection in symmetry 2 changed to the whole symmetry 1 compound
+assert(model.checkPythonDump())
index 7145cfb61a44281107c161a59ab05a64f41b381e..0df4bea8dd826cefabd7bf35be876babd2cb3dbe 100755 (executable)
@@ -1623,7 +1623,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 #ifdef DEBUG_WITH_MESSAGE_REPORT
         MyTCommunicator->RegisterPlugin("TKMessageView");
 #endif
-        MyTCommunicator->RegisterPlugin("SMBrowser"); // custom plugin to view ModelAPI
+        //MyTCommunicator->RegisterPlugin("SMBrowser"); // custom plugin to view ModelAPI
         //MyTCommunicator->RegisterPlugin("TKSMBrowser"); // custom plugin to view ModelAPI
 
         MyTCommunicator->Init(aParameters);