0028786: Refactoring of the Warning/Error reporting system of Boolean Operations...
[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_Builder.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_Builder
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   //! Adds Tool argument of the operation
86   Standard_EXPORT virtual void AddTool (const TopoDS_Shape& theShape);
87   
88   Standard_EXPORT virtual void SetTools (const BOPCol_ListOfShape& theShapes);
89   
90   Standard_EXPORT void SetOperation (const BOPAlgo_Operation theOperation);
91   
92   Standard_EXPORT BOPAlgo_Operation Operation() const;
93   
94   Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
95
96 protected:
97   
98   Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
99   
100   //! Performs calculations using prepared Filler
101   //! object <thePF>
102   Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
103   
104   Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType) Standard_OVERRIDE;
105   
106   Standard_EXPORT void BuildShape();
107   
108   Standard_EXPORT void BuildRC();
109   
110   Standard_EXPORT void BuildSolid();
111   
112   Standard_EXPORT Standard_Boolean IsBoundSplits (const TopoDS_Shape& theS, BOPCol_IndexedDataMapOfShapeListOfShape& theMEF);
113
114   //! Treatment of the cases with empty shapes.<br>
115   //! It returns TRUE if there is nothing to do, i.e.
116   //! all shapes in one of the groups are empty shapes.
117   Standard_EXPORT Standard_Boolean TreatEmptyShape();
118
119
120   BOPAlgo_Operation myOperation;
121   Standard_Integer myDims[2];
122   TopoDS_Shape myRC;
123   BOPCol_ListOfShape myTools;
124   BOPCol_MapOfShape myMapTools;
125
126
127 private:
128
129 };
130
131 #endif // _BOPAlgo_BOP_HeaderFile