Salome HOME
Add parameter feature without tests.
[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   /// Type of booelan operation
27   enum OperationType{
28     BOOL_CUT, ///< Cut objects
29     BOOL_FUSE, ///< Fuse objects
30     BOOL_COMMON ///< Take common part of objects
31   };
32
33  public:
34   /** \brief Creates cut boolean operation.
35    *  \param[in] theObjects the main shape.
36    *  \param[in] theTools  toole shape for boolean.
37    *  \return a solid or compound of solids as result of operation.
38    */
39   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> makeCut(const ListOfShape& theObjects,
40                                                                    const ListOfShape& theTools);
41
42   /** \brief Creates fuse boolean operation.
43    *  \param[in] theObjects the main shape.
44    *  \param[in] theTools  second shape.
45    *  \return a solid as result of operation.
46    */
47   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> makeFuse(const ListOfShape& theObjects,
48                                                                     const ListOfShape& theTools);
49
50   /** \brief Creates common boolean operation.
51    *  \param[in] theObjects the main shape.
52    *  \param[in] theTools  second shape.
53    *  \return a solid as result of operation.
54    */
55   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> makeCommon(const ListOfShape& theObjects,
56                                                                       const ListOfShape& theTools);
57
58   /// Constructor.
59   GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean(const ListOfShape& theObjects,
60                                          const ListOfShape& theTools,
61                                          const OperationType theOperationType);
62
63   /// \return true if algorithm succeed.
64   GEOMALGOAPI_EXPORT const bool isDone() const;
65
66   /// \return true if resulting shape is valid.
67   GEOMALGOAPI_EXPORT const bool isValid() const;
68
69   /// \return result of the boolean algorithm.
70   GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape() const;
71
72   /// \return map of sub-shapes of the result. To be used for History keeping.
73   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_DataMapOfShapeShape> mapOfShapes() const;
74
75   /// \return interface for for History processing.
76   GEOMALGOAPI_EXPORT std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape() const;
77
78 private:
79   /// Builds resulting shape.
80   void build(const ListOfShape& theObjects,
81              const ListOfShape& theTools,
82              const OperationType theOperationType);
83
84 private:
85   /// Fields.
86   bool myDone;
87   std::shared_ptr<GeomAPI_Shape> myShape;
88   std::shared_ptr<GeomAPI_DataMapOfShapeShape> myMap;
89   std::shared_ptr<GeomAlgoAPI_MakeShape> myMkShape;
90 };
91
92 #endif