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; |
48 | }; |
49 | // |
50 | // Clear |
51 | void Clear() { |
52 | if (myPaveFiller) { |
53 | delete myPaveFiller; |
54 | myPaveFiller=NULL; |
55 | } |
56 | // |
57 | if (myBuilderDefault) { |
58 | delete myBuilderDefault; |
59 | myBuilderDefault=NULL; |
60 | } |
61 | }; |
62 | // |
63 | // IsValid |
64 | Standard_Boolean IsValid() const { |
65 | return (myPaveFiller!=NULL); |
66 | } |
67 | // PaveFiller |
68 | BOPAlgo_PaveFiller& PaveFiller() { |
69 | return *myPaveFiller; |
70 | }; |
71 | // |
72 | // Builder |
73 | BOPAlgo_Builder& Builder() { |
74 | return *myBuilder; |
75 | }; |
76 | // |
77 | // SetBuilder |
78 | void SetBuilder(BOPAlgo_Builder* pBuilder) { |
79 | myBuilder=pBuilder; |
80 | }; |
81 | // |
82 | // SetBuilderDef |
83 | void SetBuilderDefault() { |
84 | myBuilder=myBuilderDefault; |
85 | }; |
86 | // |
87 | protected: |
88 | // |
89 | BOPAlgo_PaveFiller* myPaveFiller; |
90 | BOPAlgo_Builder* myBuilder; |
91 | BOPAlgo_Builder* myBuilderDefault; |
92 | }; |
93 | // |
94 | //======================================================================= |
95 | //function : GetSession |
96 | //purpose : |
97 | //======================================================================= |
98 | static BOPTest_Session& GetSession() |
99 | { |
100 | static BOPTest_Session* pSession=new BOPTest_Session; |
101 | // |
102 | if (!pSession->IsValid()) { |
103 | pSession->Init(); |
104 | } |
105 | return *pSession; |
106 | } |
107 | // |
108 | //======================================================================= |
109 | //function : Init |
110 | //purpose : |
111 | //======================================================================= |
112 | void BOPTest_Objects::Init() |
113 | { |
114 | GetSession().Init(); |
115 | } |
116 | //======================================================================= |
117 | //function : Clear |
118 | //purpose : |
119 | //======================================================================= |
120 | void BOPTest_Objects::Clear() |
121 | { |
122 | GetSession().Clear(); |
2bc5e8f1 |
123 | // |
124 | //clear objects and tools |
125 | Shapes().Clear(); |
126 | Tools().Clear(); |
4e57c75e |
127 | } |
128 | //======================================================================= |
129 | //function : PaveFiller |
130 | //purpose : |
131 | //======================================================================= |
132 | BOPAlgo_PaveFiller& BOPTest_Objects::PaveFiller() |
133 | { |
134 | return GetSession().PaveFiller(); |
135 | } |
136 | //======================================================================= |
137 | //function : PDS |
138 | //purpose : |
139 | //======================================================================= |
140 | BOPDS_PDS BOPTest_Objects::PDS() |
141 | { |
142 | return BOPTest_Objects::PaveFiller().PDS(); |
143 | } |
144 | //======================================================================= |
145 | //function : Builder |
146 | //purpose : |
147 | //======================================================================= |
148 | BOPAlgo_Builder& BOPTest_Objects::Builder() |
149 | { |
150 | return GetSession().Builder(); |
151 | } |
152 | //======================================================================= |
153 | //function : SetBuilder |
154 | //purpose : |
155 | //======================================================================= |
156 | void BOPTest_Objects::SetBuilder(const BOPAlgo_PBuilder& theBuilder) |
157 | { |
158 | BOPAlgo_Builder* pB; |
159 | // |
160 | pB=(BOPAlgo_Builder*)theBuilder; |
161 | GetSession().SetBuilder(pB); |
162 | } |
163 | //======================================================================= |
164 | //function : SetBuilderDefault |
165 | //purpose : |
166 | //======================================================================= |
167 | void BOPTest_Objects::SetBuilderDefault() |
168 | { |
169 | GetSession().SetBuilderDefault(); |
170 | } |
171 | //======================================================================= |
172 | //function : BOP |
173 | //purpose : |
174 | //======================================================================= |
175 | BOPAlgo_BOP& BOPTest_Objects::BOP() |
176 | { |
177 | static BOPAlgo_BOP sBOP(Allocator1()); |
178 | return sBOP; |
179 | } |
180 | //======================================================================= |
181 | //function : Shapes |
182 | //purpose : |
183 | //======================================================================= |
184 | BOPCol_ListOfShape& BOPTest_Objects::Shapes() |
185 | { |
186 | static BOPCol_ListOfShape s_Shapes; |
187 | return s_Shapes; |
188 | } |
189 | //======================================================================= |
190 | //function : Tools |
191 | //purpose : |
192 | //======================================================================= |
193 | BOPCol_ListOfShape& BOPTest_Objects::Tools() |
194 | { |
195 | static BOPCol_ListOfShape s_Tools; |
196 | return s_Tools; |
197 | } |
198 | //======================================================================= |
199 | //function : Allocator1 |
200 | //purpose : |
201 | //======================================================================= |
202 | Handle(NCollection_BaseAllocator)& Allocator1() |
203 | { |
204 | static Handle(NCollection_BaseAllocator) sAL1= |
205 | new NCollection_IncAllocator; |
206 | return sAL1; |
207 | } |