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