Salome HOME
Issue #353 constraint on 2 segments from not acive sketches
[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    * \return a solid as result of operation
45    */
46   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> makeCommon(
47                                                   std::shared_ptr<GeomAPI_Shape> theObject,
48                                               std::shared_ptr<GeomAPI_Shape> theTool);
49
50    enum {
51         BOOL_CUT,
52     BOOL_FUSE,
53     BOOL_COMMON
54   };
55   /// Constructor
56   GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean (std::shared_ptr<GeomAPI_Shape> theObject,
57                                           std::shared_ptr<GeomAPI_Shape> theTool,
58                                                                                   int theType);
59
60   /// Returns True if algorithm succeed
61   GEOMALGOAPI_EXPORT const bool isDone() const;
62
63   ///  Returns True if resulting shape is valid
64   GEOMALGOAPI_EXPORT const bool isValid() const;
65
66   /// Returns result of the boolean algorithm which may be a Solid or a Face
67   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape () const; 
68  
69   /// Returns map of sub-shapes of the result. To be used for History keeping
70   GEOMALGOAPI_EXPORT void  mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const;
71
72   /// Return interface for for History processing
73   GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape () const;
74
75   ///Destructor
76   GEOMALGOAPI_EXPORT  ~GeomAlgoAPI_Boolean();
77
78   private:
79   /// builds resulting shape
80   void build(std::shared_ptr<GeomAPI_Shape> theObject,
81              std::shared_ptr<GeomAPI_Shape> theTool);
82   /// fields
83   double mySize;
84   bool myDone;
85   int  myOperation;
86   std::shared_ptr<GeomAPI_Shape> myShape;  
87   GeomAPI_DataMapOfShapeShape myMap;
88   GeomAlgoAPI_MakeShape * myMkShape;
89 };
90
91 #endif