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