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> |
4e57c75e |
24 | |
25 | static Handle(NCollection_BaseAllocator)& Allocator1(); |
26 | |
27 | //======================================================================= |
28 | //function : BOPTest_Session |
29 | //purpose : |
30 | //======================================================================= |
31 | class BOPTest_Session { |
32 | public: |
33 | // |
34 | BOPTest_Session() { |
35 | Init(); |
36 | }; |
37 | // |
38 | ~BOPTest_Session(){ |
39 | Clear(); |
40 | }; |
41 | // |
42 | // Init |
43 | void Init() { |
44 | Handle(NCollection_BaseAllocator) pA1, pA2; |
45 | // |
488e5b9d |
46 | pA1=NCollection_BaseAllocator::CommonBaseAllocator(); |
47 | pA2=NCollection_BaseAllocator::CommonBaseAllocator(); |
4e57c75e |
48 | // |
49 | myPaveFiller=new BOPAlgo_PaveFiller(pA1); |
50 | myBuilderDefault=new BOPAlgo_Builder(pA2); |
51 | // |
52 | myBuilder=myBuilderDefault; |
49b0c452 |
53 | myRunParallel=Standard_False; |
3510db62 |
54 | myNonDestructive = Standard_False; |
55 | myFuzzyValue = 0.; |
483ce1bd |
56 | myGlue = BOPAlgo_GlueOff; |
33ba8565 |
57 | myDrawWarnShapes = Standard_False; |
4e57c75e |
58 | }; |
59 | // |
60 | // Clear |
61 | void Clear() { |
62 | if (myPaveFiller) { |
63 | delete myPaveFiller; |
64 | myPaveFiller=NULL; |
65 | } |
66 | // |
67 | if (myBuilderDefault) { |
68 | delete myBuilderDefault; |
69 | myBuilderDefault=NULL; |
70 | } |
71 | }; |
72 | // |
73 | // IsValid |
74 | Standard_Boolean IsValid() const { |
75 | return (myPaveFiller!=NULL); |
76 | } |
77 | // PaveFiller |
78 | BOPAlgo_PaveFiller& PaveFiller() { |
79 | return *myPaveFiller; |
80 | }; |
81 | // |
82 | // Builder |
83 | BOPAlgo_Builder& Builder() { |
84 | return *myBuilder; |
85 | }; |
86 | // |
87 | // SetBuilder |
88 | void SetBuilder(BOPAlgo_Builder* pBuilder) { |
89 | myBuilder=pBuilder; |
90 | }; |
91 | // |
92 | // SetBuilderDef |
93 | void SetBuilderDefault() { |
94 | myBuilder=myBuilderDefault; |
95 | }; |
96 | // |
49b0c452 |
97 | BOPCol_ListOfShape& Shapes() { |
98 | return myShapes; |
99 | } |
100 | // |
101 | BOPCol_ListOfShape& Tools() { |
102 | return myTools; |
103 | } |
104 | // |
105 | void SetRunParallel(const Standard_Boolean bFlag) { |
106 | myRunParallel=bFlag; |
107 | }; |
108 | // |
109 | Standard_Boolean RunParallel()const { |
110 | return myRunParallel; |
111 | }; |
112 | // |
113 | void SetFuzzyValue(const Standard_Real aValue) { |
114 | myFuzzyValue=aValue; |
115 | }; |
116 | // |
117 | Standard_Real FuzzyValue()const { |
118 | return myFuzzyValue; |
119 | }; |
120 | // |
3510db62 |
121 | void SetNonDestructive(const Standard_Boolean theFlag) { |
122 | myNonDestructive = theFlag; |
123 | }; |
124 | // |
125 | Standard_Boolean NonDestructive()const { |
126 | return myNonDestructive; |
127 | }; |
128 | // |
483ce1bd |
129 | void SetGlue(const BOPAlgo_GlueEnum theGlue) { |
130 | myGlue = theGlue; |
131 | }; |
132 | // |
133 | BOPAlgo_GlueEnum Glue() const { |
134 | return myGlue; |
135 | }; |
136 | // |
33ba8565 |
137 | void SetDrawWarnShapes(const Standard_Boolean bDraw) { |
138 | myDrawWarnShapes = bDraw; |
139 | }; |
140 | // |
141 | Standard_Boolean DrawWarnShapes() const { |
142 | return myDrawWarnShapes; |
143 | }; |
144 | // |
96f3bacc |
145 | protected: |
146 | // |
147 | BOPTest_Session(const BOPTest_Session&); |
148 | BOPTest_Session& operator=(const BOPTest_Session&); |
149 | // |
150 | protected: |
4e57c75e |
151 | // |
152 | BOPAlgo_PaveFiller* myPaveFiller; |
153 | BOPAlgo_Builder* myBuilder; |
154 | BOPAlgo_Builder* myBuilderDefault; |
49b0c452 |
155 | // |
156 | BOPCol_ListOfShape myShapes; |
157 | BOPCol_ListOfShape myTools; |
158 | Standard_Boolean myRunParallel; |
3510db62 |
159 | Standard_Boolean myNonDestructive; |
49b0c452 |
160 | Standard_Real myFuzzyValue; |
483ce1bd |
161 | BOPAlgo_GlueEnum myGlue; |
33ba8565 |
162 | Standard_Boolean myDrawWarnShapes; |
4e57c75e |
163 | }; |
164 | // |
165 | //======================================================================= |
166 | //function : GetSession |
167 | //purpose : |
168 | //======================================================================= |
169 | static BOPTest_Session& GetSession() |
170 | { |
171 | static BOPTest_Session* pSession=new BOPTest_Session; |
172 | // |
173 | if (!pSession->IsValid()) { |
174 | pSession->Init(); |
175 | } |
176 | return *pSession; |
177 | } |
178 | // |
179 | //======================================================================= |
180 | //function : Init |
181 | //purpose : |
182 | //======================================================================= |
183 | void BOPTest_Objects::Init() |
184 | { |
185 | GetSession().Init(); |
186 | } |
187 | //======================================================================= |
188 | //function : Clear |
189 | //purpose : |
190 | //======================================================================= |
191 | void BOPTest_Objects::Clear() |
192 | { |
193 | GetSession().Clear(); |
2bc5e8f1 |
194 | Shapes().Clear(); |
195 | Tools().Clear(); |
4e57c75e |
196 | } |
197 | //======================================================================= |
198 | //function : PaveFiller |
199 | //purpose : |
200 | //======================================================================= |
201 | BOPAlgo_PaveFiller& BOPTest_Objects::PaveFiller() |
202 | { |
203 | return GetSession().PaveFiller(); |
204 | } |
205 | //======================================================================= |
206 | //function : PDS |
207 | //purpose : |
208 | //======================================================================= |
209 | BOPDS_PDS BOPTest_Objects::PDS() |
210 | { |
211 | return BOPTest_Objects::PaveFiller().PDS(); |
212 | } |
213 | //======================================================================= |
214 | //function : Builder |
215 | //purpose : |
216 | //======================================================================= |
217 | BOPAlgo_Builder& BOPTest_Objects::Builder() |
218 | { |
219 | return GetSession().Builder(); |
220 | } |
221 | //======================================================================= |
222 | //function : SetBuilder |
223 | //purpose : |
224 | //======================================================================= |
225 | void BOPTest_Objects::SetBuilder(const BOPAlgo_PBuilder& theBuilder) |
226 | { |
227 | BOPAlgo_Builder* pB; |
228 | // |
229 | pB=(BOPAlgo_Builder*)theBuilder; |
230 | GetSession().SetBuilder(pB); |
231 | } |
232 | //======================================================================= |
233 | //function : SetBuilderDefault |
234 | //purpose : |
235 | //======================================================================= |
236 | void BOPTest_Objects::SetBuilderDefault() |
237 | { |
238 | GetSession().SetBuilderDefault(); |
239 | } |
240 | //======================================================================= |
241 | //function : BOP |
242 | //purpose : |
243 | //======================================================================= |
244 | BOPAlgo_BOP& BOPTest_Objects::BOP() |
245 | { |
246 | static BOPAlgo_BOP sBOP(Allocator1()); |
247 | return sBOP; |
248 | } |
249 | //======================================================================= |
85915310 |
250 | //function : Section |
251 | //purpose : |
252 | //======================================================================= |
253 | BOPAlgo_Section& BOPTest_Objects::Section() |
254 | { |
255 | static BOPAlgo_Section sSection(Allocator1()); |
256 | return sSection; |
257 | } |
258 | //======================================================================= |
338434c7 |
259 | //function : CellsBuilder |
260 | //purpose : |
261 | //======================================================================= |
262 | BOPAlgo_CellsBuilder& BOPTest_Objects::CellsBuilder() |
263 | { |
264 | static BOPAlgo_CellsBuilder sCBuilder(Allocator1()); |
265 | return sCBuilder; |
266 | } |
267 | //======================================================================= |
c58055ad |
268 | //function : Splitter |
269 | //purpose : |
270 | //======================================================================= |
271 | BOPAlgo_Splitter& BOPTest_Objects::Splitter() |
272 | { |
273 | static BOPAlgo_Splitter aSplitter(Allocator1()); |
274 | return aSplitter; |
275 | } |
276 | //======================================================================= |
4e57c75e |
277 | //function : Shapes |
278 | //purpose : |
279 | //======================================================================= |
280 | BOPCol_ListOfShape& BOPTest_Objects::Shapes() |
281 | { |
49b0c452 |
282 | return GetSession().Shapes(); |
4e57c75e |
283 | } |
284 | //======================================================================= |
285 | //function : Tools |
286 | //purpose : |
287 | //======================================================================= |
288 | BOPCol_ListOfShape& BOPTest_Objects::Tools() |
289 | { |
49b0c452 |
290 | return GetSession().Tools(); |
291 | } |
292 | //======================================================================= |
293 | //function : SetRunParallel |
294 | //purpose : |
295 | //======================================================================= |
296 | void BOPTest_Objects::SetRunParallel(const Standard_Boolean bFlag) |
297 | { |
298 | GetSession().SetRunParallel(bFlag); |
299 | } |
300 | //======================================================================= |
301 | //function : RunParallel |
302 | //purpose : |
303 | //======================================================================= |
304 | Standard_Boolean BOPTest_Objects::RunParallel() |
305 | { |
306 | return GetSession().RunParallel(); |
307 | } |
308 | //======================================================================= |
309 | //function : SetFuzzyValue |
310 | //purpose : |
311 | //======================================================================= |
312 | void BOPTest_Objects::SetFuzzyValue(const Standard_Real aValue) |
313 | { |
314 | GetSession().SetFuzzyValue(aValue); |
315 | } |
316 | //======================================================================= |
317 | //function : FuzzyValue |
318 | //purpose : |
319 | //======================================================================= |
320 | Standard_Real BOPTest_Objects::FuzzyValue() |
321 | { |
322 | return GetSession().FuzzyValue(); |
4e57c75e |
323 | } |
324 | //======================================================================= |
3510db62 |
325 | //function : SetNonDestructive |
326 | //purpose : |
327 | //======================================================================= |
328 | void BOPTest_Objects::SetNonDestructive(const Standard_Boolean theFlag) |
329 | { |
330 | GetSession().SetNonDestructive(theFlag); |
331 | } |
332 | //======================================================================= |
333 | //function : NonDestructive |
334 | //purpose : |
335 | //======================================================================= |
336 | Standard_Boolean BOPTest_Objects::NonDestructive() |
337 | { |
338 | return GetSession().NonDestructive(); |
339 | } |
340 | //======================================================================= |
483ce1bd |
341 | //function : SetGlue |
342 | //purpose : |
343 | //======================================================================= |
344 | void BOPTest_Objects::SetGlue(const BOPAlgo_GlueEnum theGlue) |
345 | { |
346 | GetSession().SetGlue(theGlue); |
347 | } |
348 | //======================================================================= |
349 | //function : Glue |
350 | //purpose : |
351 | //======================================================================= |
352 | BOPAlgo_GlueEnum BOPTest_Objects::Glue() |
353 | { |
354 | return GetSession().Glue(); |
355 | } |
356 | //======================================================================= |
33ba8565 |
357 | //function : SetDrawWarnShapes |
358 | //purpose : |
359 | //======================================================================= |
360 | void BOPTest_Objects::SetDrawWarnShapes(const Standard_Boolean bDraw) |
361 | { |
362 | GetSession().SetDrawWarnShapes(bDraw); |
363 | } |
364 | //======================================================================= |
365 | //function : DrawWarnShapes |
366 | //purpose : |
367 | //======================================================================= |
368 | Standard_Boolean BOPTest_Objects::DrawWarnShapes() |
369 | { |
370 | return GetSession().DrawWarnShapes(); |
371 | } |
372 | //======================================================================= |
4e57c75e |
373 | //function : Allocator1 |
374 | //purpose : |
375 | //======================================================================= |
376 | Handle(NCollection_BaseAllocator)& Allocator1() |
377 | { |
378 | static Handle(NCollection_BaseAllocator) sAL1= |
488e5b9d |
379 | NCollection_BaseAllocator::CommonBaseAllocator(); |
4e57c75e |
380 | return sAL1; |
381 | } |