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> |
4e57c75e |
22 | #include <NCollection_BaseAllocator.hxx> |
4e57c75e |
23 | |
24 | static Handle(NCollection_BaseAllocator)& Allocator1(); |
25 | |
26 | //======================================================================= |
27 | //function : BOPTest_Session |
28 | //purpose : |
29 | //======================================================================= |
30 | class BOPTest_Session { |
31 | public: |
32 | // |
33 | BOPTest_Session() { |
34 | Init(); |
35 | }; |
36 | // |
37 | ~BOPTest_Session(){ |
38 | Clear(); |
39 | }; |
40 | // |
41 | // Init |
42 | void Init() { |
43 | Handle(NCollection_BaseAllocator) pA1, pA2; |
44 | // |
488e5b9d |
45 | pA1=NCollection_BaseAllocator::CommonBaseAllocator(); |
46 | pA2=NCollection_BaseAllocator::CommonBaseAllocator(); |
4e57c75e |
47 | // |
48 | myPaveFiller=new BOPAlgo_PaveFiller(pA1); |
49 | myBuilderDefault=new BOPAlgo_Builder(pA2); |
50 | // |
51 | myBuilder=myBuilderDefault; |
49b0c452 |
52 | myRunParallel=Standard_False; |
53 | myFuzzyValue=0.; |
4e57c75e |
54 | }; |
55 | // |
56 | // Clear |
57 | void Clear() { |
58 | if (myPaveFiller) { |
59 | delete myPaveFiller; |
60 | myPaveFiller=NULL; |
61 | } |
62 | // |
63 | if (myBuilderDefault) { |
64 | delete myBuilderDefault; |
65 | myBuilderDefault=NULL; |
66 | } |
67 | }; |
68 | // |
69 | // IsValid |
70 | Standard_Boolean IsValid() const { |
71 | return (myPaveFiller!=NULL); |
72 | } |
73 | // PaveFiller |
74 | BOPAlgo_PaveFiller& PaveFiller() { |
75 | return *myPaveFiller; |
76 | }; |
77 | // |
78 | // Builder |
79 | BOPAlgo_Builder& Builder() { |
80 | return *myBuilder; |
81 | }; |
82 | // |
83 | // SetBuilder |
84 | void SetBuilder(BOPAlgo_Builder* pBuilder) { |
85 | myBuilder=pBuilder; |
86 | }; |
87 | // |
88 | // SetBuilderDef |
89 | void SetBuilderDefault() { |
90 | myBuilder=myBuilderDefault; |
91 | }; |
92 | // |
49b0c452 |
93 | BOPCol_ListOfShape& Shapes() { |
94 | return myShapes; |
95 | } |
96 | // |
97 | BOPCol_ListOfShape& Tools() { |
98 | return myTools; |
99 | } |
100 | // |
101 | void SetRunParallel(const Standard_Boolean bFlag) { |
102 | myRunParallel=bFlag; |
103 | }; |
104 | // |
105 | Standard_Boolean RunParallel()const { |
106 | return myRunParallel; |
107 | }; |
108 | // |
109 | void SetFuzzyValue(const Standard_Real aValue) { |
110 | myFuzzyValue=aValue; |
111 | }; |
112 | // |
113 | Standard_Real FuzzyValue()const { |
114 | return myFuzzyValue; |
115 | }; |
116 | // |
96f3bacc |
117 | protected: |
118 | // |
119 | BOPTest_Session(const BOPTest_Session&); |
120 | BOPTest_Session& operator=(const BOPTest_Session&); |
121 | // |
122 | protected: |
4e57c75e |
123 | // |
124 | BOPAlgo_PaveFiller* myPaveFiller; |
125 | BOPAlgo_Builder* myBuilder; |
126 | BOPAlgo_Builder* myBuilderDefault; |
49b0c452 |
127 | // |
128 | BOPCol_ListOfShape myShapes; |
129 | BOPCol_ListOfShape myTools; |
130 | Standard_Boolean myRunParallel; |
131 | Standard_Real myFuzzyValue; |
4e57c75e |
132 | }; |
133 | // |
134 | //======================================================================= |
135 | //function : GetSession |
136 | //purpose : |
137 | //======================================================================= |
138 | static BOPTest_Session& GetSession() |
139 | { |
140 | static BOPTest_Session* pSession=new BOPTest_Session; |
141 | // |
142 | if (!pSession->IsValid()) { |
143 | pSession->Init(); |
144 | } |
145 | return *pSession; |
146 | } |
147 | // |
148 | //======================================================================= |
149 | //function : Init |
150 | //purpose : |
151 | //======================================================================= |
152 | void BOPTest_Objects::Init() |
153 | { |
154 | GetSession().Init(); |
155 | } |
156 | //======================================================================= |
157 | //function : Clear |
158 | //purpose : |
159 | //======================================================================= |
160 | void BOPTest_Objects::Clear() |
161 | { |
162 | GetSession().Clear(); |
2bc5e8f1 |
163 | Shapes().Clear(); |
164 | Tools().Clear(); |
4e57c75e |
165 | } |
166 | //======================================================================= |
167 | //function : PaveFiller |
168 | //purpose : |
169 | //======================================================================= |
170 | BOPAlgo_PaveFiller& BOPTest_Objects::PaveFiller() |
171 | { |
172 | return GetSession().PaveFiller(); |
173 | } |
174 | //======================================================================= |
175 | //function : PDS |
176 | //purpose : |
177 | //======================================================================= |
178 | BOPDS_PDS BOPTest_Objects::PDS() |
179 | { |
180 | return BOPTest_Objects::PaveFiller().PDS(); |
181 | } |
182 | //======================================================================= |
183 | //function : Builder |
184 | //purpose : |
185 | //======================================================================= |
186 | BOPAlgo_Builder& BOPTest_Objects::Builder() |
187 | { |
188 | return GetSession().Builder(); |
189 | } |
190 | //======================================================================= |
191 | //function : SetBuilder |
192 | //purpose : |
193 | //======================================================================= |
194 | void BOPTest_Objects::SetBuilder(const BOPAlgo_PBuilder& theBuilder) |
195 | { |
196 | BOPAlgo_Builder* pB; |
197 | // |
198 | pB=(BOPAlgo_Builder*)theBuilder; |
199 | GetSession().SetBuilder(pB); |
200 | } |
201 | //======================================================================= |
202 | //function : SetBuilderDefault |
203 | //purpose : |
204 | //======================================================================= |
205 | void BOPTest_Objects::SetBuilderDefault() |
206 | { |
207 | GetSession().SetBuilderDefault(); |
208 | } |
209 | //======================================================================= |
210 | //function : BOP |
211 | //purpose : |
212 | //======================================================================= |
213 | BOPAlgo_BOP& BOPTest_Objects::BOP() |
214 | { |
215 | static BOPAlgo_BOP sBOP(Allocator1()); |
216 | return sBOP; |
217 | } |
218 | //======================================================================= |
85915310 |
219 | //function : Section |
220 | //purpose : |
221 | //======================================================================= |
222 | BOPAlgo_Section& BOPTest_Objects::Section() |
223 | { |
224 | static BOPAlgo_Section sSection(Allocator1()); |
225 | return sSection; |
226 | } |
227 | //======================================================================= |
338434c7 |
228 | //function : CellsBuilder |
229 | //purpose : |
230 | //======================================================================= |
231 | BOPAlgo_CellsBuilder& BOPTest_Objects::CellsBuilder() |
232 | { |
233 | static BOPAlgo_CellsBuilder sCBuilder(Allocator1()); |
234 | return sCBuilder; |
235 | } |
236 | //======================================================================= |
4e57c75e |
237 | //function : Shapes |
238 | //purpose : |
239 | //======================================================================= |
240 | BOPCol_ListOfShape& BOPTest_Objects::Shapes() |
241 | { |
49b0c452 |
242 | return GetSession().Shapes(); |
4e57c75e |
243 | } |
244 | //======================================================================= |
245 | //function : Tools |
246 | //purpose : |
247 | //======================================================================= |
248 | BOPCol_ListOfShape& BOPTest_Objects::Tools() |
249 | { |
49b0c452 |
250 | return GetSession().Tools(); |
251 | } |
252 | //======================================================================= |
253 | //function : SetRunParallel |
254 | //purpose : |
255 | //======================================================================= |
256 | void BOPTest_Objects::SetRunParallel(const Standard_Boolean bFlag) |
257 | { |
258 | GetSession().SetRunParallel(bFlag); |
259 | } |
260 | //======================================================================= |
261 | //function : RunParallel |
262 | //purpose : |
263 | //======================================================================= |
264 | Standard_Boolean BOPTest_Objects::RunParallel() |
265 | { |
266 | return GetSession().RunParallel(); |
267 | } |
268 | //======================================================================= |
269 | //function : SetFuzzyValue |
270 | //purpose : |
271 | //======================================================================= |
272 | void BOPTest_Objects::SetFuzzyValue(const Standard_Real aValue) |
273 | { |
274 | GetSession().SetFuzzyValue(aValue); |
275 | } |
276 | //======================================================================= |
277 | //function : FuzzyValue |
278 | //purpose : |
279 | //======================================================================= |
280 | Standard_Real BOPTest_Objects::FuzzyValue() |
281 | { |
282 | return GetSession().FuzzyValue(); |
4e57c75e |
283 | } |
284 | //======================================================================= |
285 | //function : Allocator1 |
286 | //purpose : |
287 | //======================================================================= |
288 | Handle(NCollection_BaseAllocator)& Allocator1() |
289 | { |
290 | static Handle(NCollection_BaseAllocator) sAL1= |
488e5b9d |
291 | NCollection_BaseAllocator::CommonBaseAllocator(); |
4e57c75e |
292 | return sAL1; |
293 | } |