b1d15f53 |
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 | |
b1d15f53 |
15 | |
49b0c452 |
16 | #include <BOPAlgo_Builder.hxx> |
42cf5bc1 |
17 | #include <BOPAlgo_PaveFiller.hxx> |
18 | #include <BRepAlgoAPI_BuilderAlgo.hxx> |
19 | #include <TopoDS_Shape.hxx> |
b1d15f53 |
20 | |
21 | //======================================================================= |
22 | // function: |
23 | // purpose: |
24 | //======================================================================= |
25 | BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo() |
26 | : |
27 | BRepAlgoAPI_Algo(), |
49b0c452 |
28 | myEntryType(1), |
b1d15f53 |
29 | myDSFiller(NULL), |
30 | myBuilder(NULL), |
483ce1bd |
31 | myNonDestructive(Standard_False), |
32 | myGlue(BOPAlgo_GlueOff) |
b1d15f53 |
33 | {} |
34 | //======================================================================= |
35 | // function: |
36 | // purpose: |
37 | //======================================================================= |
38 | BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo |
49b0c452 |
39 | (const BOPAlgo_PaveFiller& aPF) |
b1d15f53 |
40 | : |
49b0c452 |
41 | BRepAlgoAPI_Algo(), |
42 | myEntryType(0), |
b1d15f53 |
43 | myBuilder(NULL), |
483ce1bd |
44 | myNonDestructive(Standard_False), |
45 | myGlue(BOPAlgo_GlueOff) |
49b0c452 |
46 | { |
47 | BOPAlgo_PaveFiller* pPF=(BOPAlgo_PaveFiller*)&aPF; |
48 | myDSFiller=pPF; |
49 | } |
b1d15f53 |
50 | //======================================================================= |
51 | // function: ~ |
52 | // purpose: |
53 | //======================================================================= |
54 | BRepAlgoAPI_BuilderAlgo::~BRepAlgoAPI_BuilderAlgo() |
55 | { |
49b0c452 |
56 | Clear(); |
b1d15f53 |
57 | } |
58 | //======================================================================= |
3510db62 |
59 | //function : SetNonDestructive |
60 | //purpose : |
61 | //======================================================================= |
62 | void BRepAlgoAPI_BuilderAlgo::SetNonDestructive(const Standard_Boolean theFlag) |
63 | { |
64 | myNonDestructive = theFlag; |
65 | } |
66 | //======================================================================= |
67 | //function : NonDestructive |
68 | //purpose : |
69 | //======================================================================= |
70 | Standard_Boolean BRepAlgoAPI_BuilderAlgo::NonDestructive() const |
71 | { |
72 | return myNonDestructive; |
73 | } |
74 | //======================================================================= |
483ce1bd |
75 | //function : SetGlue |
76 | //purpose : |
77 | //======================================================================= |
78 | void BRepAlgoAPI_BuilderAlgo::SetGlue(const BOPAlgo_GlueEnum theGlue) |
79 | { |
80 | myGlue=theGlue; |
81 | } |
82 | //======================================================================= |
83 | //function : Glue |
84 | //purpose : |
85 | //======================================================================= |
86 | BOPAlgo_GlueEnum BRepAlgoAPI_BuilderAlgo::Glue() const |
87 | { |
88 | return myGlue; |
89 | } |
90 | //======================================================================= |
49b0c452 |
91 | //function : Clear |
92 | //purpose : |
93 | //======================================================================= |
94 | void BRepAlgoAPI_BuilderAlgo::Clear() |
95 | { |
33ba8565 |
96 | BRepAlgoAPI_Algo::Clear(); |
49b0c452 |
97 | if (myDSFiller && myEntryType) { |
98 | delete myDSFiller; |
99 | myDSFiller=NULL; |
100 | } |
101 | if (myBuilder) { |
102 | delete myBuilder; |
103 | myBuilder=NULL; |
104 | } |
105 | } |
106 | //======================================================================= |
107 | //function : SetArguments |
108 | //purpose : |
109 | //======================================================================= |
110 | void BRepAlgoAPI_BuilderAlgo::SetArguments |
111 | (const TopTools_ListOfShape& theLS) |
112 | { |
113 | myArguments=theLS; |
114 | } |
115 | //======================================================================= |
116 | //function : Arguments |
117 | //purpose : |
118 | //======================================================================= |
119 | const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Arguments()const |
120 | { |
121 | return myArguments; |
122 | } |
123 | //======================================================================= |
124 | //function : Build |
125 | //purpose : |
126 | //======================================================================= |
127 | void BRepAlgoAPI_BuilderAlgo::Build() |
128 | { |
49b0c452 |
129 | NotDone(); |
49b0c452 |
130 | // |
131 | Clear(); |
132 | // |
133 | if (myEntryType) { |
134 | if (myDSFiller) { |
135 | delete myDSFiller; |
136 | } |
137 | myDSFiller=new BOPAlgo_PaveFiller(myAllocator); |
138 | // |
139 | myDSFiller->SetArguments(myArguments); |
140 | // |
141 | myDSFiller->SetRunParallel(myRunParallel); |
142 | myDSFiller->SetProgressIndicator(myProgressIndicator); |
143 | myDSFiller->SetFuzzyValue(myFuzzyValue); |
3510db62 |
144 | myDSFiller->SetNonDestructive(myNonDestructive); |
483ce1bd |
145 | myDSFiller->SetGlue(myGlue); |
49b0c452 |
146 | // |
147 | myDSFiller->Perform(); |
33ba8565 |
148 | // |
149 | GetReport()->Merge (myDSFiller->GetReport()); |
150 | if (HasErrors()) |
151 | { |
152 | return; |
49b0c452 |
153 | } |
154 | }// if (myEntryType) { |
155 | // |
156 | if (myBuilder) { |
157 | delete myBuilder; |
33ba8565 |
158 | myBuilder = NULL; |
49b0c452 |
159 | } |
160 | myBuilder=new BOPAlgo_Builder(myAllocator); |
161 | // |
162 | myBuilder->SetArguments(myArguments); |
163 | // |
164 | myBuilder->SetRunParallel(myRunParallel); |
165 | myBuilder->SetProgressIndicator(myProgressIndicator); |
98b37659 |
166 | myBuilder->SetCheckInverted(myCheckInverted); |
49b0c452 |
167 | // |
168 | myBuilder->PerformWithFiller(*myDSFiller); |
33ba8565 |
169 | // |
170 | GetReport()->Merge (myBuilder->GetReport()); |
49b0c452 |
171 | // |
172 | Done(); |
173 | myShape=myBuilder->Shape(); |
174 | } |
175 | //======================================================================= |
176 | //function : Generated |
177 | //purpose : |
178 | //======================================================================= |
179 | const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Generated |
180 | (const TopoDS_Shape& aS) |
181 | { |
182 | if (myBuilder==NULL) { |
183 | myGenerated.Clear(); |
184 | return myGenerated; |
185 | } |
186 | myGenerated = myBuilder->Generated(aS); |
187 | return myGenerated; |
188 | } |
189 | //======================================================================= |
190 | //function : Modified |
191 | //purpose : |
192 | //======================================================================= |
193 | const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Modified |
194 | (const TopoDS_Shape& aS) |
195 | { |
196 | if (myBuilder==NULL) { |
197 | myGenerated.Clear(); |
198 | return myGenerated; |
199 | } |
200 | myGenerated = myBuilder->Modified(aS); |
201 | return myGenerated; |
202 | } |
203 | //======================================================================= |
204 | //function : IsDeleted |
205 | //purpose : |
206 | //======================================================================= |
207 | Standard_Boolean BRepAlgoAPI_BuilderAlgo::IsDeleted |
208 | (const TopoDS_Shape& aS) |
209 | { |
210 | Standard_Boolean bDeleted = Standard_True; |
211 | if (myBuilder != NULL) { |
212 | bDeleted=myBuilder->IsDeleted(aS); |
213 | } |
214 | return bDeleted; |
215 | } |
216 | //======================================================================= |
217 | //function : HasModified |
218 | //purpose : |
219 | //======================================================================= |
220 | Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasModified() const |
221 | { |
222 | if (myBuilder==NULL) { |
223 | return Standard_False; |
224 | } |
225 | return myBuilder->HasModified(); |
226 | } |
227 | //======================================================================= |
228 | //function : HasGenerated |
229 | //purpose : |
230 | //======================================================================= |
231 | Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasGenerated() const |
232 | { |
233 | if (myBuilder==NULL) { |
234 | return Standard_False; |
235 | } |
236 | return myBuilder->HasGenerated(); |
237 | } |
238 | //======================================================================= |
239 | //function : HasDeleted |
240 | //purpose : |
241 | //======================================================================= |
242 | Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasDeleted() const |
243 | { |
244 | if (myBuilder==NULL) { |
245 | return Standard_False; |
246 | } |
247 | return myBuilder->HasDeleted(); |
248 | } |