4e57c75e |
1 | // Created by: Peter KURNEV |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
4e57c75e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
4e57c75e |
5 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
4e57c75e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
4e57c75e |
14 | |
4e57c75e |
15 | |
42cf5bc1 |
16 | #include <BOPAlgo_BOP.hxx> |
17 | #include <BOPAlgo_Builder.hxx> |
18 | #include <BOPAlgo_PaveFiller.hxx> |
19 | #include <BOPAlgo_Section.hxx> |
20 | #include <BOPTest_Objects.hxx> |
338434c7 |
21 | #include <BOPAlgo_CellsBuilder.hxx> |
c58055ad |
22 | #include <BOPAlgo_Splitter.hxx> |
4e57c75e |
23 | #include <NCollection_BaseAllocator.hxx> |
944768d2 |
24 | #include <Precision.hxx> |
4e57c75e |
25 | |
26 | static Handle(NCollection_BaseAllocator)& Allocator1(); |
27 | |
28 | //======================================================================= |
29 | //function : BOPTest_Session |
30 | //purpose : |
31 | //======================================================================= |
32 | class BOPTest_Session { |
33 | public: |
34 | // |
35 | BOPTest_Session() { |
36 | Init(); |
37 | }; |
38 | // |
39 | ~BOPTest_Session(){ |
40 | Clear(); |
41 | }; |
42 | // |
43 | // Init |
44 | void Init() { |
45 | Handle(NCollection_BaseAllocator) pA1, pA2; |
46 | // |
488e5b9d |
47 | pA1=NCollection_BaseAllocator::CommonBaseAllocator(); |
48 | pA2=NCollection_BaseAllocator::CommonBaseAllocator(); |
4e57c75e |
49 | // |
50 | myPaveFiller=new BOPAlgo_PaveFiller(pA1); |
51 | myBuilderDefault=new BOPAlgo_Builder(pA2); |
52 | // |
53 | myBuilder=myBuilderDefault; |
49b0c452 |
54 | myRunParallel=Standard_False; |
3510db62 |
55 | myNonDestructive = Standard_False; |
944768d2 |
56 | myFuzzyValue = Precision::Confusion(); |
483ce1bd |
57 | myGlue = BOPAlgo_GlueOff; |
33ba8565 |
58 | myDrawWarnShapes = Standard_False; |
98b37659 |
59 | myCheckInverted = Standard_True; |
944768d2 |
60 | myUseOBB = Standard_False; |
4e57c75e |
61 | }; |
62 | // |
63 | // Clear |
64 | void Clear() { |
65 | if (myPaveFiller) { |
66 | delete myPaveFiller; |
67 | myPaveFiller=NULL; |
68 | } |
69 | // |
70 | if (myBuilderDefault) { |
71 | delete myBuilderDefault; |
72 | myBuilderDefault=NULL; |
73 | } |
74 | }; |
75 | // |
76 | // IsValid |
77 | Standard_Boolean IsValid() const { |
78 | return (myPaveFiller!=NULL); |
79 | } |
80 | // PaveFiller |
81 | BOPAlgo_PaveFiller& PaveFiller() { |
82 | return *myPaveFiller; |
83 | }; |
84 | // |
85 | // Builder |
86 | BOPAlgo_Builder& Builder() { |
87 | return *myBuilder; |
88 | }; |
89 | // |
90 | // SetBuilder |
91 | void SetBuilder(BOPAlgo_Builder* pBuilder) { |
92 | myBuilder=pBuilder; |
93 | }; |
94 | // |
95 | // SetBuilderDef |
96 | void SetBuilderDefault() { |
97 | myBuilder=myBuilderDefault; |
98 | }; |
99 | // |
1155d05a |
100 | TopTools_ListOfShape& Shapes() { |
49b0c452 |
101 | return myShapes; |
102 | } |
103 | // |
1155d05a |
104 | TopTools_ListOfShape& Tools() { |
49b0c452 |
105 | return myTools; |
106 | } |
107 | // |
108 | void SetRunParallel(const Standard_Boolean bFlag) { |
109 | myRunParallel=bFlag; |
110 | }; |
111 | // |
112 | Standard_Boolean RunParallel()const { |
113 | return myRunParallel; |
114 | }; |
115 | // |
116 | void SetFuzzyValue(const Standard_Real aValue) { |
117 | myFuzzyValue=aValue; |
118 | }; |
119 | // |
120 | Standard_Real FuzzyValue()const { |
121 | return myFuzzyValue; |
122 | }; |
123 | // |
3510db62 |
124 | void SetNonDestructive(const Standard_Boolean theFlag) { |
125 | myNonDestructive = theFlag; |
126 | }; |
127 | // |
128 | Standard_Boolean NonDestructive()const { |
129 | return myNonDestructive; |
130 | }; |
131 | // |
483ce1bd |
132 | void SetGlue(const BOPAlgo_GlueEnum theGlue) { |
133 | myGlue = theGlue; |
134 | }; |
135 | // |
136 | BOPAlgo_GlueEnum Glue() const { |
137 | return myGlue; |
138 | }; |
139 | // |
33ba8565 |
140 | void SetDrawWarnShapes(const Standard_Boolean bDraw) { |
141 | myDrawWarnShapes = bDraw; |
142 | }; |
143 | // |
144 | Standard_Boolean DrawWarnShapes() const { |
145 | return myDrawWarnShapes; |
146 | }; |
147 | // |
98b37659 |
148 | void SetCheckInverted(const Standard_Boolean bCheck) { |
149 | myCheckInverted = bCheck; |
150 | }; |
151 | // |
152 | Standard_Boolean CheckInverted() const { |
153 | return myCheckInverted; |
154 | }; |
155 | // |
944768d2 |
156 | void SetUseOBB(const Standard_Boolean bUse) { |
157 | myUseOBB = bUse; |
158 | }; |
159 | // |
160 | Standard_Boolean UseOBB() const { |
161 | return myUseOBB; |
162 | }; |
96f3bacc |
163 | protected: |
164 | // |
165 | BOPTest_Session(const BOPTest_Session&); |
166 | BOPTest_Session& operator=(const BOPTest_Session&); |
167 | // |
168 | protected: |
4e57c75e |
169 | // |
170 | BOPAlgo_PaveFiller* myPaveFiller; |
171 | BOPAlgo_Builder* myBuilder; |
172 | BOPAlgo_Builder* myBuilderDefault; |
49b0c452 |
173 | // |
1155d05a |
174 | TopTools_ListOfShape myShapes; |
175 | TopTools_ListOfShape myTools; |
49b0c452 |
176 | Standard_Boolean myRunParallel; |
3510db62 |
177 | Standard_Boolean myNonDestructive; |
49b0c452 |
178 | Standard_Real myFuzzyValue; |
483ce1bd |
179 | BOPAlgo_GlueEnum myGlue; |
33ba8565 |
180 | Standard_Boolean myDrawWarnShapes; |
98b37659 |
181 | Standard_Boolean myCheckInverted; |
944768d2 |
182 | Standard_Boolean myUseOBB; |
4e57c75e |
183 | }; |
184 | // |
185 | //======================================================================= |
186 | //function : GetSession |
187 | //purpose : |
188 | //======================================================================= |
189 | static BOPTest_Session& GetSession() |
190 | { |
191 | static BOPTest_Session* pSession=new BOPTest_Session; |
192 | // |
193 | if (!pSession->IsValid()) { |
194 | pSession->Init(); |
195 | } |
196 | return *pSession; |
197 | } |
198 | // |
199 | //======================================================================= |
200 | //function : Init |
201 | //purpose : |
202 | //======================================================================= |
203 | void BOPTest_Objects::Init() |
204 | { |
205 | GetSession().Init(); |
206 | } |
207 | //======================================================================= |
208 | //function : Clear |
209 | //purpose : |
210 | //======================================================================= |
211 | void BOPTest_Objects::Clear() |
212 | { |
213 | GetSession().Clear(); |
2bc5e8f1 |
214 | Shapes().Clear(); |
215 | Tools().Clear(); |
4e57c75e |
216 | } |
217 | //======================================================================= |
218 | //function : PaveFiller |
219 | //purpose : |
220 | //======================================================================= |
221 | BOPAlgo_PaveFiller& BOPTest_Objects::PaveFiller() |
222 | { |
223 | return GetSession().PaveFiller(); |
224 | } |
225 | //======================================================================= |
226 | //function : PDS |
227 | //purpose : |
228 | //======================================================================= |
229 | BOPDS_PDS BOPTest_Objects::PDS() |
230 | { |
231 | return BOPTest_Objects::PaveFiller().PDS(); |
232 | } |
233 | //======================================================================= |
234 | //function : Builder |
235 | //purpose : |
236 | //======================================================================= |
237 | BOPAlgo_Builder& BOPTest_Objects::Builder() |
238 | { |
239 | return GetSession().Builder(); |
240 | } |
241 | //======================================================================= |
242 | //function : SetBuilder |
243 | //purpose : |
244 | //======================================================================= |
245 | void BOPTest_Objects::SetBuilder(const BOPAlgo_PBuilder& theBuilder) |
246 | { |
247 | BOPAlgo_Builder* pB; |
248 | // |
249 | pB=(BOPAlgo_Builder*)theBuilder; |
250 | GetSession().SetBuilder(pB); |
251 | } |
252 | //======================================================================= |
253 | //function : SetBuilderDefault |
254 | //purpose : |
255 | //======================================================================= |
256 | void BOPTest_Objects::SetBuilderDefault() |
257 | { |
258 | GetSession().SetBuilderDefault(); |
259 | } |
260 | //======================================================================= |
261 | //function : BOP |
262 | //purpose : |
263 | //======================================================================= |
264 | BOPAlgo_BOP& BOPTest_Objects::BOP() |
265 | { |
266 | static BOPAlgo_BOP sBOP(Allocator1()); |
267 | return sBOP; |
268 | } |
269 | //======================================================================= |
85915310 |
270 | //function : Section |
271 | //purpose : |
272 | //======================================================================= |
273 | BOPAlgo_Section& BOPTest_Objects::Section() |
274 | { |
275 | static BOPAlgo_Section sSection(Allocator1()); |
276 | return sSection; |
277 | } |
278 | //======================================================================= |
338434c7 |
279 | //function : CellsBuilder |
280 | //purpose : |
281 | //======================================================================= |
282 | BOPAlgo_CellsBuilder& BOPTest_Objects::CellsBuilder() |
283 | { |
284 | static BOPAlgo_CellsBuilder sCBuilder(Allocator1()); |
285 | return sCBuilder; |
286 | } |
287 | //======================================================================= |
c58055ad |
288 | //function : Splitter |
289 | //purpose : |
290 | //======================================================================= |
291 | BOPAlgo_Splitter& BOPTest_Objects::Splitter() |
292 | { |
293 | static BOPAlgo_Splitter aSplitter(Allocator1()); |
294 | return aSplitter; |
295 | } |
296 | //======================================================================= |
4e57c75e |
297 | //function : Shapes |
298 | //purpose : |
299 | //======================================================================= |
1155d05a |
300 | TopTools_ListOfShape& BOPTest_Objects::Shapes() |
4e57c75e |
301 | { |
49b0c452 |
302 | return GetSession().Shapes(); |
4e57c75e |
303 | } |
304 | //======================================================================= |
305 | //function : Tools |
306 | //purpose : |
307 | //======================================================================= |
1155d05a |
308 | TopTools_ListOfShape& BOPTest_Objects::Tools() |
4e57c75e |
309 | { |
49b0c452 |
310 | return GetSession().Tools(); |
311 | } |
312 | //======================================================================= |
313 | //function : SetRunParallel |
314 | //purpose : |
315 | //======================================================================= |
316 | void BOPTest_Objects::SetRunParallel(const Standard_Boolean bFlag) |
317 | { |
318 | GetSession().SetRunParallel(bFlag); |
319 | } |
320 | //======================================================================= |
321 | //function : RunParallel |
322 | //purpose : |
323 | //======================================================================= |
324 | Standard_Boolean BOPTest_Objects::RunParallel() |
325 | { |
326 | return GetSession().RunParallel(); |
327 | } |
328 | //======================================================================= |
329 | //function : SetFuzzyValue |
330 | //purpose : |
331 | //======================================================================= |
332 | void BOPTest_Objects::SetFuzzyValue(const Standard_Real aValue) |
333 | { |
334 | GetSession().SetFuzzyValue(aValue); |
335 | } |
336 | //======================================================================= |
337 | //function : FuzzyValue |
338 | //purpose : |
339 | //======================================================================= |
340 | Standard_Real BOPTest_Objects::FuzzyValue() |
341 | { |
342 | return GetSession().FuzzyValue(); |
4e57c75e |
343 | } |
344 | //======================================================================= |
3510db62 |
345 | //function : SetNonDestructive |
346 | //purpose : |
347 | //======================================================================= |
348 | void BOPTest_Objects::SetNonDestructive(const Standard_Boolean theFlag) |
349 | { |
350 | GetSession().SetNonDestructive(theFlag); |
351 | } |
352 | //======================================================================= |
353 | //function : NonDestructive |
354 | //purpose : |
355 | //======================================================================= |
356 | Standard_Boolean BOPTest_Objects::NonDestructive() |
357 | { |
358 | return GetSession().NonDestructive(); |
359 | } |
360 | //======================================================================= |
483ce1bd |
361 | //function : SetGlue |
362 | //purpose : |
363 | //======================================================================= |
364 | void BOPTest_Objects::SetGlue(const BOPAlgo_GlueEnum theGlue) |
365 | { |
366 | GetSession().SetGlue(theGlue); |
367 | } |
368 | //======================================================================= |
369 | //function : Glue |
370 | //purpose : |
371 | //======================================================================= |
372 | BOPAlgo_GlueEnum BOPTest_Objects::Glue() |
373 | { |
374 | return GetSession().Glue(); |
375 | } |
376 | //======================================================================= |
33ba8565 |
377 | //function : SetDrawWarnShapes |
378 | //purpose : |
379 | //======================================================================= |
380 | void BOPTest_Objects::SetDrawWarnShapes(const Standard_Boolean bDraw) |
381 | { |
382 | GetSession().SetDrawWarnShapes(bDraw); |
383 | } |
384 | //======================================================================= |
385 | //function : DrawWarnShapes |
386 | //purpose : |
387 | //======================================================================= |
388 | Standard_Boolean BOPTest_Objects::DrawWarnShapes() |
389 | { |
390 | return GetSession().DrawWarnShapes(); |
391 | } |
392 | //======================================================================= |
98b37659 |
393 | //function : SetCheckInverted |
394 | //purpose : |
395 | //======================================================================= |
396 | void BOPTest_Objects::SetCheckInverted(const Standard_Boolean bCheck) |
397 | { |
398 | GetSession().SetCheckInverted(bCheck); |
399 | } |
400 | //======================================================================= |
401 | //function : CheckInverted |
402 | //purpose : |
403 | //======================================================================= |
404 | Standard_Boolean BOPTest_Objects::CheckInverted() |
405 | { |
406 | return GetSession().CheckInverted(); |
407 | } |
408 | //======================================================================= |
944768d2 |
409 | //function : SetUseOBB |
410 | //purpose : |
411 | //======================================================================= |
412 | void BOPTest_Objects::SetUseOBB(const Standard_Boolean bUseOBB) |
413 | { |
414 | GetSession().SetUseOBB(bUseOBB); |
415 | } |
416 | //======================================================================= |
417 | //function : UseOBB |
418 | //purpose : |
419 | //======================================================================= |
420 | Standard_Boolean BOPTest_Objects::UseOBB() |
421 | { |
422 | return GetSession().UseOBB(); |
423 | } |
424 | //======================================================================= |
4e57c75e |
425 | //function : Allocator1 |
426 | //purpose : |
427 | //======================================================================= |
428 | Handle(NCollection_BaseAllocator)& Allocator1() |
429 | { |
430 | static Handle(NCollection_BaseAllocator) sAL1= |
488e5b9d |
431 | NCollection_BaseAllocator::CommonBaseAllocator(); |
4e57c75e |
432 | return sAL1; |
433 | } |