Salome HOME
Adjust test cases reference data according to precise calculation of bounding boxes.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Symmetry.h
index 988f58339d3eb23920e76954c00ace4f8756bac6..b0756ec56db352af0f19b38b0620c5fa27228eb1 100644 (file)
@@ -1,8 +1,21 @@
-// Copyright (C) 2014-2016 CEA/DEN, EDF R&D
-
-// File:        FeaturesPlugin_Symmetry.h
-// Created:     30 Nov 2016
-// Author:      Clarisse Genrault (CEA)
+// Copyright (C) 2014-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
+//
 
 #ifndef FEATURESPLUGIN_SYMMETRY_H_
 #define FEATURESPLUGIN_SYMMETRY_H_
@@ -11,7 +24,8 @@
 
 #include <ModelAPI_Feature.h>
 
-#include <GeomAlgoAPI_Symmetry.h>
+class GeomAPI_Trsf;
+class GeomAlgoAPI_MakeShapeList;
 
 /** \class FeaturesPlugin_Symmetry
  *  \ingroup Plugins
@@ -23,8 +37,8 @@ class FeaturesPlugin_Symmetry : public ModelAPI_Feature
   /// Symmetry kind.
   inline static const std::string& ID()
   {
-    static const std::string MY_SYMMETRY("Symmetry");
-    return MY_SYMMETRY;
+    static const std::string MY_SYMMETRY_ID("Symmetry");
+    return MY_SYMMETRY_ID;
   }
 
   /// Attribute name for creation method.
@@ -34,21 +48,21 @@ class FeaturesPlugin_Symmetry : public ModelAPI_Feature
     return MY_CREATION_METHOD_ID;
   }
 
-  /// Attribute name for creation method "ByAxisAndDistance".
+  /// Attribute name for creation method "ByPoint".
   inline static const std::string& CREATION_METHOD_BY_POINT()
   {
     static const std::string MY_CREATION_METHOD_ID("ByPoint");
     return MY_CREATION_METHOD_ID;
   }
 
-  /// Attribute name for creation method "ByDimensions".
+  /// Attribute name for creation method "ByAxis".
   inline static const std::string& CREATION_METHOD_BY_AXIS()
   {
     static const std::string MY_CREATION_METHOD_ID("ByAxis");
     return MY_CREATION_METHOD_ID;
   }
 
-  /// Attribute name for creation method "ByTwoPoints".
+  /// Attribute name for creation method "ByPlane".
   inline static const std::string& CREATION_METHOD_BY_PLANE()
   {
     static const std::string MY_CREATION_METHOD_ID("ByPlane");
@@ -83,6 +97,13 @@ class FeaturesPlugin_Symmetry : public ModelAPI_Feature
     return MY_PLANE_OBJECT_ID;
   }
 
+  /// Attribute name of keeping original shape.
+  inline static const std::string& KEEP_ORIGINAL_RESULT()
+  {
+    static const std::string MY_KEEP_ORIGINAL_RESULT_ID("keep_original");
+    return MY_KEEP_ORIGINAL_RESULT_ID;
+  }
+
   /// \return the kind of a feature.
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
@@ -90,7 +111,7 @@ class FeaturesPlugin_Symmetry : public ModelAPI_Feature
     return MY_KIND;
   }
 
-  /// Creates a new part document if needed.
+  /// Performs the algorithm and stores results it in the data structure.
   FEATURESPLUGIN_EXPORT virtual void execute();
 
   /// Request for initialization of data model of the feature: adding all attributes.
@@ -100,18 +121,28 @@ class FeaturesPlugin_Symmetry : public ModelAPI_Feature
   FeaturesPlugin_Symmetry();
 
 private:
-  ///Perform symmetry with respect to a point.
-  void performSymmetryByPoint();
+  /// Calculate symmetry with respect to a point.
+  std::shared_ptr<GeomAPI_Trsf> symmetryByPoint();
+
+  /// Calculate symmetry with respect to an axis.
+  std::shared_ptr<GeomAPI_Trsf> symmetryByAxis();
+
+  /// Calculate symmetry with respect to a plane.
+  std::shared_ptr<GeomAPI_Trsf> symmetryByPlane();
 
-  ///Perform symmetry with respect to an axis.
-  void performSymmetryByAxis();
+  /// Perform the transformation
+  void performSymmetry(std::shared_ptr<GeomAPI_Trsf> theTrsf);
 
-  ///Perform symmetry with respect to a plane.
-  void performSymmetryByPlane();
+  /// Create new result on given shapes and the index of result
+  void buildResult(const std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theAlgo,
+                   const std::list<std::shared_ptr<GeomAPI_Shape> >& theOriginalShapes,
+                   std::shared_ptr<GeomAPI_Shape> theTargetShape,
+                   int& theResultIndex);
 
-  void loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
-                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                    std::shared_ptr<GeomAPI_Shape> theBaseShape);
+  /// Create new result for the given part and transformation
+  void buildResult(std::shared_ptr<ModelAPI_ResultPart> theOriginal,
+                   std::shared_ptr<GeomAPI_Trsf> theTrsf,
+                   int& theResultIndex);
 };
 
 #endif // FEATURESPLUGIN_SYMMETRY_H_