1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _BOPAlgo_MakerVolume_HeaderFile
16 #define _BOPAlgo_MakerVolume_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21 #include <Standard_Boolean.hxx>
23 #include <BOPAlgo_Builder.hxx>
24 #include <Bnd_Box.hxx>
25 #include <NCollection_BaseAllocator.hxx>
26 #include <TopoDS_Solid.hxx>
27 #include <TopTools_ListOfShape.hxx>
28 #include <TopTools_MapOfShape.hxx>
30 class BOPAlgo_PaveFiller;
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.
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
43 //! All faces on this step added twice, with orientation FORWARD
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>;
50 //! 3. Build solids from <myFaces> using BOPAlgo_BuilderSolid algorithm;
52 //! 4. Treat the result: Eliminate solid containig faces from <mySBox>;
54 //! 5. Fill internal shapes: add internal vertices and edges into
57 //! 6. Prepare the history.
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
67 //! <myBBox> - bounding box, covering all faces from <myFaces>.
69 //! <mySBox> - Solid box created from the corner points of <myBBox>.
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>.
78 //! Fields inherited from BOPAlgo_Builder:
80 //! <myArguments> - list of the source shapes. The source shapes can have
81 //! any type, but each shape must not be self-interfered.
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.
88 //! Fields inherited from BOPAlgo_Algo:
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.
98 //! BOPAlgo_MakerVolume aMV;
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>
104 //! aMV.Perform(); //perform the operation
105 //! if (aMV.HasErrors()) { //check error status
109 //! const TopoDS_Shape& aResult = aMV.Shape(); //result of the operation
110 class BOPAlgo_MakerVolume : public BOPAlgo_Builder
114 DEFINE_STANDARD_ALLOC
118 //! Empty contructor.
119 BOPAlgo_MakerVolume();
120 virtual ~BOPAlgo_MakerVolume();
122 //! Empty contructor.
123 BOPAlgo_MakerVolume(const Handle(NCollection_BaseAllocator)& theAllocator);
126 virtual void Clear() Standard_OVERRIDE;
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);
133 //! Returns the flag <myIntersect>.
134 Standard_Boolean IsIntersect() const;
136 //! Returns the solid box <mySBox>.
137 const TopoDS_Solid& Box() const;
139 //! Returns the processed faces <myFaces>.
140 const TopTools_ListOfShape& Faces() const;
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;
148 //! Returns the AvoidInternalShapes flag
149 Standard_EXPORT Standard_Boolean IsAvoidInternalShapes() const {
150 return myAvoidInternalShapes;
153 //! Performs the operation.
154 Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
159 Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
161 //! Performs the operation.
162 Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF) Standard_OVERRIDE;
164 //! Collects all faces.
165 Standard_EXPORT void CollectFaces();
168 Standard_EXPORT void MakeBox (TopTools_MapOfShape& theBoxFaces);
171 Standard_EXPORT void BuildSolids (TopTools_ListOfShape& theLSR);
173 //! Removes the covering box.
174 Standard_EXPORT void RemoveBox (TopTools_ListOfShape& theLSR, const TopTools_MapOfShape& theBoxFaces);
176 //! Fills the solids with internal shapes.
177 Standard_EXPORT void FillInternalShapes (const TopTools_ListOfShape& theLSR);
179 //! Builds the result.
180 Standard_EXPORT void BuildShape (const TopTools_ListOfShape& theLSR);
183 Standard_Boolean myIntersect;
186 TopTools_ListOfShape myFaces;
187 Standard_Boolean myAvoidInternalShapes;
193 #include <BOPAlgo_MakerVolume.lxx>
195 #endif // _BOPAlgo_MakerVolume_HeaderFile