0028786: Refactoring of the Warning/Error reporting system of Boolean Operations...
[occt.git] / src / BOPAlgo / BOPAlgo_MakerVolume.hxx
... / ...
CommitLineData
1// Created by: Eugeny MALTCHIKOV
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 _BOPAlgo_MakerVolume_HeaderFile
16#define _BOPAlgo_MakerVolume_HeaderFile
17
18#include <Standard.hxx>
19#include <Standard_DefineAlloc.hxx>
20#include <Standard_Handle.hxx>
21
22#include <Standard_Boolean.hxx>
23#include <Bnd_Box.hxx>
24#include <TopoDS_Solid.hxx>
25#include <BOPCol_ListOfShape.hxx>
26#include <BOPAlgo_Builder.hxx>
27#include <BOPCol_BaseAllocator.hxx>
28#include <BOPCol_MapOfShape.hxx>
29class TopoDS_Solid;
30class BOPAlgo_PaveFiller;
31
32
33
34//! The algorithm is to build solids from set of shapes.
35//! It uses the BOPAlgo_Builder algorithm to intersect the given shapes
36//! and build the images of faces (if needed) and BOPAlgo_BuilderSolid
37//! algorithm to build the solids.
38//!
39//! Steps of the algorithm:
40//! 1. Collect all faces: intersect the shapes if necessary and collect
41//! the images of faces, otherwise just collect the faces to the
42//! <myFaces> list;
43//! All faces on this step added twice, with orientation FORWARD
44//! and REVERSED;
45//!
46//! 2. Create bounding box covering all the faces from <myFaces> and
47//! create solid box from corner points of that bounding box
48//! (myBBox, mySBox). Add faces from that box to <myFaces>;
49//!
50//! 3. Build solids from <myFaces> using BOPAlgo_BuilderSolid algorithm;
51//!
52//! 4. Treat the result: Eliminate solid containig faces from <mySBox>;
53//!
54//! 5. Fill internal shapes: add internal vertices and edges into
55//! created solids;
56//!
57//! 6. Prepare the history.
58//!
59//! Fields:
60//! <myIntersect> - boolean flag. It defines whether intersect shapes
61//! from <myArguments> (if set to TRUE) or not (FALSE).
62//! The default value is TRUE. By setting it to FALSE
63//! the user should guarantee that shapes in <myArguments>
64//! do not interfere with each other, otherwise the result
65//! is unpredictable.
66//!
67//! <myBBox> - bounding box, covering all faces from <myFaces>.
68//!
69//! <mySBox> - Solid box created from the corner points of <myBBox>.
70//!
71//! <myFaces> - the list is to keep the "final" faces, that will be
72//! given to the BOPAlgo_BuilderSolid algorithm.
73//! If the shapes have been interfered it should contain
74//! the images of the source shapes, otherwise its just
75//! the original faces.
76//! It also contains the faces from <mySBox>.
77//!
78//! Fields inherited from BOPAlgo_Builder:
79//!
80//! <myArguments> - list of the source shapes. The source shapes can have
81//! any type, but each shape must not be self-interfered.
82//!
83//! <myShape> - Result shape:
84//! - empty compound - if no solids were created;
85//! - solid - if created only one solid;
86//! - compound of solids - if created more than one solid.
87//!
88//! Fields inherited from BOPAlgo_Algo:
89//!
90//! <myRunParallel> - Defines whether the parallel processing is
91//! switched on or not.
92//! <myReport> - Error status of the operation. Additionally to the
93//! errors of the parent algorithm it can have the following values:
94//! - *BOPAlgo_AlertSolidBuilderFailed* - BOPAlgo_BuilderSolid algorithm has failed.
95//!
96//! Example:
97//!
98//! BOPAlgo_MakerVolume aMV;
99//! //
100//! aMV.SetArguments(aLS); //source shapes
101//! aMV.SetRunParallel(bRunParallel); //parallel or single mode
102//! aMV.SetIntersect(bIntersect); //intersect or not the shapes from <aLS>
103//! //
104//! aMV.Perform(); //perform the operation
105//! if (aMV.ErrorStatus()) { //check error status
106//! return;
107//! }
108//! //
109//! const TopoDS_Shape& aResult = aMV.Shape(); //result of the operation
110class BOPAlgo_MakerVolume : public BOPAlgo_Builder
111{
112public:
113
114 DEFINE_STANDARD_ALLOC
115
116
117
118 //! Empty contructor.
119 BOPAlgo_MakerVolume();
120 virtual ~BOPAlgo_MakerVolume();
121
122 //! Empty contructor.
123 BOPAlgo_MakerVolume(const BOPCol_BaseAllocator& theAllocator);
124
125 //! Clears the data.
126 virtual void Clear() Standard_OVERRIDE;
127
128 //! Sets the flag myIntersect:
129 //! if <bIntersect> is TRUE the shapes from <myArguments> will be intersected.
130 //! if <bIntersect> is FALSE no intersection will be done.
131 void SetIntersect(const Standard_Boolean bIntersect);
132
133 //! Returns the flag <myIntersect>.
134 Standard_Boolean IsIntersect() const;
135
136 //! Returns the solid box <mySBox>.
137 const TopoDS_Solid& Box() const;
138
139 //! Returns the processed faces <myFaces>.
140 const BOPCol_ListOfShape& Faces() const;
141
142 //! Defines the preventing of addition of internal for solid parts into the result.
143 //! By default the internal parts are added into result.
144 Standard_EXPORT void SetAvoidInternalShapes(const Standard_Boolean theAvoidInternal) {
145 myAvoidInternalShapes = theAvoidInternal;
146 }
147
148 //! Returns the AvoidInternalShapes flag
149 Standard_EXPORT Standard_Boolean IsAvoidInternalShapes() const {
150 return myAvoidInternalShapes;
151 }
152
153 //! Performs the operation.
154 Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
155
156protected:
157
158 //! Checks the data.
159 Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
160
161 //! Performs the operation.
162 Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
163
164 //! Collects all faces.
165 Standard_EXPORT void CollectFaces();
166
167 //! Makes solid box.
168 Standard_EXPORT void MakeBox (BOPCol_MapOfShape& theBoxFaces);
169
170 //! Builds solids.
171 Standard_EXPORT void BuildSolids (BOPCol_ListOfShape& theLSR);
172
173 //! Removes the covering box.
174 Standard_EXPORT void RemoveBox (BOPCol_ListOfShape& theLSR, const BOPCol_MapOfShape& theBoxFaces);
175
176 //! Fills the solids with internal shapes.
177 Standard_EXPORT void FillInternalShapes (const BOPCol_ListOfShape& theLSR);
178
179 //! Builds the result.
180 Standard_EXPORT void BuildShape (const BOPCol_ListOfShape& theLSR);
181
182
183 Standard_Boolean myIntersect;
184 Bnd_Box myBBox;
185 TopoDS_Solid mySBox;
186 BOPCol_ListOfShape myFaces;
187 Standard_Boolean myAvoidInternalShapes;
188
189private:
190
191};
192
193#include <BOPAlgo_MakerVolume.lxx>
194
195#endif // _BOPAlgo_MakerVolume_HeaderFile