Salome HOME
Issue #1866: Naming incorrect on edges after translation
authordbv <dbv@opencascade.com>
Thu, 17 Nov 2016 08:22:50 +0000 (11:22 +0300)
committerdbv <dbv@opencascade.com>
Thu, 17 Nov 2016 08:23:26 +0000 (11:23 +0300)
Fixed naming for edges after translation, rotation and placement.

src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Tools.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Tools.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp

index 34a303c083e3104bdc1070899506c509935c1ed8..8afae28a6758f8abcd9fa410f28fe2e176baef2d 100644 (file)
@@ -28,6 +28,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_ValidatorTransform.h
     FeaturesPlugin_Validators.h
     FeaturesPlugin_RemoveSubShapes.h
+    FeaturesPlugin_Tools.h
 )
 
 SET(PROJECT_SOURCES
@@ -54,6 +55,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_ValidatorTransform.cpp
     FeaturesPlugin_Validators.cpp
     FeaturesPlugin_RemoveSubShapes.cpp
+    FeaturesPlugin_Tools.cpp
 )
 
 SET(XML_RESOURCES
index 5702921e29a3cffdd4b2d54003d9b4bd763e14e6..c3351408566f81b7fd5b9c4d79acbf1db8854656 100644 (file)
@@ -20,6 +20,8 @@
 #include <GeomAlgoAPI_Placement.h>
 #include <GeomAlgoAPI_Transform.h>
 
+#include <FeaturesPlugin_Tools.h>
+
 FeaturesPlugin_Placement::FeaturesPlugin_Placement()
 {
 }
@@ -191,28 +193,9 @@ void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformA
   //load result
   theResultBody->storeModified(theBaseShape, theTransformAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTransformAlgo.mapOfSubShapes();
-
-    // put modifed faces in DF
   int aPlacedTag = 1;
   std::string aPlacedName = "Placed";
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTransformAlgo.mapOfSubShapes();
 
-  switch(theBaseShape->shapeType()) {
-    case GeomAPI_Shape::COMPOUND:
-    case GeomAPI_Shape::COMPSOLID:
-    case GeomAPI_Shape::SOLID:
-    case GeomAPI_Shape::SHELL:
-      theResultBody->loadAndOrientModifiedShapes(&theTransformAlgo,
-                                                theBaseShape, GeomAPI_Shape::FACE,
-                                        aPlacedTag, aPlacedName + "_Face", *aSubShapes.get());
-    case GeomAPI_Shape::FACE:
-    case GeomAPI_Shape::WIRE:
-      theResultBody->loadAndOrientModifiedShapes(&theTransformAlgo,
-                                                 theBaseShape, GeomAPI_Shape::EDGE,
-                                        ++aPlacedTag, aPlacedName + "_Edge", *aSubShapes.get());
-    case GeomAPI_Shape::EDGE:
-      theResultBody->loadAndOrientModifiedShapes(&theTransformAlgo,
-                                                 theBaseShape, GeomAPI_Shape::VERTEX,
-                                        ++aPlacedTag, aPlacedName + "_Vertex", *aSubShapes.get());
-  }
+  FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody, theBaseShape, aPlacedTag, aPlacedName, *aSubShapes.get());
 }
index 1e0dd3c29a45ad8c5e1fd5deb3f20725b5a753ab..ac2c10ca0e03316d29b9af2259e80bcaeb973899 100755 (executable)
@@ -14,6 +14,8 @@
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
 
+#include <FeaturesPlugin_Tools.h>
+
 //=================================================================================================
 FeaturesPlugin_Rotation::FeaturesPlugin_Rotation()
 {
@@ -126,27 +128,9 @@ void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
   // Store result.
   theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfSubShapes();
-
   int aRotatedTag = 1;
   std::string aRotatedName = "Rotated";
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfSubShapes();
 
-  switch(theBaseShape->shapeType()) {
-    case GeomAPI_Shape::COMPOUND:
-    case GeomAPI_Shape::COMPSOLID:
-    case GeomAPI_Shape::SOLID:
-    case GeomAPI_Shape::SHELL:
-      theResultBody->loadAndOrientModifiedShapes(&theRotaionAlgo,
-                                    theBaseShape, GeomAPI_Shape::FACE,
-                                    aRotatedTag, aRotatedName + "_Face", *aSubShapes.get());
-    case GeomAPI_Shape::FACE:
-    case GeomAPI_Shape::WIRE:
-      theResultBody->loadAndOrientModifiedShapes(&theRotaionAlgo,
-                                  theBaseShape, GeomAPI_Shape::EDGE,
-                                  ++aRotatedTag, aRotatedName + "_Edge", *aSubShapes.get());
-    case GeomAPI_Shape::EDGE:
-      theResultBody->loadAndOrientModifiedShapes(&theRotaionAlgo,
-                                theBaseShape, GeomAPI_Shape::VERTEX,
-                                ++aRotatedTag, aRotatedName + "_Vertex", *aSubShapes.get());
-  }
+  FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody, theBaseShape, aRotatedTag, aRotatedName, *aSubShapes.get());
 }
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp
new file mode 100644 (file)
index 0000000..22431b9
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        FeaturesPlugin_Tools.cpp
+// Created:     17 November 2016
+// Author:      Dmitry Bobylev
+
+#include "FeaturesPlugin_Tools.h"
+
+#include <ModelAPI_ResultBody.h>
+
+#include <GeomAPI_ShapeIterator.h>
+
+void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo,
+                                               std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                               std::shared_ptr<GeomAPI_Shape> theBaseShape,
+                                               int& theTag,
+                                               const std::string theName,
+                                               GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+  switch(theBaseShape->shapeType()) {
+    case GeomAPI_Shape::COMPOUND: {
+      for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next())
+      {
+        storeModifiedShapes(theAlgo, theResultBody, theBaseShape, theTag, theName, theSubShapes);
+        theTag++;
+      }
+      break;
+    }
+    case GeomAPI_Shape::COMPSOLID:
+    case GeomAPI_Shape::SOLID:
+    case GeomAPI_Shape::SHELL: {
+      theResultBody->loadAndOrientModifiedShapes(&theAlgo,
+                                theBaseShape, GeomAPI_Shape::FACE,
+                                theTag, theName + "_Face", theSubShapes);
+      if (theBaseShape->shapeType() == GeomAPI_Shape::COMPSOLID
+          || theBaseShape->shapeType() == GeomAPI_Shape::SOLID) {
+        break;
+      }
+    }
+    case GeomAPI_Shape::FACE:
+    case GeomAPI_Shape::WIRE:
+      theResultBody->loadAndOrientModifiedShapes(&theAlgo,
+                                theBaseShape, GeomAPI_Shape::EDGE,
+                                ++theTag, theName + "_Edge", theSubShapes);
+    case GeomAPI_Shape::EDGE:
+      theResultBody->loadAndOrientModifiedShapes(&theAlgo,
+                              theBaseShape, GeomAPI_Shape::VERTEX,
+                              ++theTag, theName + "_Vertex", theSubShapes);
+  }
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.h b/src/FeaturesPlugin/FeaturesPlugin_Tools.h
new file mode 100644 (file)
index 0000000..c6cd120
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        FeaturesPlugin_Tools.h
+// Created:     17 November 2016
+// Author:      Dmitry Bobylev
+
+#ifndef FeaturesPlugin_Tools_H_
+#define FeaturesPlugin_Tools_H_
+
+#include <GeomAlgoAPI_Translation.h>
+
+class ModelAPI_ResultBody;
+
+class FeaturesPlugin_Tools {
+public:
+  static void storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo,
+                                  std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                  std::shared_ptr<GeomAPI_Shape> theBaseShape,
+                                  int& theTag,
+                                  const std::string theName,
+                                  GeomAPI_DataMapOfShapeShape& theSubShapes);
+};
+
+#endif /* FeaturesPlugin_Tools_H_ */
index 30b64de120ebc2d58e21e4379bc98f1f9830dafa..dea6df9f4f237835a150bbdba88e6a3719b51d44 100644 (file)
@@ -16,6 +16,8 @@
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
 
+#include <FeaturesPlugin_Tools.h>
+
 //=================================================================================================
 FeaturesPlugin_Translation::FeaturesPlugin_Translation()
 {
@@ -130,27 +132,9 @@ void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTransl
   // Store result.
   theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
-
   int aTranslatedTag = 1;
   std::string aTranslatedName = "Translated";
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
 
-  switch(theBaseShape->shapeType()) {
-    case GeomAPI_Shape::COMPOUND:
-    case GeomAPI_Shape::COMPSOLID:
-    case GeomAPI_Shape::SOLID:
-    case GeomAPI_Shape::SHELL:
-      theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo,
-                                theBaseShape, GeomAPI_Shape::FACE,
-                                aTranslatedTag, aTranslatedName + "_Face", *aSubShapes.get());
-    case GeomAPI_Shape::FACE:
-    case GeomAPI_Shape::WIRE:
-      theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo,
-                                theBaseShape, GeomAPI_Shape::EDGE,
-                                ++aTranslatedTag, aTranslatedName + "_Edge", *aSubShapes.get());
-    case GeomAPI_Shape::EDGE:
-      theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo,
-                              theBaseShape, GeomAPI_Shape::VERTEX,
-                              ++aTranslatedTag, aTranslatedName + "_Vertex", *aSubShapes.get());
-  }
+  FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody, theBaseShape, aTranslatedTag, aTranslatedName, *aSubShapes.get());
 }