ff205346 |
1 | // Copyright (c) 2015 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | |
15 | #ifndef _StdObject_gp_HeaderFile |
16 | #define _StdObject_gp_HeaderFile |
17 | |
18 | #include <StdObjMgt_ContentTypes.hxx> |
19 | |
20 | class StdObject_gp : private StdObjMgt_ContentTypes |
21 | { |
22 | template <class Data> |
23 | struct object : Data |
24 | { Standard_EXPORT void Read (StdObjMgt_ReadData& theReadData); }; |
25 | |
26 | public: |
27 | template <class Data> |
28 | struct Object : StdObjMgt_ContentTypes::Object <object<Data> > {}; |
29 | |
30 | template <class Data> |
31 | static Object<Data>& Ref (Data& theData) |
32 | { return static_cast<Object<Data>&> (theData); } |
33 | }; |
34 | |
35 | // read vectors |
36 | |
37 | #include <gp_Pnt2d.hxx> |
38 | #include <gp_Vec2d.hxx> |
39 | #include <gp_Dir2d.hxx> |
40 | #include <gp_Pnt.hxx> |
41 | #include <gp_Vec.hxx> |
42 | #include <gp_Dir.hxx> |
43 | |
44 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_XY& theXY) |
45 | { |
46 | Standard_Real aX, aY; |
47 | theReadData.ReadValue(aX); |
48 | theReadData.ReadValue(aY); |
49 | theXY.SetCoord(aX, aY); |
50 | return theReadData; |
51 | } |
52 | |
53 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Pnt2d& thePnt) |
54 | { |
55 | Standard_Real aX, aY; |
56 | theReadData.ReadValue(aX); |
57 | theReadData.ReadValue(aY); |
58 | thePnt.SetCoord(aX, aY); |
59 | return theReadData; |
60 | } |
61 | |
62 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Vec2d& theVec) |
63 | { |
64 | Standard_Real aX, aY; |
65 | theReadData.ReadValue(aX); |
66 | theReadData.ReadValue(aY); |
67 | theVec.SetCoord(aX, aY); |
68 | return theReadData; |
69 | } |
70 | |
71 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Dir2d& theDir) |
72 | { |
73 | Standard_Real aX, aY; |
74 | theReadData.ReadValue(aX); |
75 | theReadData.ReadValue(aY); |
76 | theDir.SetCoord(aX, aY); |
77 | return theReadData; |
78 | } |
79 | |
80 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_XYZ& theXYZ) |
81 | { |
82 | Standard_Real aX, aY, aZ; |
83 | theReadData.ReadValue(aX); |
84 | theReadData.ReadValue(aY); |
85 | theReadData.ReadValue(aZ); |
86 | theXYZ.SetCoord(aX, aY, aZ); |
87 | return theReadData; |
88 | } |
89 | |
90 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Pnt& thePnt) |
91 | { |
92 | Standard_Real aX, aY, aZ; |
93 | theReadData.ReadValue(aX); |
94 | theReadData.ReadValue(aY); |
95 | theReadData.ReadValue(aZ); |
96 | thePnt.SetCoord(aX, aY, aZ); |
97 | return theReadData; |
98 | } |
99 | |
100 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Vec& theVec) |
101 | { |
102 | Standard_Real aX, aY, aZ; |
103 | theReadData.ReadValue(aX); |
104 | theReadData.ReadValue(aY); |
105 | theReadData.ReadValue(aZ); |
106 | theVec.SetCoord(aX, aY, aZ); |
107 | return theReadData; |
108 | } |
109 | |
110 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Dir& theDir) |
111 | { |
112 | Standard_Real aX, aY, aZ; |
113 | theReadData.ReadValue(aX); |
114 | theReadData.ReadValue(aY); |
115 | theReadData.ReadValue(aZ); |
116 | theDir.SetCoord(aX, aY, aZ); |
117 | return theReadData; |
118 | } |
119 | |
120 | // read axis placements |
121 | |
122 | #include <gp_Ax2d.hxx> |
123 | #include <gp_Ax22d.hxx> |
124 | #include <gp_Ax1.hxx> |
125 | #include <gp_Ax2.hxx> |
126 | #include <gp_Ax3.hxx> |
127 | |
128 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax2d& theAx) |
129 | { |
130 | gp_Pnt2d aLoc; |
131 | gp_Dir2d aDir; |
132 | theReadData >> aLoc >> aDir; |
133 | theAx = gp_Ax2d (aLoc, aDir); |
134 | return theReadData; |
135 | } |
136 | |
137 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax22d& theAx) |
138 | { |
139 | gp_Pnt2d aLoc; |
140 | gp_Dir2d aYDir, aXDir; |
141 | theReadData >> aLoc >> aYDir >> aXDir; |
142 | theAx = gp_Ax22d (aLoc, aXDir, aYDir); |
143 | return theReadData; |
144 | } |
145 | |
146 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax1& theAx) |
147 | { |
148 | gp_XYZ aLoc; |
149 | gp_Dir aDir; |
150 | theReadData >> aLoc >> aDir; |
151 | theAx = gp_Ax1 (aLoc, aDir); |
152 | return theReadData; |
153 | } |
154 | |
155 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax2& theAx) |
156 | { |
157 | gp_Ax1 anAx; |
158 | gp_Dir aYDir, aXDir; |
159 | theReadData >> anAx >> aYDir >> aXDir; |
160 | theAx = gp_Ax2 (anAx.Location(), anAx.Direction(), aXDir); |
161 | return theReadData; |
162 | } |
163 | |
164 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Ax3& theAx) |
165 | { |
166 | gp_Ax1 anAx; |
167 | gp_Dir aYDir, aXDir; |
168 | theReadData >> anAx >> aYDir >> aXDir; |
169 | theAx = gp_Ax3 (anAx.Location(), anAx.Direction(), aXDir); |
170 | if (aYDir * theAx.YDirection() < 0.) |
171 | theAx.YReverse(); |
172 | return theReadData; |
173 | } |
174 | |
175 | // read curves |
176 | |
177 | #include <gp_Lin2d.hxx> |
178 | #include <gp_Circ2d.hxx> |
179 | #include <gp_Elips2d.hxx> |
180 | #include <gp_Hypr2d.hxx> |
181 | #include <gp_Parab2d.hxx> |
182 | #include <gp_Lin.hxx> |
183 | #include <gp_Circ.hxx> |
184 | #include <gp_Elips.hxx> |
185 | #include <gp_Hypr.hxx> |
186 | #include <gp_Parab.hxx> |
187 | |
188 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Lin2d& theLin) |
189 | { |
190 | gp_Ax2d anAx; |
191 | theReadData >> anAx; |
192 | theLin.SetPosition(anAx); |
193 | return theReadData; |
194 | } |
195 | |
196 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Circ2d& theCirc) |
197 | { |
198 | gp_Ax22d anAx; |
199 | Standard_Real aRadius; |
200 | theReadData >> anAx; |
201 | theReadData.ReadValue(aRadius); |
202 | theCirc.SetAxis(anAx); |
203 | theCirc.SetRadius (aRadius); |
204 | return theReadData; |
205 | } |
206 | |
207 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Elips2d& theElips) |
208 | { |
209 | gp_Ax22d anAx; |
210 | Standard_Real aMajorRadius, aMinorRadius; |
211 | theReadData >> anAx; |
212 | theReadData.ReadValue(aMajorRadius); |
213 | theReadData.ReadValue(aMinorRadius); |
214 | theElips.SetAxis(anAx); |
215 | theElips.SetMajorRadius(aMajorRadius); |
216 | theElips.SetMinorRadius(aMinorRadius); |
217 | return theReadData; |
218 | } |
219 | |
220 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Hypr2d& theHypr) |
221 | { |
222 | gp_Ax22d anAx; |
223 | Standard_Real aMajorRadius, aMinorRadius; |
224 | theReadData >> anAx; |
225 | theReadData.ReadValue(aMajorRadius); |
226 | theReadData.ReadValue(aMinorRadius); |
227 | theHypr.SetAxis(anAx); |
228 | theHypr.SetMajorRadius(aMajorRadius); |
229 | theHypr.SetMinorRadius(aMinorRadius); |
230 | return theReadData; |
231 | } |
232 | |
233 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Parab2d& theParab) |
234 | { |
235 | gp_Ax22d anAx; |
236 | Standard_Real aFocalLength; |
237 | theReadData >> anAx; |
238 | theReadData.ReadValue(aFocalLength); |
239 | theParab.SetAxis(anAx); |
240 | theParab.SetFocal(aFocalLength); |
241 | return theReadData; |
242 | } |
243 | |
244 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Lin& theLin) |
245 | { |
246 | gp_Ax1 anAx; |
247 | theReadData >> anAx; |
248 | theLin.SetPosition(anAx); |
249 | return theReadData; |
250 | } |
251 | |
252 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Circ& theCirc) |
253 | { |
254 | gp_Ax2 anAx; |
255 | Standard_Real aRadius; |
256 | theReadData >> anAx; |
257 | theReadData.ReadValue(aRadius); |
258 | theCirc.SetPosition(anAx); |
259 | theCirc.SetRadius (aRadius); |
260 | return theReadData; |
261 | } |
262 | |
263 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Elips& theElips) |
264 | { |
265 | gp_Ax2 anAx; |
266 | Standard_Real aMajorRadius, aMinorRadius; |
267 | theReadData >> anAx; |
268 | theReadData.ReadValue(aMajorRadius); |
269 | theReadData.ReadValue(aMinorRadius); |
270 | theElips.SetPosition(anAx); |
271 | theElips.SetMajorRadius(aMajorRadius); |
272 | theElips.SetMinorRadius(aMinorRadius); |
273 | return theReadData; |
274 | } |
275 | |
276 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Hypr& theHypr) |
277 | { |
278 | gp_Ax2 anAx; |
279 | Standard_Real aMajorRadius, aMinorRadius; |
280 | theReadData >> anAx; |
281 | theReadData.ReadValue(aMajorRadius); |
282 | theReadData.ReadValue(aMinorRadius); |
283 | theHypr.SetPosition(anAx); |
284 | theHypr.SetMajorRadius(aMajorRadius); |
285 | theHypr.SetMinorRadius(aMinorRadius); |
286 | return theReadData; |
287 | } |
288 | |
289 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Parab& theParab) |
290 | { |
291 | gp_Ax2 anAx; |
292 | Standard_Real aFocalLength; |
293 | theReadData >> anAx; |
294 | theReadData.ReadValue(aFocalLength); |
295 | theParab.SetPosition(anAx); |
296 | theParab.SetFocal(aFocalLength); |
297 | return theReadData; |
298 | } |
299 | |
300 | // read surfaces |
301 | |
302 | #include <gp_Cone.hxx> |
303 | #include <gp_Cylinder.hxx> |
304 | #include <gp_Sphere.hxx> |
305 | #include <gp_Torus.hxx> |
306 | |
307 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Cone& theCone) |
308 | { |
309 | gp_Ax3 anAx; |
310 | Standard_Real aRadius, aSemiAngle; |
311 | theReadData >> anAx; |
312 | theReadData.ReadValue(aRadius); |
313 | theReadData.ReadValue(aSemiAngle); |
314 | theCone.SetPosition(anAx); |
315 | theCone.SetRadius(aRadius); |
316 | theCone.SetSemiAngle(aSemiAngle); |
317 | return theReadData; |
318 | } |
319 | |
320 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Cylinder& theCyl) |
321 | { |
322 | gp_Ax3 anAx; |
323 | Standard_Real aRadius; |
324 | theReadData >> anAx; |
325 | theReadData.ReadValue(aRadius); |
326 | theCyl.SetPosition(anAx); |
327 | theCyl.SetRadius(aRadius); |
328 | return theReadData; |
329 | } |
330 | |
331 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Sphere& theSph) |
332 | { |
333 | gp_Ax3 anAx; |
334 | Standard_Real aRadius; |
335 | theReadData >> anAx; |
336 | theReadData.ReadValue(aRadius); |
337 | theSph.SetPosition(anAx); |
338 | theSph.SetRadius(aRadius); |
339 | return theReadData; |
340 | } |
341 | |
342 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Torus& theTorus) |
343 | { |
344 | gp_Ax3 anAx; |
345 | Standard_Real aMajorRadius, aMinorRadius; |
346 | theReadData >> anAx; |
347 | theReadData.ReadValue(aMajorRadius); |
348 | theReadData.ReadValue(aMinorRadius); |
349 | theTorus.SetPosition(anAx); |
350 | theTorus.SetMajorRadius(aMajorRadius); |
351 | theTorus.SetMinorRadius(aMinorRadius); |
352 | return theReadData; |
353 | } |
354 | |
355 | // read transformations |
356 | |
357 | #include <gp_Mat2d.hxx> |
358 | #include <gp_Mat.hxx> |
359 | #include <gp_Trsf2d.hxx> |
360 | #include <gp_Trsf.hxx> |
361 | |
362 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Mat2d& theMat) |
363 | { |
364 | gp_XY aRow1, aRow2; |
365 | theReadData >> aRow1 >> aRow2; |
366 | theMat.SetRows(aRow1, aRow2); |
367 | return theReadData; |
368 | } |
369 | |
370 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Mat& theMat) |
371 | { |
372 | gp_XYZ aRow1, aRow2, aRow3; |
373 | theReadData >> aRow1 >> aRow2 >> aRow3; |
374 | theMat.SetRows(aRow1, aRow2, aRow3); |
375 | return theReadData; |
376 | } |
377 | |
378 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Trsf2d& theTrsf) |
379 | { |
380 | Standard_Real aScale; |
381 | gp_TrsfForm aForm; |
382 | gp_Mat2d aMat; |
383 | gp_XY aLoc; |
384 | theReadData.ReadValue(aScale); |
385 | theReadData.ReadEnum(aForm); |
386 | theReadData >> aMat >> aLoc; |
387 | theTrsf.SetValues(aScale * aMat(1, 1), aScale * aMat(1, 2), aLoc.X(), |
388 | aScale * aMat(2, 1), aScale * aMat(2, 2), aLoc.Y()); |
389 | return theReadData; |
390 | } |
391 | |
392 | inline StdObjMgt_ReadData& operator >> (StdObjMgt_ReadData& theReadData, gp_Trsf& theTrsf) |
393 | { |
394 | Standard_Real aScale; |
395 | gp_TrsfForm aForm; |
396 | gp_Mat aMat; |
397 | gp_XYZ aLoc; |
398 | theReadData.ReadValue(aScale); |
399 | theReadData.ReadEnum(aForm); |
400 | theReadData >> aMat >> aLoc; |
401 | theTrsf.SetValues(aScale * aMat(1, 1), aScale * aMat(1, 2), aScale * aMat(1, 3), aLoc.X(), |
402 | aScale * aMat(2, 1), aScale * aMat(2, 2), aScale * aMat(2, 3), aLoc.Y(), |
403 | aScale * aMat(3, 1), aScale * aMat(3, 2), aScale * aMat(3, 3), aLoc.Z()); |
404 | return theReadData; |
405 | } |
406 | |
407 | template<class T> |
408 | inline void StdObject_gp::object<T>::Read (StdObjMgt_ReadData& theReadData) |
409 | { |
410 | theReadData >> (*this); |
411 | } |
412 | |
413 | |
414 | #endif |