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