0029333: Boolean Operations - Prevent modification of the input shapes in case their...
[occt.git] / src / BRepAlgoAPI / BRepAlgoAPI_BuilderAlgo.hxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _BRepAlgoAPI_BuilderAlgo_HeaderFile
16 #define _BRepAlgoAPI_BuilderAlgo_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <Standard_Integer.hxx>
23 #include <BOPAlgo_PPaveFiller.hxx>
24 #include <BOPAlgo_PBuilder.hxx>
25 #include <BOPAlgo_GlueEnum.hxx>
26 #include <Standard_Real.hxx>
27 #include <TopTools_ListOfShape.hxx>
28 #include <BRepAlgoAPI_Algo.hxx>
29 #include <Standard_Boolean.hxx>
30 class BOPAlgo_PaveFiller;
31 class TopoDS_Shape;
32
33
34 //! The class contains API level of the General Fuse algorithm.<br>
35 //!
36 //! Additionally to the options defined in the base class, the algorithm has
37 //! the following options:<br>
38 //! - *Safe processing mode* - allows to avoid modification of the input
39 //!                            shapes during the operation (by default it is off);
40 //! - *Gluing options* - allows to speed up the calculation of the intersections
41 //!                      on the special cases, in which some sub-shapes are coinciding.
42 //! - *Disabling the check for inverted solids* - Disables/Enables the check of the input solids
43 //!                          for inverted status (holes in the space). The default value is TRUE,
44 //!                          i.e. the check is performed. Setting this flag to FALSE for inverted solids,
45 //!                          most likely will lead to incorrect results.
46 //!
47 //! It returns the following Error statuses:<br>
48 //! - 0 - in case of success;<br>
49 //! - *BOPAlgo_AlertTooFewArguments* - in case there are no enough arguments to perform the operation;<br>
50 //! - *BOPAlgo_AlertIntersectionFailed* - in case the intersection of the arguments has failed;<br>
51 //! - *BOPAlgo_AlertBuilderFailed* - in case building of the result shape has failed.<br>
52 //!
53 //! Warnings statuses from underlying DS Filler and Builder algorithms
54 //! are collected in the report.
55 class BRepAlgoAPI_BuilderAlgo  : public BRepAlgoAPI_Algo
56 {
57 public:
58
59   DEFINE_STANDARD_ALLOC
60
61   
62   //! Empty constructor
63   Standard_EXPORT BRepAlgoAPI_BuilderAlgo();
64 Standard_EXPORT virtual ~BRepAlgoAPI_BuilderAlgo();
65   
66   //! Empty constructor
67   Standard_EXPORT BRepAlgoAPI_BuilderAlgo(const BOPAlgo_PaveFiller& thePF);
68   
69   //! Sets the flag that defines the mode of treatment.
70   //! In non-destructive mode the argument shapes are not modified. Instead
71   //! a copy of a sub-shape is created in the result if it is needed to be updated.
72   Standard_EXPORT void SetNonDestructive(const Standard_Boolean theFlag);
73
74   //! Returns the flag that defines the mode of treatment.
75   //! In non-destructive mode the argument shapes are not modified. Instead
76   //! a copy of a sub-shape is created in the result if it is needed to be updated.
77   Standard_EXPORT Standard_Boolean NonDestructive() const;
78
79   //! Sets the glue option for the algorithm
80   Standard_EXPORT void SetGlue(const BOPAlgo_GlueEnum theGlue);
81   
82   //! Returns the glue option of the algorithm
83   Standard_EXPORT BOPAlgo_GlueEnum Glue() const;
84
85   //! Enables/Disables the check of the input solids for inverted status
86   void SetCheckInverted(const Standard_Boolean theCheck)
87   {
88     myCheckInverted = theCheck;
89   }
90
91   //! Returns the flag defining whether the check for input solids on inverted status
92   //! should be performed or not.
93   Standard_Boolean CheckInverted() const
94   {
95     return myCheckInverted;
96   }
97
98   //! Sets the arguments
99   Standard_EXPORT void SetArguments (const TopTools_ListOfShape& theLS);
100   
101   //! Gets the arguments
102   Standard_EXPORT const TopTools_ListOfShape& Arguments() const;
103   
104   //! Performs the algorithm
105   //!
106   //! H  I  S  T  O  R  Y
107   Standard_EXPORT virtual void Build() Standard_OVERRIDE;
108   
109   //! Returns the list  of shapes modified from the shape <S>.
110   Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& aS) Standard_OVERRIDE;
111   
112   //! Returns true if the shape S has been deleted. The
113   //! result shape of the operation does not contain the shape S.
114   Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& aS) Standard_OVERRIDE;
115   
116   //! Returns the list  of shapes generated from the shape <S>.
117   //! For use in BRepNaming.
118   Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
119   
120   //! Returns true if there is at least one modified shape.
121   //! For use in BRepNaming.
122   Standard_EXPORT virtual Standard_Boolean HasModified() const;
123   
124   //! Returns true if there is at least one generated shape.
125   //! For use in BRepNaming.
126   Standard_EXPORT virtual Standard_Boolean HasGenerated() const;
127   
128   //! Returns true if there is at least one deleted shape.
129   //! For use in BRepNaming.
130   //!
131   //! protected methods
132   Standard_EXPORT virtual Standard_Boolean HasDeleted() const;
133
134   //! Returns the Intersection tool
135   const BOPAlgo_PPaveFiller& DSFiller() const
136   {
137     return myDSFiller;
138   }
139
140   //! Returns the Building tool
141   const BOPAlgo_PBuilder& Builder() const
142   {
143     return myBuilder;
144   }
145
146 protected:
147
148   Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
149
150   Standard_Integer myEntryType;
151   BOPAlgo_PPaveFiller myDSFiller;
152   BOPAlgo_PBuilder myBuilder;
153   Standard_Boolean myNonDestructive;
154   TopTools_ListOfShape myArguments;
155   BOPAlgo_GlueEnum myGlue;
156   Standard_Boolean myCheckInverted;
157
158 private:
159
160 };
161
162 #endif // _BRepAlgoAPI_BuilderAlgo_HeaderFile