7fd59977 |
1 | // File: MgtGeom2d.cxx |
2 | // Created: Wed Apr 14 17:28:55 1993 |
3 | // Author: Philippe DAUTRY |
4 | // <fid@mastox> |
5 | // Copyright: Matra Datavision 1993 |
6 | |
7 | |
8 | #include <MgtGeom2d.ixx> |
9 | |
10 | #include <Standard_Type.hxx> |
11 | |
12 | #include <PColStd_HArray1OfInteger.hxx> |
13 | #include <PColStd_HArray2OfInteger.hxx> |
14 | #include <PColStd_HArray1OfReal.hxx> |
15 | #include <PColStd_HArray2OfReal.hxx> |
16 | |
17 | #include <TColStd_Array1OfInteger.hxx> |
18 | #include <TColStd_Array2OfInteger.hxx> |
19 | #include <TColStd_HArray1OfInteger.hxx> |
20 | |
21 | #include <TColStd_Array1OfReal.hxx> |
22 | #include <TColStd_Array2OfReal.hxx> |
23 | #include <TColStd_HArray1OfReal.hxx> |
24 | #include <TColStd_HArray2OfReal.hxx> |
25 | |
26 | #include <TColgp_Array1OfPnt2d.hxx> |
27 | #include <TColgp_Array2OfPnt2d.hxx> |
28 | #include <TColgp_HArray1OfPnt2d.hxx> |
29 | #include <TColgp_HArray2OfPnt2d.hxx> |
30 | |
31 | #include <PColgp_HArray1OfPnt2d.hxx> |
32 | #include <PColgp_HArray2OfPnt2d.hxx> |
33 | |
34 | #include <gp_Vec.hxx> |
35 | #include <gp_Ax1.hxx> |
36 | |
37 | //modif wok++ |
38 | #include <gp_Circ2d.hxx> |
39 | #include <Standard_NullObject.hxx> |
40 | #include <gp_Lin2d.hxx> |
41 | |
42 | // ******************************************************************* |
43 | // The following methods are subroutines used to copy elements |
44 | // from structures to other structures, as array1 or array2. |
45 | // ******************************************************************* |
46 | |
47 | // ******************************************************************* |
48 | // Structures from TCollection to structures from PCollection. |
49 | // ******************************************************************* |
50 | |
51 | //======================================================================= |
52 | //function : ArrayCopy |
53 | //purpose : Copy the gp_Pnt2d |
54 | // from an Array1 from TColgp (TCollection) |
55 | // to an HArray1 from PColgp (PCollection) |
56 | //======================================================================= |
57 | |
58 | static Handle(PColgp_HArray1OfPnt2d) ArrayCopy |
59 | (const TColgp_Array1OfPnt2d& TArray) |
60 | { |
61 | Standard_Integer Lower = TArray.Lower(); |
62 | Standard_Integer Upper = TArray.Upper(); |
63 | Standard_Integer Index; |
64 | Handle(PColgp_HArray1OfPnt2d) PArray = |
65 | new PColgp_HArray1OfPnt2d(Lower, Upper); |
66 | for (Index = Lower; Index <= Upper; Index++) { |
67 | PArray->SetValue(Index, TArray(Index)); |
68 | } |
69 | return PArray; |
70 | } |
71 | |
72 | //======================================================================= |
73 | //function : ArrayCopy |
74 | //purpose : Copy the gp_Pnt2d |
75 | // from an Array2 from TColgp (TCollection) |
76 | // to an HArray2 from PColgp (PCollection) |
77 | //======================================================================= |
78 | #ifdef DEB |
79 | static Handle(PColgp_HArray2OfPnt2d) ArrayCopy |
80 | (const TColgp_Array2OfPnt2d& TArray) |
81 | { |
82 | Standard_Integer LowerRow = TArray.LowerRow(); |
83 | Standard_Integer UpperRow = TArray.UpperRow(); |
84 | Standard_Integer LowerCol = TArray.LowerCol(); |
85 | Standard_Integer UpperCol = TArray.UpperCol(); |
86 | Standard_Integer IndexRow, IndexCol; |
87 | Handle(PColgp_HArray2OfPnt2d) PArray = |
88 | new PColgp_HArray2OfPnt2d(LowerRow, UpperRow, LowerCol, UpperCol); |
89 | for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) { |
90 | for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) { |
91 | PArray->SetValue(IndexRow, IndexCol, TArray(IndexRow, IndexCol)); |
92 | } |
93 | } |
94 | return PArray; |
95 | } |
96 | #endif |
97 | //======================================================================= |
98 | //function : ArrayCopy |
99 | //purpose : Copy the Standard_Real |
100 | // from an Array1 from TColStd (TCollection) |
101 | // to an SingleArray from PCollection |
102 | //======================================================================= |
103 | |
104 | static Handle(PColStd_HArray1OfReal) ArrayCopy |
105 | (const TColStd_Array1OfReal& TArray) |
106 | { |
107 | Standard_Integer Lower = TArray.Lower(); |
108 | Standard_Integer Upper = TArray.Upper(); |
109 | Standard_Integer Index; |
110 | Handle(PColStd_HArray1OfReal) PArray = |
111 | new PColStd_HArray1OfReal(Lower, Upper); |
112 | for (Index = Lower; Index <= Upper; Index++) { |
113 | PArray->SetValue(Index, TArray(Index)); |
114 | } |
115 | return PArray; |
116 | } |
117 | |
118 | //======================================================================= |
119 | //function : ArrayCopy |
120 | //purpose : Copy the Standard_Real |
121 | // from an Array2 from TColStd (TCollection) |
122 | // to an DoubleArray from PCollection |
123 | //======================================================================= |
124 | #ifdef DEB |
125 | static Handle(PColStd_HArray2OfReal) ArrayCopy |
126 | (const TColStd_Array2OfReal& TArray) |
127 | { |
128 | Standard_Integer LowerRow = TArray.LowerRow(); |
129 | Standard_Integer UpperRow = TArray.UpperRow(); |
130 | Standard_Integer LowerCol = TArray.LowerCol(); |
131 | Standard_Integer UpperCol = TArray.UpperCol(); |
132 | Standard_Integer IndexRow, IndexCol; |
133 | Handle(PColStd_HArray2OfReal) PArray = |
134 | new PColStd_HArray2OfReal(LowerRow, UpperRow, LowerCol, UpperCol); |
135 | for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) { |
136 | for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) { |
137 | PArray->SetValue(IndexRow, IndexCol, TArray(IndexRow, IndexCol)); |
138 | } |
139 | } |
140 | return PArray; |
141 | } |
142 | #endif |
143 | //======================================================================= |
144 | //function : ArrayCopy |
145 | //purpose : Copy the Standard_Integer |
146 | // from an Array1 from TColStd (TCollection) |
147 | // to an SingleArray from PCollection |
148 | //======================================================================= |
149 | |
150 | static Handle(PColStd_HArray1OfInteger) ArrayCopy |
151 | (const TColStd_Array1OfInteger& TArray) |
152 | { |
153 | Standard_Integer Lower = TArray.Lower(); |
154 | Standard_Integer Upper = TArray.Upper(); |
155 | Standard_Integer Index; |
156 | Handle(PColStd_HArray1OfInteger) PArray = |
157 | new PColStd_HArray1OfInteger(Lower, Upper); |
158 | for (Index = Lower; Index <= Upper; Index++) { |
159 | PArray->SetValue(Index, TArray(Index)); |
160 | } |
161 | return PArray; |
162 | } |
163 | |
164 | // ******************************************************************* |
165 | // Structures from PCollection to structures from TCollection. |
166 | // ******************************************************************* |
167 | |
168 | //======================================================================= |
169 | //function : ArrayCopy |
170 | //purpose : Copy the gp_Pnt2d |
171 | // from an HArray1 from PColgp (PCollection) |
172 | // to an Array1 from TColgp (TCollection) |
173 | //======================================================================= |
174 | |
175 | static void ArrayCopy |
176 | (const Handle(PColgp_HArray1OfPnt2d)& PArray, |
177 | TColgp_Array1OfPnt2d& TArray) |
178 | { |
179 | Standard_Integer Lower = PArray->Lower(); |
180 | Standard_Integer Upper = PArray->Upper(); |
181 | Standard_Integer Index; |
182 | for (Index = Lower; Index <= Upper; Index++) { |
183 | TArray(Index) = PArray->Value(Index); |
184 | } |
185 | } |
186 | |
187 | //======================================================================= |
188 | //function : ArrayCopy |
189 | //purpose : Copy the gp_Pnt2d |
190 | // from an HArray2 from PColgp (PCollection) |
191 | // to an Array2 from TColgp (TCollection) |
192 | //======================================================================= |
193 | |
194 | // Unused : |
195 | #ifdef DEB |
196 | static void ArrayCopy |
197 | (const Handle(PColgp_HArray2OfPnt2d)& PArray, |
198 | TColgp_Array2OfPnt2d& TArray) |
199 | { |
200 | Standard_Integer LowerRow = TArray.LowerRow(); |
201 | Standard_Integer UpperRow = TArray.UpperRow(); |
202 | Standard_Integer LowerCol = TArray.LowerCol(); |
203 | Standard_Integer UpperCol = TArray.UpperCol(); |
204 | Standard_Integer IndexRow, IndexCol; |
205 | for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) { |
206 | for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) { |
207 | TArray(IndexRow, IndexCol) = PArray->Value(IndexRow, IndexCol); |
208 | } |
209 | } |
210 | } |
211 | #endif |
212 | |
213 | //======================================================================= |
214 | //function : ArrayCopy |
215 | //purpose : Copy the Standard_Real |
216 | // from an SingleArray from PCollection |
217 | // to an Array1 from TColStd (TCollection) |
218 | //======================================================================= |
219 | |
220 | static void ArrayCopy |
221 | (const Handle(PColStd_HArray1OfReal)& PArray, |
222 | TColStd_Array1OfReal& TArray) |
223 | { |
224 | Standard_Integer Lower = PArray->Lower(); |
225 | Standard_Integer Upper = PArray->Upper(); |
226 | Standard_Integer Index; |
227 | for (Index = Lower; Index <= Upper; Index++) { |
228 | TArray(Index) = PArray->Value(Index); |
229 | } |
230 | } |
231 | |
232 | //======================================================================= |
233 | //function : ArrayCopy |
234 | //purpose : Copy the Standard_Real |
235 | // from an DoubleArray from PCollection |
236 | // to an Array2 from TColStd (TCollection) |
237 | //======================================================================= |
238 | |
239 | // Unused : |
240 | #ifdef DEB |
241 | static void ArrayCopy |
242 | (const Handle(PColStd_HArray2OfReal)& PArray, |
243 | TColStd_Array2OfReal& TArray) |
244 | { |
245 | Standard_Integer LowerRow = TArray.LowerRow(); |
246 | Standard_Integer UpperRow = TArray.UpperRow(); |
247 | Standard_Integer LowerCol = TArray.LowerCol(); |
248 | Standard_Integer UpperCol = TArray.UpperCol(); |
249 | Standard_Integer IndexRow, IndexCol; |
250 | for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) { |
251 | for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) { |
252 | TArray(IndexRow, IndexCol) = PArray->Value(IndexRow, IndexCol); |
253 | } |
254 | } |
255 | } |
256 | #endif |
257 | |
258 | //======================================================================= |
259 | //function : ArrayCopy |
260 | //purpose : Copy the Standard_Integer |
261 | // from an SingleArray from PCollection |
262 | // to an Array1 from TColStd (TCollection) |
263 | //======================================================================= |
264 | |
265 | static void ArrayCopy |
266 | (const Handle(PColStd_HArray1OfInteger)& PArray, |
267 | TColStd_Array1OfInteger& TArray) |
268 | { |
269 | Standard_Integer Lower = PArray->Lower(); |
270 | Standard_Integer Upper = PArray->Upper(); |
271 | Standard_Integer Index; |
272 | for (Index = Lower; Index <= Upper; Index++) { |
273 | TArray(Index) = PArray->Value(Index); |
274 | } |
275 | } |
276 | |
277 | |
278 | |
279 | // ******************************************************************* |
280 | // Here is the implementation of the package methods. |
281 | // ******************************************************************* |
282 | |
283 | |
284 | //======================================================================= |
285 | //function : Translate |
286 | //purpose : Translates a PGeom2d_AxisPlacement to a Geom2d_AxisPlacement. |
287 | //======================================================================= |
288 | |
289 | Handle(Geom2d_AxisPlacement) MgtGeom2d::Translate |
290 | (const Handle(PGeom2d_AxisPlacement)& PObj) |
291 | { |
292 | return new Geom2d_AxisPlacement(PObj->Axis()); |
293 | } |
294 | |
295 | |
296 | //======================================================================= |
297 | //function : Translate |
298 | //purpose : Translates a Geom2d_AxisPlacement to a PGeom2d_AxisPlacement. |
299 | //======================================================================= |
300 | |
301 | Handle(PGeom2d_AxisPlacement) MgtGeom2d::Translate |
302 | (const Handle(Geom2d_AxisPlacement)& TObj) |
303 | { |
304 | return new PGeom2d_AxisPlacement(TObj->Ax2d()); |
305 | } |
306 | |
307 | |
308 | //======================================================================= |
309 | //function : Translate |
310 | //purpose : Translates a PGeom2d_BSplineCurve to a Geom2d_BSplineCurve. |
311 | //======================================================================= |
312 | |
313 | Handle(Geom2d_BSplineCurve) MgtGeom2d::Translate |
314 | (const Handle(PGeom2d_BSplineCurve)& PObj) |
315 | { |
316 | Handle(Geom2d_BSplineCurve) TBSplC; |
317 | |
318 | Handle(PColgp_HArray1OfPnt2d) oldPoles = PObj->Poles(); |
319 | TColgp_Array1OfPnt2d newPoles (oldPoles->Lower(),oldPoles->Upper()); |
320 | ArrayCopy(oldPoles,newPoles); |
321 | |
322 | Handle(PColStd_HArray1OfInteger) oldMult = PObj->Multiplicities(); |
323 | TColStd_Array1OfInteger newMultiplicities(oldMult->Lower(),oldMult->Upper()); |
324 | ArrayCopy(oldMult,newMultiplicities); |
325 | |
326 | Handle(PColStd_HArray1OfReal) oldKnots = PObj->Knots(); |
327 | TColStd_Array1OfReal newKnots (oldKnots->Lower(),oldKnots->Upper()); |
328 | ArrayCopy(oldKnots,newKnots); |
329 | |
330 | if (PObj->Rational()) { |
331 | Handle(PColStd_HArray1OfReal) oldWeights = PObj->Weights(); |
332 | TColStd_Array1OfReal newWeights (oldWeights->Lower(),oldWeights->Upper()); |
333 | ArrayCopy(oldWeights,newWeights); |
334 | // modified by NIZHNY-MKK Fri Oct 17 11:20:32 2003.BEGIN |
335 | TBSplC = new Geom2d_BSplineCurve |
336 | // (newPoles, newWeights, newKnots, newMultiplicities, PObj->SpineDegree()); |
337 | (newPoles, newWeights, newKnots, newMultiplicities, |
338 | PObj->SpineDegree(), PObj->Periodic()); |
339 | // modified by NIZHNY-MKK Fri Oct 17 11:20:38 2003.END |
340 | } |
341 | else { |
342 | // modified by NIZHNY-MKK Thu Oct 16 18:19:22 2003.BEGIN |
343 | TBSplC = new Geom2d_BSplineCurve |
344 | // (newPoles, newKnots, newMultiplicities, PObj->SpineDegree()); |
345 | (newPoles, newKnots, newMultiplicities, |
346 | PObj->SpineDegree(), PObj->Periodic()); |
347 | // modified by NIZHNY-MKK Fri Oct 17 11:20:52 2003.END |
348 | } |
349 | // modified by NIZHNY-MKK Thu Oct 16 18:19:12 2003 |
350 | // if (PObj->Periodic()) TBSplC->SetPeriodic(); |
351 | return TBSplC; |
352 | } |
353 | |
354 | |
355 | //======================================================================= |
356 | //function : Translate |
357 | //purpose : Translates a Geom2d_BSplineCurve to a PGeom2d_BSplineCurve. |
358 | //======================================================================= |
359 | |
360 | Handle(PGeom2d_BSplineCurve) MgtGeom2d::Translate |
361 | (const Handle(Geom2d_BSplineCurve)& TObj) |
362 | { |
363 | Standard_Integer Upper; |
364 | |
365 | Upper = TObj->NbPoles(); |
366 | |
367 | TColgp_Array1OfPnt2d oldPoles(1, Upper); |
368 | TObj->Poles(oldPoles); |
369 | Handle(PColgp_HArray1OfPnt2d) newPPoles = ArrayCopy(oldPoles); |
370 | |
371 | Handle(PColStd_HArray1OfReal) newPWeights; |
372 | if (TObj->IsRational()) { |
373 | TColStd_Array1OfReal oldWeights(1, Upper); |
374 | TObj->Weights(oldWeights); |
375 | newPWeights = ArrayCopy(oldWeights); |
376 | } |
377 | |
378 | Upper = TObj->NbKnots(); |
379 | |
380 | TColStd_Array1OfReal oldKnots(1, Upper); |
381 | TObj->Knots(oldKnots); |
382 | Handle(PColStd_HArray1OfReal) newPKnots = ArrayCopy(oldKnots); |
383 | |
384 | TColStd_Array1OfInteger oldMultiplicities(1, Upper); |
385 | TObj->Multiplicities(oldMultiplicities); |
386 | Handle(PColStd_HArray1OfInteger) newPMultiplicities = |
387 | ArrayCopy(oldMultiplicities); |
388 | |
389 | |
390 | Handle(PGeom2d_BSplineCurve) PBSplC = |
391 | new PGeom2d_BSplineCurve(TObj->IsRational(), |
392 | TObj->IsPeriodic(), |
393 | TObj->Degree(), |
394 | newPPoles, |
395 | newPWeights, |
396 | newPKnots, |
397 | newPMultiplicities); |
398 | return PBSplC; |
399 | } |
400 | |
401 | |
402 | //======================================================================= |
403 | //function : Translate |
404 | //purpose : Translates a PGeom2d_BezierCurve to a Geom2d_BezierCurve. |
405 | //======================================================================= |
406 | |
407 | Handle(Geom2d_BezierCurve) MgtGeom2d::Translate |
408 | (const Handle(PGeom2d_BezierCurve)& PObj) |
409 | { |
410 | Handle(Geom2d_BezierCurve) TBzC; |
411 | |
412 | Handle(PColgp_HArray1OfPnt2d) oldPoles = PObj->Poles(); |
413 | TColgp_Array1OfPnt2d newPoles (oldPoles->Lower(),oldPoles->Upper()); |
414 | ArrayCopy(oldPoles,newPoles); |
415 | |
416 | if (PObj->Rational()) { |
417 | Handle(PColStd_HArray1OfReal) oldWeights = PObj->Weights(); |
418 | TColStd_Array1OfReal newWeights (oldWeights->Lower(),oldWeights->Upper()); |
419 | ArrayCopy(oldWeights,newWeights); |
420 | TBzC = new Geom2d_BezierCurve(newPoles, newWeights); |
421 | } |
422 | else { |
423 | TBzC = new Geom2d_BezierCurve(newPoles); |
424 | } |
425 | return TBzC; |
426 | } |
427 | |
428 | |
429 | //======================================================================= |
430 | //function : Translate |
431 | //purpose : Translates a Geom2d_BezierCurve to a PGeom2d_BezierCurve. |
432 | //======================================================================= |
433 | |
434 | Handle(PGeom2d_BezierCurve) MgtGeom2d::Translate |
435 | (const Handle(Geom2d_BezierCurve)& TObj) |
436 | { |
437 | Standard_Integer Upper; |
438 | |
439 | Upper = TObj->NbPoles(); |
440 | |
441 | TColgp_Array1OfPnt2d oldPoles(1, Upper); |
442 | TObj->Poles(oldPoles); |
443 | Handle(PColgp_HArray1OfPnt2d) newPPoles = ArrayCopy(oldPoles); |
444 | |
445 | Handle(PColStd_HArray1OfReal) newPWeights; |
446 | if (TObj->IsRational()) { |
447 | TColStd_Array1OfReal oldWeights(1, Upper); |
448 | TObj->Weights(oldWeights); |
449 | newPWeights = ArrayCopy(oldWeights); |
450 | } |
451 | |
452 | Handle(PGeom2d_BezierCurve) PBzC = new PGeom2d_BezierCurve |
453 | (newPPoles, |
454 | newPWeights, |
455 | TObj->IsRational()); |
456 | return PBzC; |
457 | } |
458 | |
459 | |
460 | //======================================================================= |
461 | //function : Translate |
462 | //purpose : Translates a PGeom2d_CartesianPoint to a Geom2d_CartesianPoint. |
463 | //======================================================================= |
464 | |
465 | Handle(Geom2d_CartesianPoint) MgtGeom2d::Translate |
466 | (const Handle(PGeom2d_CartesianPoint)& PObj) |
467 | { return new Geom2d_CartesianPoint(PObj->Pnt()); } |
468 | |
469 | |
470 | //======================================================================= |
471 | //function : Translate |
472 | //purpose : Translates a Geom2d_CartesianPoint to a PGeom2d_CartesianPoint. |
473 | //======================================================================= |
474 | |
475 | Handle(PGeom2d_CartesianPoint) MgtGeom2d::Translate |
476 | (const Handle(Geom2d_CartesianPoint)& TObj) |
477 | { return new PGeom2d_CartesianPoint(TObj->Pnt2d()); } |
478 | |
479 | |
480 | //======================================================================= |
481 | //function : Translate |
482 | //purpose : Translates a PGeom2d_Circle to a Geom2d_Circle. |
483 | //======================================================================= |
484 | |
485 | Handle(Geom2d_Circle) MgtGeom2d::Translate(const Handle(PGeom2d_Circle)& PObj) |
486 | { |
487 | return new Geom2d_Circle(PObj->Position(), |
488 | PObj->Radius()); |
489 | } |
490 | |
491 | |
492 | //======================================================================= |
493 | //function : Translate |
494 | //purpose : Translates a Geom2d_Circle to a PGeom2d_Circle. |
495 | //======================================================================= |
496 | |
497 | Handle(PGeom2d_Circle) MgtGeom2d::Translate(const Handle(Geom2d_Circle)& TObj) |
498 | { |
499 | return new PGeom2d_Circle(TObj->Circ2d().Position(),TObj->Circ2d().Radius()); |
500 | } |
501 | |
502 | |
503 | //======================================================================= |
504 | //function : Translate |
505 | //purpose : Translates a PGeom2d_Curve to a Geom2d_Curve. |
506 | //======================================================================= |
507 | |
508 | Handle(Geom2d_Curve) MgtGeom2d::Translate(const Handle(PGeom2d_Curve)& PObj) |
509 | { |
510 | Handle(Standard_Type) CurveType = PObj->DynamicType(); |
511 | |
512 | if (CurveType == STANDARD_TYPE(PGeom2d_Line)) { |
513 | Handle(PGeom2d_Line)& TLine = |
514 | (Handle(PGeom2d_Line)&) PObj; |
515 | return MgtGeom2d::Translate(TLine); |
516 | } |
517 | else if (CurveType == STANDARD_TYPE(PGeom2d_Circle)) { |
518 | Handle(PGeom2d_Circle)& TCircle = |
519 | (Handle(PGeom2d_Circle)&) PObj; |
520 | return MgtGeom2d::Translate(TCircle); |
521 | } |
522 | else if (CurveType == STANDARD_TYPE(PGeom2d_Ellipse)) { |
523 | Handle(PGeom2d_Ellipse)& TEllipse = |
524 | (Handle(PGeom2d_Ellipse)&) PObj; |
525 | return MgtGeom2d::Translate(TEllipse); |
526 | } |
527 | else if (CurveType == STANDARD_TYPE(PGeom2d_Hyperbola)) { |
528 | Handle(PGeom2d_Hyperbola)& THyperbola = |
529 | (Handle(PGeom2d_Hyperbola)&) PObj; |
530 | return MgtGeom2d::Translate(THyperbola); |
531 | } |
532 | else if (CurveType == STANDARD_TYPE(PGeom2d_Parabola)) { |
533 | Handle(PGeom2d_Parabola)& TParabola = |
534 | (Handle(PGeom2d_Parabola)&) PObj; |
535 | return MgtGeom2d::Translate(TParabola); |
536 | } |
537 | else if (CurveType == STANDARD_TYPE(PGeom2d_BezierCurve)) { |
538 | Handle(PGeom2d_BezierCurve)& TBezierCurve = |
539 | (Handle(PGeom2d_BezierCurve)&) PObj; |
540 | return MgtGeom2d::Translate(TBezierCurve); |
541 | } |
542 | else if (CurveType == STANDARD_TYPE(PGeom2d_BSplineCurve)) { |
543 | Handle(PGeom2d_BSplineCurve)& TBSplineCurve = |
544 | (Handle(PGeom2d_BSplineCurve)&) PObj; |
545 | return MgtGeom2d::Translate(TBSplineCurve); |
546 | } |
547 | else if (CurveType == STANDARD_TYPE(PGeom2d_TrimmedCurve)) { |
548 | Handle(PGeom2d_TrimmedCurve)& TTrimmedCurve = |
549 | (Handle(PGeom2d_TrimmedCurve)&) PObj; |
550 | return MgtGeom2d::Translate(TTrimmedCurve); |
551 | } |
552 | else if (CurveType == STANDARD_TYPE(PGeom2d_OffsetCurve)) { |
553 | Handle(PGeom2d_OffsetCurve)& TOffsetCurve = |
554 | (Handle(PGeom2d_OffsetCurve)&) PObj; |
555 | return MgtGeom2d::Translate(TOffsetCurve); |
556 | } |
557 | else { |
558 | cout << "Unknown Geom2d curve type ???? " << endl; |
559 | Standard_NullObject::Raise("No mapping for the current Persistent Curve"); |
560 | } |
561 | // POP pour NT |
562 | Handle(Geom2d_Curve) dummy; |
563 | return dummy; |
564 | } |
565 | |
566 | |
567 | //======================================================================= |
568 | //function : Translate |
569 | //purpose : Translates a Geom2d_Curve to a PGeom2d_Curve. |
570 | //======================================================================= |
571 | |
572 | Handle(PGeom2d_Curve) MgtGeom2d::Translate(const Handle(Geom2d_Curve)& TObj) |
573 | { |
574 | Handle(Standard_Type) CurveType = TObj->DynamicType(); |
575 | |
576 | if (CurveType == STANDARD_TYPE(Geom2d_Line)) { |
577 | Handle(Geom2d_Line)& PLine = |
578 | (Handle(Geom2d_Line)&) TObj; |
579 | return MgtGeom2d::Translate(PLine); |
580 | } |
581 | else if (CurveType == STANDARD_TYPE(Geom2d_Circle)) { |
582 | Handle(Geom2d_Circle)& PCircle = |
583 | (Handle(Geom2d_Circle)&) TObj; |
584 | return MgtGeom2d::Translate(PCircle); |
585 | } |
586 | else if (CurveType == STANDARD_TYPE(Geom2d_Ellipse)) { |
587 | Handle(Geom2d_Ellipse)& PEllipse = |
588 | (Handle(Geom2d_Ellipse)&) TObj; |
589 | return MgtGeom2d::Translate(PEllipse); |
590 | } |
591 | else if (CurveType == STANDARD_TYPE(Geom2d_Hyperbola)) { |
592 | Handle(Geom2d_Hyperbola)& PHyperbola = |
593 | (Handle(Geom2d_Hyperbola)&) TObj; |
594 | return MgtGeom2d::Translate(PHyperbola); |
595 | } |
596 | else if (CurveType == STANDARD_TYPE(Geom2d_Parabola)) { |
597 | Handle(Geom2d_Parabola)& PParabola = |
598 | (Handle(Geom2d_Parabola)&) TObj; |
599 | return MgtGeom2d::Translate(PParabola); |
600 | } |
601 | else if (CurveType == STANDARD_TYPE(Geom2d_BezierCurve)) { |
602 | Handle(Geom2d_BezierCurve)& PBezierCurve = |
603 | (Handle(Geom2d_BezierCurve)&) TObj; |
604 | return MgtGeom2d::Translate(PBezierCurve); |
605 | } |
606 | else if (CurveType == STANDARD_TYPE(Geom2d_BSplineCurve)) { |
607 | Handle(Geom2d_BSplineCurve)& PBSplineCurve = |
608 | (Handle(Geom2d_BSplineCurve)&) TObj; |
609 | return MgtGeom2d::Translate(PBSplineCurve); |
610 | } |
611 | else if (CurveType == STANDARD_TYPE(Geom2d_TrimmedCurve)) { |
612 | Handle(Geom2d_TrimmedCurve)& PTrimmedCurve = |
613 | (Handle(Geom2d_TrimmedCurve)&) TObj; |
614 | return MgtGeom2d::Translate(PTrimmedCurve); |
615 | } |
616 | else if (CurveType == STANDARD_TYPE(Geom2d_OffsetCurve)) { |
617 | Handle(Geom2d_OffsetCurve)& POffsetCurve = |
618 | (Handle(Geom2d_OffsetCurve)&) TObj; |
619 | return MgtGeom2d::Translate(POffsetCurve); |
620 | } |
621 | else { |
622 | cout << "Unknown Geom2d curve type ???? " << endl; |
623 | Standard_NullObject::Raise("No mapping for the current Transient Curve"); |
624 | } |
625 | // POP pour NT |
626 | Handle(PGeom2d_Curve) dummy; |
627 | return dummy; |
628 | } |
629 | |
630 | |
631 | //======================================================================= |
632 | //function : Translate |
633 | //purpose : Translates a PGeom2d_Direction to a Geom2d_Direction. |
634 | //======================================================================= |
635 | |
636 | Handle(Geom2d_Direction) MgtGeom2d::Translate |
637 | (const Handle(PGeom2d_Direction)& PObj) |
638 | { |
639 | gp_Vec2d vec = PObj->Vec(); |
640 | return new Geom2d_Direction(vec.X(), vec.Y()); |
641 | } |
642 | |
643 | |
644 | //======================================================================= |
645 | //function : Translate |
646 | //purpose : Translates a Geom2d_Direction to a PGeom2d_Direction. |
647 | //======================================================================= |
648 | |
649 | Handle(PGeom2d_Direction) MgtGeom2d::Translate |
650 | (const Handle(Geom2d_Direction)& TObj) |
651 | { return new PGeom2d_Direction(TObj->Vec2d()); } |
652 | |
653 | |
654 | //======================================================================= |
655 | //function : Translate |
656 | //purpose : Translates a PGeom2d_Ellipse to a Geom2d_Ellipse. |
657 | //======================================================================= |
658 | |
659 | Handle(Geom2d_Ellipse) MgtGeom2d::Translate |
660 | (const Handle(PGeom2d_Ellipse)& PObj) |
661 | { |
662 | return new Geom2d_Ellipse(PObj->Position(), |
663 | PObj->MajorRadius(), |
664 | PObj->MinorRadius()); |
665 | } |
666 | |
667 | |
668 | //======================================================================= |
669 | //function : Translate |
670 | //purpose : Translates a Geom2d_Ellipse to a PGeom2d_Ellipse. |
671 | //======================================================================= |
672 | |
673 | Handle(PGeom2d_Ellipse) MgtGeom2d::Translate |
674 | (const Handle(Geom2d_Ellipse)& TObj) |
675 | { |
676 | return new PGeom2d_Ellipse(TObj->Position(), |
677 | TObj->MajorRadius(), |
678 | TObj->MinorRadius()); |
679 | } |
680 | |
681 | |
682 | //======================================================================= |
683 | //function : Translate |
684 | //purpose : Translates a PGeom2d_Hyperbola to a Geom2d_Hyperbola. |
685 | //======================================================================= |
686 | |
687 | Handle(Geom2d_Hyperbola) MgtGeom2d::Translate |
688 | (const Handle(PGeom2d_Hyperbola)& PObj) |
689 | { |
690 | return new Geom2d_Hyperbola(PObj->Position(), |
691 | PObj->MajorRadius(), |
692 | PObj->MinorRadius()); |
693 | } |
694 | |
695 | |
696 | //======================================================================= |
697 | //function : Translate |
698 | //purpose : Translates a Geom2d_Hyperbola to a PGeom2d_Hyperbola. |
699 | //======================================================================= |
700 | |
701 | Handle(PGeom2d_Hyperbola) MgtGeom2d::Translate |
702 | (const Handle(Geom2d_Hyperbola)& TObj) |
703 | { |
704 | return new PGeom2d_Hyperbola(TObj->Position(), |
705 | TObj->MajorRadius(), |
706 | TObj->MinorRadius()); |
707 | } |
708 | |
709 | |
710 | //======================================================================= |
711 | //function : Translate |
712 | //purpose : Translates a PGeom2d_Line to a Geom2d_Line. |
713 | //======================================================================= |
714 | |
715 | Handle(Geom2d_Line) MgtGeom2d::Translate(const Handle(PGeom2d_Line)& PObj) |
716 | { return new Geom2d_Line(PObj->Position()); } |
717 | |
718 | |
719 | //======================================================================= |
720 | //function : Translate |
721 | //purpose : Translates a Geom2d_Line to a PGeom2d_Line. |
722 | //======================================================================= |
723 | |
724 | Handle(PGeom2d_Line) MgtGeom2d::Translate(const Handle(Geom2d_Line)& TObj) |
725 | { |
726 | return new PGeom2d_Line(TObj->Lin2d().Position()); |
727 | } |
728 | |
729 | //======================================================================= |
730 | //function : Translate |
731 | //purpose : Translates a PGeom2d_OffsetCurve to a Geom2d_OffsetCurve. |
732 | //======================================================================= |
733 | |
734 | Handle(Geom2d_OffsetCurve) MgtGeom2d::Translate |
735 | (const Handle(PGeom2d_OffsetCurve)& PObj) |
736 | { |
737 | return new Geom2d_OffsetCurve(MgtGeom2d::Translate(PObj->BasisCurve()), |
738 | PObj->OffsetValue()); |
739 | } |
740 | |
741 | |
742 | //======================================================================= |
743 | //function : Translate |
744 | //purpose : Translates a Geom2d_OffsetCurve to a PGeom2d_OffsetCurve. |
745 | //======================================================================= |
746 | |
747 | Handle(PGeom2d_OffsetCurve) MgtGeom2d::Translate |
748 | (const Handle(Geom2d_OffsetCurve)& TObj) |
749 | { |
750 | return new PGeom2d_OffsetCurve(MgtGeom2d::Translate(TObj->BasisCurve()), |
751 | TObj->Offset()); |
752 | } |
753 | |
754 | |
755 | //======================================================================= |
756 | //function : Translate |
757 | //purpose : Translates a PGeom2d_Parabola to a Geom2d_Parabola. |
758 | //======================================================================= |
759 | |
760 | Handle(Geom2d_Parabola) MgtGeom2d::Translate |
761 | (const Handle(PGeom2d_Parabola)& PObj) |
762 | { |
763 | return new Geom2d_Parabola(PObj->Position(), |
764 | PObj->FocalLength()); |
765 | } |
766 | |
767 | |
768 | //======================================================================= |
769 | //function : Translate |
770 | //purpose : Translates a Geom2d_Parabola to a PGeom2d_Parabola. |
771 | //======================================================================= |
772 | |
773 | Handle(PGeom2d_Parabola) MgtGeom2d::Translate |
774 | (const Handle(Geom2d_Parabola)& TObj) |
775 | { |
776 | return new PGeom2d_Parabola(TObj->Position(), |
777 | TObj->Focal()); |
778 | } |
779 | |
780 | //======================================================================= |
781 | //function : Translate |
782 | //purpose : Translates a PGeom2d_Point to a Geom2d_Point. |
783 | // Optimized valid until new subtypes of Geom2dPoint exist |
784 | //======================================================================= |
785 | |
786 | Handle(Geom2d_Point) MgtGeom2d::Translate |
787 | (const Handle(PGeom2d_Point)& PObj) |
788 | { |
789 | /* |
790 | Handle(Geom2d_Point) Geom2dP; |
791 | Handle(Standard_Type) PointType = PObj->DynamicType(); |
792 | |
793 | if (PointType == STANDARD_TYPE(PGeom2d_CartesianPoint)) { |
794 | Handle(PGeom2d_CartesianPoint) PCPoint = |
795 | Handle(PGeom2d_CartesianPoint)::DownCast(PObj); |
796 | Geom2dP = MgtGeom2d::Translate(PCPoint); |
797 | } |
798 | return Geom2dP; |
799 | */ |
800 | Handle(PGeom2d_CartesianPoint)& PCPoint = |
801 | (Handle(PGeom2d_CartesianPoint)&) PObj; |
802 | return new Geom2d_CartesianPoint(PCPoint->Pnt()); |
803 | } |
804 | |
805 | |
806 | //======================================================================= |
807 | //function : Translate |
808 | //purpose : Translates a Geom2d_Point to a PGeom2d_Point. |
809 | // Optimized valid until new subtypes of Geom2dPoint exist |
810 | //======================================================================= |
811 | |
812 | Handle(PGeom2d_Point) MgtGeom2d::Translate |
813 | (const Handle(Geom2d_Point)& TObj) |
814 | { |
815 | /* |
816 | Handle(PGeom2d_Point) PGeom2dP; |
817 | Handle(Standard_Type) PointType = TObj->DynamicType(); |
818 | |
819 | if (PointType == STANDARD_TYPE(Geom2d_CartesianPoint)) { |
820 | Handle(Geom2d_CartesianPoint) TCPoint = |
821 | Handle(Geom2d_CartesianPoint)::DownCast(TObj); |
822 | PGeom2dP = MgtGeom2d::Translate(TCPoint); |
823 | } |
824 | return PGeom2dP; |
825 | */ |
826 | Handle(Geom2d_CartesianPoint)& TCPoint = |
827 | (Handle(Geom2d_CartesianPoint)&) TObj; |
828 | return new PGeom2d_CartesianPoint(TCPoint->Pnt2d()); |
829 | } |
830 | |
831 | |
832 | |
833 | //======================================================================= |
834 | //function : Translate |
835 | //purpose : Translates a PGeom2d_Transformation to a Geom2d_Transformation. |
836 | //======================================================================= |
837 | |
838 | Handle(Geom2d_Transformation) MgtGeom2d::Translate |
839 | (const Handle(PGeom2d_Transformation)& PObj) |
840 | { return new Geom2d_Transformation(PObj->Trsf()); } |
841 | |
842 | |
843 | //======================================================================= |
844 | //function : Translate |
845 | //purpose : Translates a Geom2d_Transformation to a PGeom2d_Transformation. |
846 | //======================================================================= |
847 | |
848 | Handle(PGeom2d_Transformation) MgtGeom2d::Translate |
849 | (const Handle(Geom2d_Transformation)& TObj) |
850 | { return new PGeom2d_Transformation(TObj->Trsf2d()); } |
851 | |
852 | |
853 | //======================================================================= |
854 | //function : Translate |
855 | //purpose : Translates a PGeom2d_TrimmedCurve to a Geom2d_TrimmedCurve. |
856 | //======================================================================= |
857 | |
858 | Handle(Geom2d_TrimmedCurve) MgtGeom2d::Translate |
859 | (const Handle(PGeom2d_TrimmedCurve)& PObj) |
860 | { |
861 | return new Geom2d_TrimmedCurve(MgtGeom2d::Translate(PObj->BasisCurve()), |
862 | PObj->FirstU(), |
863 | PObj->LastU(), |
864 | Standard_True); // Warning : will desappear |
865 | } |
866 | |
867 | |
868 | //======================================================================= |
869 | //function : Translate |
870 | //purpose : Translates a Geom2d_TrimmedCurve to a PGeom2d_TrimmedCurve. |
871 | //======================================================================= |
872 | |
873 | Handle(PGeom2d_TrimmedCurve) MgtGeom2d::Translate |
874 | (const Handle(Geom2d_TrimmedCurve)& TObj) |
875 | { |
876 | return new PGeom2d_TrimmedCurve(MgtGeom2d::Translate(TObj->BasisCurve()), |
877 | TObj->FirstParameter(), |
878 | TObj->LastParameter()); |
879 | } |
880 | |
881 | |
882 | //======================================================================= |
883 | //function : Translate |
884 | //purpose : Translates a PGeom2d_VectorWithMagnitude to a |
885 | // Geom2d_VectorWithMagnitude. |
886 | //======================================================================= |
887 | |
888 | Handle(Geom2d_VectorWithMagnitude) MgtGeom2d::Translate |
889 | (const Handle(PGeom2d_VectorWithMagnitude)& PObj) |
890 | { return new Geom2d_VectorWithMagnitude(PObj->Vec()); } |
891 | |
892 | |
893 | //======================================================================= |
894 | //function : Translate |
895 | //purpose : Translates a Geom2d_VectorWithMagnitude to a |
896 | // PGeom2d_VectorWithMagnitude. |
897 | //======================================================================= |
898 | |
899 | Handle(PGeom2d_VectorWithMagnitude) MgtGeom2d::Translate |
900 | (const Handle(Geom2d_VectorWithMagnitude)& TObj) |
901 | { return new PGeom2d_VectorWithMagnitude(TObj->Vec2d()); } |