Salome HOME
Another fix for revolution naming.
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Boolean.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_Boolean.h
4 // Created:     02 Sept 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef GeomAlgoAPI_Boolean_H_
8 #define GeomAlgoAPI_Boolean_H_
9
10 #include <GeomAlgoAPI.h>
11 #include <GeomAlgoAPI_MakeShape.h>
12
13 #include <GeomAPI_Shape.h>
14 #include <GeomAPI_Interface.h>
15 #include <GeomAPI_DataMapOfShapeShape.h>
16
17 #include <memory>
18
19 /**\class GeomAlgoAPI_Boolean
20  * \ingroup DataAlgo
21  * \brief Allows to perform of boolean operations
22  */
23 class GeomAlgoAPI_Boolean : public GeomAPI_Interface
24 {
25  public:
26   /**\brief Creates cut boolean operation
27    * \param[in] theShape the main shape
28    * \param[in] theTool  toole shape for boolean
29    * \return a solid as result of operation
30    */
31   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> makeCut(
32                                                   std::shared_ptr<GeomAPI_Shape> theShape,
33                                             std::shared_ptr<GeomAPI_Shape> theTool);
34
35   /**\brief Creates fuse boolean operation
36    * \param[in] theShape the main shape
37    * \param[in] theTool  second shape
38    * \return a solid as result of operation
39    */
40   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> makeFuse(
41                                                   std::shared_ptr<GeomAPI_Shape> theShape,
42                                               std::shared_ptr<GeomAPI_Shape> theTool);
43
44   /**\brief Creates common boolean operation
45    * \param[in] theObject the main shape
46    * \param[in] theTool  second shape
47    * \return a solid as result of operation
48    */
49   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> makeCommon(
50                                                   std::shared_ptr<GeomAPI_Shape> theObject,
51                                               std::shared_ptr<GeomAPI_Shape> theTool);
52
53    enum {
54         BOOL_CUT,
55     BOOL_FUSE,
56     BOOL_COMMON
57   };
58   /// Constructor
59   GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean (std::shared_ptr<GeomAPI_Shape> theObject,
60                                           std::shared_ptr<GeomAPI_Shape> theTool,
61                                                                                   int theType);
62
63   /// Returns True if algorithm succeed
64   GEOMALGOAPI_EXPORT const bool isDone() const;
65
66   ///  Returns True if resulting shape is valid
67   GEOMALGOAPI_EXPORT const bool isValid() const;
68
69   /// Returns result of the boolean algorithm which may be a Solid or a Face
70   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape () const; 
71  
72   /// Returns map of sub-shapes of the result. To be used for History keeping
73   GEOMALGOAPI_EXPORT void  mapOfShapes(std::shared_ptr<GeomAPI_DataMapOfShapeShape>& theMap) const;
74
75   /// Return interface for for History processing
76   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAlgoAPI_MakeShape>& makeShape () const;
77
78   ///Destructor
79   GEOMALGOAPI_EXPORT  ~GeomAlgoAPI_Boolean();
80
81   private:
82   /// builds resulting shape
83   void build(std::shared_ptr<GeomAPI_Shape> theObject,
84              std::shared_ptr<GeomAPI_Shape> theTool);
85   /// fields
86   double mySize;
87   bool myDone;
88   int  myOperation;
89   std::shared_ptr<GeomAPI_Shape> myShape;
90   std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
91   std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
92 };
93
94 #endif