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