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