0029186: Move AddTool(), SetTools(), Tools() and other common methods of BOP tools...
[occt.git] / src / BOPAlgo / BOPAlgo_BOP.hxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-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 _BOPAlgo_BOP_HeaderFile
16 #define _BOPAlgo_BOP_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <BOPAlgo_Operation.hxx>
23 #include <Standard_Integer.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <BOPCol_ListOfShape.hxx>
26 #include <BOPCol_MapOfShape.hxx>
27 #include <BOPAlgo_ToolsProvider.hxx>
28 #include <BOPCol_BaseAllocator.hxx>
29 #include <TopAbs_ShapeEnum.hxx>
30 #include <Standard_Boolean.hxx>
31 #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
32 class TopoDS_Shape;
33 class BOPAlgo_PaveFiller;
34
35 //!
36 //! The class represents the Building part of the Boolean Operations
37 //! algorithm.<br>
38 //! The arguments of the algorithms are divided in two groups - *Objects*
39 //! and *Tools*.<br>
40 //! The algorithm builds the splits of the given arguments using the intersection
41 //! results and combines the result of Boolean Operation of given type:<br>
42 //! - *FUSE* - union of two groups of objects;<br>
43 //! - *COMMON* - intersection of two groups of objects;<br>
44 //! - *CUT* - subtraction of one group from the other.<br>
45 //!
46 //! The rules for the arguments and type of the operation are the following:<br>
47 //! - For Boolean operation *FUSE* all arguments should have equal dimensions;<br>
48 //! - For Boolean operation *CUT* the minimal dimension of *Tools* should not be
49 //!   less than the maximal dimension of *Objects*;<br>
50 //! - For Boolean operation *COMMON* the arguments can have any dimension.<br>
51 //!
52 //! The class is a General Fuse based algorithm. Thus, all options
53 //! of the General Fuse algorithm such as Fuzzy mode, safe processing mode,
54 //! parallel processing mode, gluing mode and history support are also
55 //! available in this algorithm.<br>
56 //!
57 //! Additionally to the Warnings of the parent class the algorithm returns
58 //! the following warnings:
59 //! - *BOPAlgo_AlertEmptyShape* - in case some of the input shapes are empty shapes.
60 //!
61 //! Additionally to Errors of the parent class the algorithm returns
62 //! the following Error statuses:
63 //! - *BOPAlgo_AlertBOPIsNotSet* - in case the type of Boolean operation is not set;
64 //! - *BOPAlgo_AlertBOPNotAllowed* - in case the operation of given type is not allowed on
65 //!                     given inputs;
66 //! - *BOPAlgo_AlertSolidBuilderFailed* - in case the BuilderSolid algorithm failed to
67 //!                          produce the Fused solid.
68 //!
69 class BOPAlgo_BOP  : public BOPAlgo_ToolsProvider
70 {
71 public:
72
73   DEFINE_STANDARD_ALLOC
74
75   
76   //! Empty constructor
77   Standard_EXPORT BOPAlgo_BOP();
78   Standard_EXPORT virtual ~BOPAlgo_BOP();
79   
80   Standard_EXPORT BOPAlgo_BOP(const BOPCol_BaseAllocator& theAllocator);
81   
82   //! Clears internal fields and arguments
83   Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
84   
85   Standard_EXPORT void SetOperation (const BOPAlgo_Operation theOperation);
86   
87   Standard_EXPORT BOPAlgo_Operation Operation() const;
88   
89   Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
90
91 protected:
92   
93   Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
94   
95   //! Performs calculations using prepared Filler
96   //! object <thePF>
97   Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
98   
99   Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType) Standard_OVERRIDE;
100   
101   Standard_EXPORT void BuildShape();
102   
103   Standard_EXPORT void BuildRC();
104   
105   Standard_EXPORT void BuildSolid();
106   
107   Standard_EXPORT Standard_Boolean IsBoundSplits (const TopoDS_Shape& theS, BOPCol_IndexedDataMapOfShapeListOfShape& theMEF);
108
109   //! Treatment of the cases with empty shapes.<br>
110   //! It returns TRUE if there is nothing to do, i.e.
111   //! all shapes in one of the groups are empty shapes.
112   Standard_EXPORT Standard_Boolean TreatEmptyShape();
113
114 protected:
115
116   BOPAlgo_Operation myOperation;
117   Standard_Integer  myDims[2];
118   TopoDS_Shape      myRC;
119 };
120
121 #endif // _BOPAlgo_BOP_HeaderFile