b61e5f28fcf45bb999a8b5967da0c779f73fa0f3
[occt.git] / src / BOPAlgo / BOPAlgo_Builder.hxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 //                         EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 //
7 // This file is part of Open CASCADE Technology software library.
8 //
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
14 //
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
17
18 #ifndef _BOPAlgo_Builder_HeaderFile
19 #define _BOPAlgo_Builder_HeaderFile
20
21 #include <Standard.hxx>
22 #include <Standard_DefineAlloc.hxx>
23 #include <Standard_Handle.hxx>
24
25 #include <BOPCol_ListOfShape.hxx>
26 #include <BOPCol_MapOfShape.hxx>
27 #include <BOPAlgo_PPaveFiller.hxx>
28 #include <BOPAlgo_GlueEnum.hxx>
29 #include <BOPDS_PDS.hxx>
30 #include <Standard_Integer.hxx>
31 #include <BOPCol_DataMapOfShapeListOfShape.hxx>
32 #include <BOPCol_DataMapOfShapeShape.hxx>
33 #include <Standard_Real.hxx>
34 #include <BOPAlgo_BuilderShape.hxx>
35 #include <BOPCol_BaseAllocator.hxx>
36 #include <TopTools_ListOfShape.hxx>
37 #include <Standard_Boolean.hxx>
38 #include <TopAbs_ShapeEnum.hxx>
39 class IntTools_Context;
40 class TopoDS_Shape;
41 class BOPAlgo_PaveFiller;
42
43 //!
44 //! The class is a General Fuse algorithm - base algorithm for the
45 //! algorithms in the Boolean Component. Its main purpose is to build
46 //! the split parts of the argument shapes from which the result of
47 //! the operations is combined.<br>
48 //! The result of the General Fuse algorithm itself is a compound
49 //! containing all split parts of the arguments. <br>
50 //!
51 //! Additionally to the options of the base classes, the algorithm has
52 //! the following options:<br>
53 //! - *Safe processing mode* - allows to avoid modification of the input
54 //!                            shapes during the operation (by default it is off);<br>
55 //! - *Gluing options* - allows to speed up the calculation of the intersections
56 //!                      on the special cases, in which some sub-shapes are coinciding.<br>
57 //!
58 //! The algorithm returns the following Error statuses:
59 //! - *BOPAlgo_AlertTooFewArguments* - in case there are no enough arguments to perform the operation;
60 //! - *BOPAlgo_AlertNoFiller* - in case the intersection tool has not been created;
61 //! - *BOPAlgo_AlertIntersectionFailed* - in case the intersection of the arguments has failed;
62 //! - *BOPAlgo_AlertBuilderFailed* - in case building splits of arguments has failed with some unexpected error.
63 //!
64 class BOPAlgo_Builder  : public BOPAlgo_BuilderShape
65 {
66 public:
67
68   DEFINE_STANDARD_ALLOC
69
70   
71   Standard_EXPORT BOPAlgo_Builder();
72 Standard_EXPORT virtual ~BOPAlgo_Builder();
73   
74   Standard_EXPORT BOPAlgo_Builder(const BOPCol_BaseAllocator& theAllocator);
75   
76   Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
77   
78   Standard_EXPORT BOPAlgo_PPaveFiller PPaveFiller();
79   
80   Standard_EXPORT BOPDS_PDS PDS();
81   
82   Standard_EXPORT virtual void AddArgument (const TopoDS_Shape& theShape);
83   
84   Standard_EXPORT virtual void SetArguments (const BOPCol_ListOfShape& theLS);
85   
86   Standard_EXPORT const BOPCol_ListOfShape& Arguments() const;
87
88   Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
89   
90   Standard_EXPORT virtual void PerformWithFiller (const BOPAlgo_PaveFiller& theFiller);
91   
92   //! Returns the  list of shapes generated from the
93   //! shape theS.
94   Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS) Standard_OVERRIDE;
95   
96   //! Returns the list of shapes modified from the shape
97   //! theS.
98   Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS) Standard_OVERRIDE;
99   
100   //! Returns true if the shape theS has been deleted.
101   Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE;
102   
103   Standard_EXPORT const BOPCol_DataMapOfShapeListOfShape& Images() const;
104   
105   Standard_EXPORT Standard_Boolean IsInterferred (const TopoDS_Shape& theS) const;
106   
107   //! Returns myOrigins.
108   Standard_EXPORT const BOPCol_DataMapOfShapeListOfShape& Origins() const;
109   
110   //! Returns myShapesSD.
111   Standard_EXPORT const BOPCol_DataMapOfShapeShape& ShapesSD() const;
112   
113   //! Returns mySplits.
114   Standard_EXPORT const BOPCol_DataMapOfShapeListOfShape& Splits() const;
115   
116   
117   //! Sets the flag that defines the mode of treatment.
118   //! In non-destructive mode the argument shapes are not modified. Instead
119   //! a copy of a sub-shape is created in the result if it is needed to be updated.
120   //! This flag is taken into account if internal PaveFiller is used only.
121   //! In the case of calling PerformWithFiller the corresponding flag of that PaveFiller
122   //! is in force.
123   Standard_EXPORT void SetNonDestructive(const Standard_Boolean theFlag);
124
125   //! Returns the flag that defines the mode of treatment.
126   //! In non-destructive mode the argument shapes are not modified. Instead
127   //! a copy of a sub-shape is created in the result if it is needed to be updated.
128   Standard_EXPORT Standard_Boolean NonDestructive() const;
129
130   //! Sets the glue option for the algorithm
131   Standard_EXPORT void SetGlue(const BOPAlgo_GlueEnum theGlue);
132   
133   //! Returns the glue option of the algorithm
134   Standard_EXPORT BOPAlgo_GlueEnum Glue() const;
135
136 protected:
137
138   //! Prepare information for history support
139   Standard_EXPORT virtual void PrepareHistory() Standard_OVERRIDE;
140   
141   Standard_EXPORT virtual void PerformInternal (const BOPAlgo_PaveFiller& thePF);
142   
143   Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF);
144   
145   Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
146
147   //! Checks if the intersection algorithm has Errors/Warnings
148   Standard_EXPORT void CheckFiller();
149   
150   Standard_EXPORT virtual void Prepare();
151   
152   Standard_EXPORT void FillImagesVertices();
153   
154   Standard_EXPORT void FillImagesEdges();
155   
156   Standard_EXPORT virtual void BuildResult (const TopAbs_ShapeEnum theType);
157   
158   Standard_EXPORT void FillImagesContainers (const TopAbs_ShapeEnum theType);
159   
160   Standard_EXPORT void FillImagesCompounds();
161   
162   Standard_EXPORT void FillImagesContainer (const TopoDS_Shape& theS, const TopAbs_ShapeEnum theType);
163   
164   Standard_EXPORT void FillImagesCompound (const TopoDS_Shape& theS, BOPCol_MapOfShape& theMF);
165   
166   Standard_EXPORT void FillImagesFaces();
167   
168   Standard_EXPORT virtual void BuildSplitFaces();
169   
170   Standard_EXPORT void FillSameDomainFaces();
171   
172   Standard_EXPORT void FillImagesFaces1();
173   
174   Standard_EXPORT void FillImagesSolids();
175   
176   Standard_EXPORT void BuildDraftSolid (const TopoDS_Shape& theSolid, TopoDS_Shape& theDraftSolid, BOPCol_ListOfShape& theLIF);
177   
178   Standard_EXPORT virtual void FillIn3DParts (BOPCol_DataMapOfShapeListOfShape& theInParts, BOPCol_DataMapOfShapeShape& theDraftSolids, const BOPCol_BaseAllocator& theAllocator);
179   
180   Standard_EXPORT void BuildSplitSolids (BOPCol_DataMapOfShapeListOfShape& theInParts, BOPCol_DataMapOfShapeShape& theDraftSolids, const BOPCol_BaseAllocator& theAllocator);
181   
182   Standard_EXPORT void FillInternalShapes();
183   
184   Standard_EXPORT virtual void PostTreat();
185
186
187   BOPCol_ListOfShape myArguments;
188   BOPCol_MapOfShape myMapFence;
189   BOPAlgo_PPaveFiller myPaveFiller;
190   BOPDS_PDS myDS;
191   Handle(IntTools_Context) myContext;
192   Standard_Integer myEntryPoint;
193   BOPCol_DataMapOfShapeListOfShape myImages;
194   BOPCol_DataMapOfShapeShape myShapesSD;
195   BOPCol_DataMapOfShapeListOfShape mySplits;
196   BOPCol_DataMapOfShapeListOfShape myOrigins;
197   Standard_Boolean myNonDestructive;
198   BOPAlgo_GlueEnum myGlue;
199
200 private:
201
202 };
203
204
205 #endif // _BOPAlgo_Builder_HeaderFile