0025614: Provide API access to the new fuctionalities of Boolean Components
[occt.git] / src / BRepAlgoAPI / BRepAlgoAPI_BuilderAlgo.cxx
1 // Created by: Peter KURNEV
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 #include <BRepAlgoAPI_BuilderAlgo.ixx>
16
17 #include <BOPAlgo_PaveFiller.hxx>
18 #include <BOPAlgo_Builder.hxx>
19
20 //=======================================================================
21 // function: 
22 // purpose: 
23 //=======================================================================
24 BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo()
25 :
26   BRepAlgoAPI_Algo(),
27   myEntryType(1),
28   myDSFiller(NULL),
29   myBuilder(NULL),
30   myFuzzyValue(0.)
31 {}
32 //=======================================================================
33 // function: 
34 // purpose: 
35 //=======================================================================
36 BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo
37   (const BOPAlgo_PaveFiller& aPF)
38 :
39   BRepAlgoAPI_Algo(),
40   myEntryType(0),
41   myBuilder(NULL),
42   myFuzzyValue(0.)
43 {
44   BOPAlgo_PaveFiller* pPF=(BOPAlgo_PaveFiller*)&aPF;
45   myDSFiller=pPF;
46 }
47 //=======================================================================
48 // function: ~
49 // purpose: 
50 //=======================================================================
51 BRepAlgoAPI_BuilderAlgo::~BRepAlgoAPI_BuilderAlgo()
52 {
53   Clear();
54 }
55 //=======================================================================
56 //function : SetFuzzyValue
57 //purpose  : 
58 //=======================================================================
59 void BRepAlgoAPI_BuilderAlgo::SetFuzzyValue(const Standard_Real theFuzz)
60 {
61   if (theFuzz > 0.) {
62     myFuzzyValue = theFuzz;
63   }
64 }
65 //=======================================================================
66 //function : FuzzyValue
67 //purpose  : 
68 //=======================================================================
69 Standard_Real BRepAlgoAPI_BuilderAlgo::FuzzyValue() const
70 {
71   return myFuzzyValue;
72 }
73 //=======================================================================
74 //function : Clear
75 //purpose  : 
76 //=======================================================================
77 void BRepAlgoAPI_BuilderAlgo::Clear()
78 {
79   if (myDSFiller && myEntryType) {
80     delete myDSFiller;
81     myDSFiller=NULL;
82   }
83   if (myBuilder) {
84     delete myBuilder;
85     myBuilder=NULL;
86   }
87 }
88 //=======================================================================
89 //function : SetArguments
90 //purpose  : 
91 //=======================================================================
92 void BRepAlgoAPI_BuilderAlgo::SetArguments
93   (const TopTools_ListOfShape& theLS)
94 {
95   myArguments=theLS;
96 }
97 //=======================================================================
98 //function : Arguments
99 //purpose  : 
100 //=======================================================================
101 const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Arguments()const
102 {
103   return myArguments;
104 }
105 //=======================================================================
106 //function : Build
107 //purpose  : 
108 //=======================================================================
109 void BRepAlgoAPI_BuilderAlgo::Build()
110 {
111   Standard_Integer iErr;
112   //
113   NotDone();
114   myErrorStatus=0;
115   //
116   Clear();
117   //
118   if (myEntryType) {
119     if (myDSFiller) {
120       delete myDSFiller;
121     }
122     myDSFiller=new BOPAlgo_PaveFiller(myAllocator);
123     //
124     myDSFiller->SetArguments(myArguments);
125     //
126     myDSFiller->SetRunParallel(myRunParallel);
127     myDSFiller->SetProgressIndicator(myProgressIndicator);
128     myDSFiller->SetFuzzyValue(myFuzzyValue);
129     //
130     myDSFiller->Perform();
131     iErr=myDSFiller->ErrorStatus();
132     if (iErr) {
133       myErrorStatus=100+iErr;
134     }
135   }// if (myEntryType) {
136   // 
137   if (myBuilder) {
138     delete myBuilder;
139   }
140   myBuilder=new BOPAlgo_Builder(myAllocator);
141   //
142   myBuilder->SetArguments(myArguments);
143   //
144   myBuilder->SetRunParallel(myRunParallel);
145   myBuilder->SetProgressIndicator(myProgressIndicator);
146   //
147   myBuilder->PerformWithFiller(*myDSFiller);
148   iErr=myBuilder->ErrorStatus();
149   if (iErr) {
150     myErrorStatus=200+iErr;
151   }
152   //
153   Done();
154   myShape=myBuilder->Shape();
155 }
156 //=======================================================================
157 //function : Generated
158 //purpose  : 
159 //=======================================================================
160 const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Generated
161   (const TopoDS_Shape& aS) 
162 {
163   if (myBuilder==NULL) {
164     myGenerated.Clear();
165     return myGenerated;
166   }
167   myGenerated = myBuilder->Generated(aS);
168   return myGenerated;
169 }
170 //=======================================================================
171 //function : Modified
172 //purpose  : 
173 //=======================================================================
174 const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Modified
175   (const TopoDS_Shape& aS) 
176 {
177   if (myBuilder==NULL) {
178     myGenerated.Clear();
179     return myGenerated;
180   }
181   myGenerated = myBuilder->Modified(aS);
182   return myGenerated;
183 }
184 //=======================================================================
185 //function : IsDeleted
186 //purpose  : 
187 //=======================================================================
188 Standard_Boolean BRepAlgoAPI_BuilderAlgo::IsDeleted
189   (const TopoDS_Shape& aS) 
190 {
191   Standard_Boolean bDeleted = Standard_True; 
192   if (myBuilder != NULL) {
193     bDeleted=myBuilder->IsDeleted(aS);
194   }
195   return bDeleted; 
196 }
197 //=======================================================================
198 //function : HasModified
199 //purpose  : 
200 //=======================================================================
201 Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasModified() const
202 {
203   if (myBuilder==NULL) {
204     return Standard_False;
205   }
206   return myBuilder->HasModified();
207 }
208 //=======================================================================
209 //function : HasGenerated
210 //purpose  : 
211 //=======================================================================
212 Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasGenerated() const
213 {
214   if (myBuilder==NULL) {
215     return Standard_False;
216   }
217   return myBuilder->HasGenerated();
218 }
219 //=======================================================================
220 //function : HasDeleted
221 //purpose  : 
222 //=======================================================================
223 Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasDeleted() const
224 {
225   if (myBuilder==NULL) {
226     return Standard_False;
227   }
228   return myBuilder->HasDeleted();
229 }