0025266: Debug statements in the source are getting flushed on to the console
[occt.git] / src / MgtGeom / MgtGeom.cxx
1 // Created on: 1993-03-05
2 // Created by: Philippe DAUTRY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <MgtGeom.ixx>
18
19 #include <Standard_Type.hxx>
20
21 #include <PColStd_HArray1OfInteger.hxx>
22 #include <PColStd_HArray2OfInteger.hxx>
23 #include <PColStd_HArray1OfReal.hxx>
24 #include <PColStd_HArray2OfReal.hxx>
25
26 #include <TColStd_Array1OfInteger.hxx>
27 #include <TColStd_Array2OfInteger.hxx>
28 #include <TColStd_HArray1OfInteger.hxx>
29
30 #include <TColStd_Array1OfReal.hxx>
31 #include <TColStd_Array2OfReal.hxx>
32 #include <TColStd_HArray1OfReal.hxx>
33 #include <TColStd_HArray2OfReal.hxx>
34
35 #include <TColgp_Array1OfPnt.hxx>
36 #include <TColgp_Array2OfPnt.hxx>
37 #include <TColgp_HArray1OfPnt.hxx>
38 #include <TColgp_HArray2OfPnt.hxx>
39
40 #include <PColgp_HArray1OfPnt.hxx>
41 #include <PColgp_HArray2OfPnt.hxx>
42
43 #include <gp_Vec.hxx>
44 #include <gp_Circ.hxx>
45 #include <gp_Ax1.hxx>
46
47 //modif wok++
48 #include <Standard_NullObject.hxx>
49 #include <gp_Lin.hxx>
50 #include <gp_Pln.hxx>
51
52 // *******************************************************************
53 // The following methods are subroutines used to copy elements
54 // from structures to other structures, as array1 or array2.
55 // *******************************************************************
56
57 // *******************************************************************
58 // Structures from TCollection to structures from PCollection.
59 // *******************************************************************
60
61 //=======================================================================
62 //function : ArrayCopy
63 //purpose  : Copy the gp_Pnt
64 //           from an Array1 from TColgp (TCollection)
65 //           to an HArray1 from PColgp (PCollection)
66 //=======================================================================
67
68 static Handle(PColgp_HArray1OfPnt) ArrayCopy
69        (const TColgp_Array1OfPnt& TArray)
70 {
71   Standard_Integer Lower = TArray.Lower();
72   Standard_Integer Upper = TArray.Upper();
73   Standard_Integer Index;
74   Handle(PColgp_HArray1OfPnt) PArray = new PColgp_HArray1OfPnt(Lower, Upper);
75   for (Index = Lower; Index <= Upper; Index++) {
76     PArray->SetValue(Index, TArray(Index));
77   }
78   return PArray;
79 }
80
81 //=======================================================================
82 //function : ArrayCopy
83 //purpose  : Copy the gp_Pnt
84 //           from an Array2 from TColgp (TCollection)
85 //           to an HArray2 from PColgp (PCollection)
86 //=======================================================================
87
88 static Handle(PColgp_HArray2OfPnt) ArrayCopy
89        (const TColgp_Array2OfPnt& TArray)
90 {
91   Standard_Integer LowerRow = TArray.LowerRow();
92   Standard_Integer UpperRow = TArray.UpperRow();
93   Standard_Integer LowerCol = TArray.LowerCol();
94   Standard_Integer UpperCol = TArray.UpperCol();
95   Standard_Integer IndexRow, IndexCol;
96   Handle(PColgp_HArray2OfPnt) PArray =
97     new PColgp_HArray2OfPnt(LowerRow, UpperRow, LowerCol, UpperCol);
98   for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) {
99     for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) {
100       PArray->SetValue(IndexRow, IndexCol, TArray(IndexRow, IndexCol));
101     }
102   }
103   return PArray;
104 }
105
106 //=======================================================================
107 //function : ArrayCopy
108 //purpose  : Copy the Standard_Real
109 //           from an Array1 from TColStd (TCollection)
110 //           to an SingleArray from PCollection
111 //=======================================================================
112
113 static Handle(PColStd_HArray1OfReal) ArrayCopy
114        (const TColStd_Array1OfReal& TArray)
115 {
116   Standard_Integer Lower = TArray.Lower();
117   Standard_Integer Upper = TArray.Upper();
118   Standard_Integer Index;
119   Handle(PColStd_HArray1OfReal) PArray =
120     new PColStd_HArray1OfReal(Lower, Upper);
121   for (Index = Lower; Index <= Upper; Index++) {
122     PArray->SetValue(Index, TArray(Index));
123   }
124   return PArray;
125 }
126
127 //=======================================================================
128 //function : ArrayCopy
129 //purpose  : Copy the Standard_Real
130 //           from an Array2 from TColStd (TCollection)
131 //           to an DoubleArray from PCollection
132 //=======================================================================
133
134 static Handle(PColStd_HArray2OfReal) ArrayCopy
135        (const TColStd_Array2OfReal& TArray)
136 {
137   Standard_Integer LowerRow = TArray.LowerRow();
138   Standard_Integer UpperRow = TArray.UpperRow();
139   Standard_Integer LowerCol = TArray.LowerCol();
140   Standard_Integer UpperCol = TArray.UpperCol();
141   Standard_Integer IndexRow, IndexCol;
142   Handle(PColStd_HArray2OfReal) PArray =
143     new PColStd_HArray2OfReal(LowerRow, UpperRow, LowerCol, UpperCol);
144   for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) {
145     for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) {
146       PArray->SetValue(IndexRow, IndexCol, TArray(IndexRow, IndexCol));
147     }
148   }
149   return PArray;
150 }
151
152 //=======================================================================
153 //function : ArrayCopy
154 //purpose  : Copy the Standard_Integer
155 //           from an Array1 from TColStd (TCollection)
156 //           to an SingleArray from PCollection
157 //=======================================================================
158
159 static Handle(PColStd_HArray1OfInteger) ArrayCopy
160        (const TColStd_Array1OfInteger& TArray)
161 {
162   Standard_Integer Lower = TArray.Lower();
163   Standard_Integer Upper = TArray.Upper();
164   Standard_Integer Index;
165   Handle(PColStd_HArray1OfInteger) PArray =
166     new PColStd_HArray1OfInteger(Lower, Upper);
167   for (Index = Lower; Index <= Upper; Index++) {
168     PArray->SetValue(Index, TArray(Index));
169   }
170   return PArray;
171 }
172
173 // *******************************************************************
174 // Structures from PCollection to structures from TCollection.
175 // *******************************************************************
176
177 //=======================================================================
178 //function : ArrayCopy
179 //purpose  : Copy the gp_Pnt
180 //           from an HArray1 from PColgp (PCollection)
181 //           to an Array1 from TColgp (TCollection)
182 //=======================================================================
183
184 static void ArrayCopy
185   (const Handle(PColgp_HArray1OfPnt)& PArray,
186    TColgp_Array1OfPnt& TArray)
187 {
188   Standard_Integer Lower = PArray->Lower();
189   Standard_Integer Upper = PArray->Upper();
190   Standard_Integer Index;
191   for (Index = Lower; Index <= Upper; Index++) {
192     TArray(Index) = PArray->Value(Index);
193   }
194 }
195
196 //=======================================================================
197 //function : ArrayCopy
198 //purpose  : Copy the gp_Pnt
199 //           from an HArray2 from PColgp (PCollection)
200 //           to an Array2 from TColgp (TCollection)
201 //=======================================================================
202
203 static void ArrayCopy
204   (const Handle(PColgp_HArray2OfPnt)& PArray,
205    TColgp_Array2OfPnt& TArray)
206 {
207   Standard_Integer LowerRow = TArray.LowerRow();
208   Standard_Integer UpperRow = TArray.UpperRow();
209   Standard_Integer LowerCol = TArray.LowerCol();
210   Standard_Integer UpperCol = TArray.UpperCol();
211   Standard_Integer IndexRow, IndexCol;
212   for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) {
213     for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) {
214       TArray(IndexRow, IndexCol) = PArray->Value(IndexRow, IndexCol);
215     }
216   }
217 }
218
219 //=======================================================================
220 //function : ArrayCopy
221 //purpose  : Copy the Standard_Real
222 //           from an SingleArray from PCollection
223 //           to an Array1 from TColStd (TCollection)
224 //=======================================================================
225
226 static void ArrayCopy
227   (const Handle(PColStd_HArray1OfReal)& PArray,
228    TColStd_Array1OfReal& TArray)
229 {
230   Standard_Integer Lower = PArray->Lower();
231   Standard_Integer Upper = PArray->Upper();
232   Standard_Integer Index;
233   for (Index = Lower; Index <= Upper; Index++) {
234     TArray(Index) = PArray->Value(Index);
235   }
236 }
237
238 //=======================================================================
239 //function : ArrayCopy
240 //purpose  : Copy the Standard_Real
241 //           from an DoubleArray from PCollection
242 //           to an Array2 from TColStd (TCollection)
243 //=======================================================================
244
245 static void ArrayCopy
246   (const Handle(PColStd_HArray2OfReal)& PArray,
247    TColStd_Array2OfReal& TArray)
248 {
249   Standard_Integer LowerRow = TArray.LowerRow();
250   Standard_Integer UpperRow = TArray.UpperRow();
251   Standard_Integer LowerCol = TArray.LowerCol();
252   Standard_Integer UpperCol = TArray.UpperCol();
253   Standard_Integer IndexRow, IndexCol;
254   for (IndexRow = LowerRow; IndexRow <= UpperRow; IndexRow++) {
255     for (IndexCol = LowerCol; IndexCol <= UpperCol; IndexCol++) {
256       TArray(IndexRow, IndexCol) = PArray->Value(IndexRow, IndexCol);
257     }
258   }
259 }
260
261 //=======================================================================
262 //function : ArrayCopy
263 //purpose  : Copy the Standard_Integer
264 //           from an SingleArray from PCollection
265 //           to an Array1 from TColStd (TCollection)
266 //=======================================================================
267
268 static void ArrayCopy
269   (const Handle(PColStd_HArray1OfInteger)& PArray,
270    TColStd_Array1OfInteger& TArray)
271 {
272   Standard_Integer Lower = PArray->Lower();
273   Standard_Integer Upper = PArray->Upper();
274   Standard_Integer Index;
275   for (Index = Lower; Index <= Upper; Index++) {
276     TArray(Index) = PArray->Value(Index);
277   }
278 }
279
280
281
282 // *******************************************************************
283 // Here is the implementation of the package methods.
284 // *******************************************************************
285
286
287 //=======================================================================
288 //function : Translate
289 //purpose  : Translates a PGeom_Axis1Placement to a Geom_Axis1Placement.
290 //=======================================================================
291
292 Handle(Geom_Axis1Placement)  MgtGeom::Translate
293        (const Handle(PGeom_Axis1Placement)& PObj)
294 {
295   return new Geom_Axis1Placement(PObj->Axis());
296 }
297
298
299 //=======================================================================
300 //function : Translate
301 //purpose  : Translates a Geom_Axis1Placement to a PGeom_Axis1Placement.
302 //=======================================================================
303
304 Handle(PGeom_Axis1Placement)  MgtGeom::Translate
305        (const Handle(Geom_Axis1Placement)& TObj)
306 {
307   return new PGeom_Axis1Placement(TObj->Axis());
308 }
309
310
311 //=======================================================================
312 //function : Translate
313 //purpose  : Translates a PGeom_Axis2Placement to a Geom_Axis2Placement.
314 //=======================================================================
315
316 Handle(Geom_Axis2Placement)  MgtGeom::Translate
317        (const Handle(PGeom_Axis2Placement)& PObj)
318 {
319   return new Geom_Axis2Placement(PObj->Axis().Location(),
320                                  PObj->Axis().Direction(),
321                                  PObj->XDirection());
322 }
323
324
325 //=======================================================================
326 //function : Translate
327 //purpose  : Translates a Geom_Axis2Placement to a PGeom_Axis2Placement.
328 //=======================================================================
329
330 Handle(PGeom_Axis2Placement)  MgtGeom::Translate
331        (const Handle(Geom_Axis2Placement)& TObj)
332 {
333   return new PGeom_Axis2Placement(TObj->Axis(),
334                                   TObj->XDirection());
335 }
336
337
338 //=======================================================================
339 //function : Translate
340 //purpose  : Translates a PGeom_BSplineCurve to a Geom_BSplineCurve.
341 //=======================================================================
342
343 Handle(Geom_BSplineCurve)  MgtGeom::Translate
344        (const Handle(PGeom_BSplineCurve)& PObj)
345 {
346   Handle(Geom_BSplineCurve)  TBSplC;
347
348   Handle(PColgp_HArray1OfPnt) oldPoles = PObj->Poles();
349   TColgp_Array1OfPnt newPoles (oldPoles->Lower(),oldPoles->Upper());
350   ArrayCopy(oldPoles,newPoles);
351
352   Handle(PColStd_HArray1OfInteger) oldMult = PObj->Multiplicities();
353   TColStd_Array1OfInteger newMultiplicities(oldMult->Lower(),oldMult->Upper());
354   ArrayCopy(oldMult,newMultiplicities);
355
356   Handle(PColStd_HArray1OfReal) oldKnots = PObj->Knots();
357   TColStd_Array1OfReal newKnots (oldKnots->Lower(),oldKnots->Upper());
358   ArrayCopy(oldKnots,newKnots);
359
360   if (PObj->Rational()) {
361     Handle(PColStd_HArray1OfReal) oldWeights = PObj->Weights();
362     TColStd_Array1OfReal newWeights (oldWeights->Lower(),oldWeights->Upper());
363     ArrayCopy(oldWeights,newWeights);
364     TBSplC = new Geom_BSplineCurve
365       (newPoles, newWeights, newKnots, newMultiplicities, PObj->SpineDegree(),PObj->Periodic());
366   }
367   else {
368     TBSplC = new Geom_BSplineCurve
369       (newPoles, newKnots, newMultiplicities, PObj->SpineDegree(),PObj->Periodic());
370   }
371 //  if (PObj->Periodic()) TBSplC->SetPeriodic();
372   return TBSplC;
373 }
374
375
376 //=======================================================================
377 //function : Translate
378 //purpose  : Translates a Geom_BSplineCurve to a PGeom_BSplineCurve.
379 //=======================================================================
380
381 Handle(PGeom_BSplineCurve)  MgtGeom::Translate
382        (const Handle(Geom_BSplineCurve)& TObj)
383 {
384   Standard_Integer Upper;
385
386   Upper = TObj->NbPoles();
387
388   TColgp_Array1OfPnt oldPoles(1, Upper);
389   TObj->Poles(oldPoles);
390   Handle(PColgp_HArray1OfPnt) newPPoles = ArrayCopy(oldPoles);
391   
392   Handle(PColStd_HArray1OfReal) newPWeights;
393   if (TObj->IsRational()) {
394     TColStd_Array1OfReal oldWeights(1, Upper);
395     TObj->Weights(oldWeights);
396     newPWeights = ArrayCopy(oldWeights);
397   }
398   
399   Upper = TObj->NbKnots();
400
401   TColStd_Array1OfReal oldKnots(1, Upper);
402   TObj->Knots(oldKnots);
403   Handle(PColStd_HArray1OfReal) newPKnots = ArrayCopy(oldKnots);
404
405   TColStd_Array1OfInteger oldMultiplicities(1, Upper);
406   TObj->Multiplicities(oldMultiplicities);
407   Handle(PColStd_HArray1OfInteger) newPMultiplicities =
408     ArrayCopy(oldMultiplicities);
409   
410   return new PGeom_BSplineCurve(TObj->IsRational(),
411                                 TObj->IsPeriodic(),
412                                 TObj->Degree(),
413                                 newPPoles,
414                                 newPWeights,
415                                 newPKnots,
416                                 newPMultiplicities);
417 }
418
419
420 //=======================================================================
421 //function : Translate
422 //purpose  : Translates a PGeom_BSplineSurface to a Geom_BSplineSurface.
423 //=======================================================================
424
425 Handle(Geom_BSplineSurface)  MgtGeom::Translate
426        (const Handle(PGeom_BSplineSurface)& PObj)
427 {
428   Handle(Geom_BSplineSurface)  TBSplS;
429
430   Handle(PColgp_HArray2OfPnt) oldPoles = PObj->Poles();
431   TColgp_Array2OfPnt newPoles (oldPoles->LowerRow(),oldPoles->UpperRow(),
432                                oldPoles->LowerCol(),oldPoles->UpperCol());
433   ArrayCopy(oldPoles,newPoles);
434
435   Handle(PColStd_HArray1OfInteger) oldUMult = PObj->UMultiplicities();
436   TColStd_Array1OfInteger
437     newUMultiplicities (oldUMult->Lower(),oldUMult->Upper());
438   ArrayCopy(oldUMult,newUMultiplicities);
439
440   Handle(PColStd_HArray1OfInteger) oldVMult = PObj->VMultiplicities();
441   TColStd_Array1OfInteger
442     newVMultiplicities (oldVMult->Lower(),oldVMult->Upper());
443   ArrayCopy(oldVMult,newVMultiplicities);
444
445   Handle(PColStd_HArray1OfReal) oldUKnots = PObj->UKnots();
446   TColStd_Array1OfReal newUKnots (oldUKnots->Lower(),oldUKnots->Upper());
447   ArrayCopy(oldUKnots,newUKnots);
448
449   Handle(PColStd_HArray1OfReal) oldVKnots = PObj->VKnots();
450   TColStd_Array1OfReal newVKnots (oldVKnots->Lower(),oldVKnots->Upper());
451   ArrayCopy(oldVKnots,newVKnots);
452
453   if (!PObj->URational() && !PObj->VRational()) {
454     TBSplS = new Geom_BSplineSurface
455       (newPoles,
456        newUKnots, newVKnots,
457        newUMultiplicities,newVMultiplicities,
458        PObj->USpineDegree(),
459        PObj->VSpineDegree(),
460        PObj->UPeriodic(),
461        PObj->VPeriodic());
462   }
463   else {
464     Handle(PColStd_HArray2OfReal) oldWeights = PObj->Weights();
465     TColStd_Array2OfReal
466       newWeights (oldWeights->LowerRow(),oldWeights->UpperRow(),
467                   oldWeights->LowerCol(),oldWeights->UpperCol());
468     ArrayCopy(oldWeights,newWeights);
469     TBSplS = new Geom_BSplineSurface
470       (newPoles,
471        newWeights,
472        newUKnots, newVKnots,
473        newUMultiplicities,newVMultiplicities,
474        PObj->USpineDegree(),
475        PObj->VSpineDegree(),
476        PObj->UPeriodic(),
477        PObj->VPeriodic());
478   }
479 //  if (PObj->UPeriodic()) TBSplS->SetUPeriodic();
480 //  if (PObj->VPeriodic()) TBSplS->SetVPeriodic();
481   return TBSplS;
482 }
483
484
485 //=======================================================================
486 //function : Translate
487 //purpose  : Translates a Geom_BSplineSurface to a PGeom_BSplineSurface.
488 //=======================================================================
489
490 Handle(PGeom_BSplineSurface)  MgtGeom::Translate
491        (const Handle(Geom_BSplineSurface)& TObj)
492 {
493   Standard_Integer UpperU, UpperV;
494
495   UpperU = TObj->NbUPoles();
496   UpperV = TObj->NbVPoles();
497
498   TColgp_Array2OfPnt oldPoles(1, UpperU, 1, UpperV);
499   TObj->Poles(oldPoles);
500   Handle(PColgp_HArray2OfPnt) newPPoles =
501     ArrayCopy(oldPoles);
502   
503   Handle(PColStd_HArray2OfReal) newPWeights;
504   if (TObj->IsURational() || TObj->IsVRational()) {
505     TColStd_Array2OfReal oldWeights(1, UpperU, 1, UpperV);
506     TObj->Weights(oldWeights);
507     newPWeights = ArrayCopy(oldWeights);
508   }
509   
510   UpperU = TObj->NbUKnots();
511
512   TColStd_Array1OfReal oldUKnots(1, UpperU);
513   TObj->UKnots(oldUKnots);
514   Handle(PColStd_HArray1OfReal) newPUKnots =
515     ArrayCopy(oldUKnots);
516   
517   TColStd_Array1OfInteger oldUMultiplicities(1, UpperU);
518   TObj->UMultiplicities(oldUMultiplicities);
519   Handle(PColStd_HArray1OfInteger) newPUMultiplicities =
520     ArrayCopy(oldUMultiplicities);
521   
522   UpperV = TObj->NbVKnots();
523
524   TColStd_Array1OfReal oldVKnots(1, UpperV);
525   TObj->VKnots(oldVKnots);
526   Handle(PColStd_HArray1OfReal) newPVKnots =
527     ArrayCopy(oldVKnots);
528   
529   TColStd_Array1OfInteger oldVMultiplicities(1, UpperV);
530   TObj->VMultiplicities(oldVMultiplicities);
531   Handle(PColStd_HArray1OfInteger) newPVMultiplicities =
532     ArrayCopy(oldVMultiplicities);
533   
534   return new PGeom_BSplineSurface(TObj->IsURational(),
535                                   TObj->IsVRational(),
536                                   TObj->IsUPeriodic(),
537                                   TObj->IsVPeriodic(),
538                                   TObj->UDegree(),
539                                   TObj->VDegree(),
540                                   newPPoles,
541                                   newPWeights,
542                                   newPUKnots,
543                                   newPVKnots,
544                                   newPUMultiplicities,
545                                   newPVMultiplicities);
546 }
547
548
549 //=======================================================================
550 //function : Translate
551 //purpose  : Translates a PGeom_BezierCurve to a Geom_BezierCurve.
552 //=======================================================================
553
554 Handle(Geom_BezierCurve)  MgtGeom::Translate
555        (const Handle(PGeom_BezierCurve)& PObj)
556 {
557   Handle(Geom_BezierCurve) TBzC;
558
559   Handle(PColgp_HArray1OfPnt) oldPoles = PObj->Poles();
560   TColgp_Array1OfPnt newPoles (oldPoles->Lower(),oldPoles->Upper());
561   ArrayCopy(oldPoles,newPoles);
562
563   if (PObj->Rational()) {
564     Handle(PColStd_HArray1OfReal) oldWeights = PObj->Weights();
565     TColStd_Array1OfReal newWeights (oldWeights->Lower(),oldWeights->Upper());
566     ArrayCopy(oldWeights,newWeights);
567     TBzC = new Geom_BezierCurve(newPoles, newWeights);
568   }
569   else {
570     TBzC = new Geom_BezierCurve(newPoles);
571   }
572   return TBzC;
573 }
574
575
576 //=======================================================================
577 //function : Translate
578 //purpose  : Translates a Geom_BezierCurve to a PGeom_BezierCurve.
579 //=======================================================================
580
581 Handle(PGeom_BezierCurve)  MgtGeom::Translate
582        (const Handle(Geom_BezierCurve)& TObj)
583 {
584   Standard_Integer Upper;
585
586   Upper = TObj->NbPoles();
587
588   TColgp_Array1OfPnt oldPoles(1, Upper);
589   TObj->Poles(oldPoles);
590   Handle(PColgp_HArray1OfPnt) newPPoles = ArrayCopy(oldPoles);
591   
592   Handle(PColStd_HArray1OfReal) newPWeights;
593   if (TObj->IsRational()) {
594     TColStd_Array1OfReal oldWeights(1, Upper);
595     TObj->Weights(oldWeights);
596     newPWeights = ArrayCopy(oldWeights);
597   }
598   
599   return new PGeom_BezierCurve(newPPoles,
600                                newPWeights,
601                                TObj->IsRational());
602 }
603
604
605 //=======================================================================
606 //function : Translate
607 //purpose  : Translates a PGeom_BezierSurface to a Geom_BezierSurface.
608 //=======================================================================
609
610 Handle(Geom_BezierSurface)  MgtGeom::Translate
611        (const Handle(PGeom_BezierSurface)& PObj)
612 {
613   Handle(Geom_BezierSurface)  TBzS;
614
615   Handle(PColgp_HArray2OfPnt) oldPoles = PObj->Poles();
616   TColgp_Array2OfPnt newPoles (oldPoles->LowerRow(),oldPoles->UpperRow(),
617                                oldPoles->LowerCol(),oldPoles->UpperCol());
618   ArrayCopy(oldPoles,newPoles);
619
620   if (!PObj->URational() && !PObj->VRational()) {
621     TBzS = new Geom_BezierSurface(newPoles);
622   }
623   else {
624     Handle(PColStd_HArray2OfReal) oldWeights = PObj->Weights();
625     TColStd_Array2OfReal
626       newWeights (oldWeights->LowerRow(),oldWeights->UpperRow(),
627                   oldWeights->LowerCol(),oldWeights->UpperCol());
628     ArrayCopy(oldWeights,newWeights);
629
630     TBzS = new Geom_BezierSurface(newPoles, newWeights);
631   }
632   return TBzS;
633 }
634
635
636 //=======================================================================
637 //function : Translate
638 //purpose  : Translates a Geom_BezierSurface to a PGeom_BezierSurface.
639 //=======================================================================
640
641 Handle(PGeom_BezierSurface)  MgtGeom::Translate(const Handle(Geom_BezierSurface)& TObj)
642 {
643   Standard_Integer UpperU, UpperV;
644
645   UpperU = TObj->NbUPoles();
646   UpperV = TObj->NbVPoles();
647
648   TColgp_Array2OfPnt oldPoles(1, UpperU, 1, UpperV);
649   TObj->Poles(oldPoles);
650   Handle(PColgp_HArray2OfPnt) newPPoles =
651     ArrayCopy(oldPoles);
652   
653   Handle(PColStd_HArray2OfReal) newPWeights;
654   if (TObj->IsURational() || TObj->IsVRational()) {
655     TColStd_Array2OfReal oldWeights(1, UpperU, 1, UpperV);
656     TObj->Weights(oldWeights);
657     newPWeights = ArrayCopy(oldWeights);
658   }
659   
660   return new PGeom_BezierSurface(TObj->IsURational(),
661                                  TObj->IsVRational(),
662                                  newPPoles,
663                                  newPWeights);
664 }
665
666
667 //=======================================================================
668 //function : Translate
669 //purpose  : Translates a PGeom_CartesianPoint to a Geom_CartesianPoint.
670 //=======================================================================
671
672 Handle(Geom_CartesianPoint)  MgtGeom::Translate
673        (const Handle(PGeom_CartesianPoint)& PObj)
674 { return new Geom_CartesianPoint(PObj->Pnt()); }
675
676
677 //=======================================================================
678 //function : Translate
679 //purpose  : Translates a Geom_CartesianPoint to a PGeom_CartesianPoint.
680 //=======================================================================
681
682 Handle(PGeom_CartesianPoint)  MgtGeom::Translate
683        (const Handle(Geom_CartesianPoint)& TObj)
684 { return new PGeom_CartesianPoint(TObj->Pnt()); }
685
686
687 //=======================================================================
688 //function : Translate
689 //purpose  : Translates a PGeom_Circle to a Geom_Circle.
690 //=======================================================================
691
692 Handle(Geom_Circle)  MgtGeom::Translate(const Handle(PGeom_Circle)& PObj)
693 {
694   return new Geom_Circle(PObj->Position(),
695                          PObj->Radius());
696 }
697
698
699 //=======================================================================
700 //function : Translate
701 //purpose  : Translates a Geom_Circle to a PGeom_Circle.
702 //=======================================================================
703
704 Handle(PGeom_Circle)  MgtGeom::Translate(const Handle(Geom_Circle)& TObj)
705 {
706   gp_Circ cir = TObj->Circ();
707   return new PGeom_Circle(cir.Position(),cir.Radius());
708 }
709
710
711 //=======================================================================
712 //function : Translate
713 //purpose  : Translates a PGeom_ConicalSurface to a Geom_ConicalSurface.
714 //=======================================================================
715
716 Handle(Geom_ConicalSurface)  MgtGeom::Translate
717        (const Handle(PGeom_ConicalSurface)& PObj)
718 {
719   return new Geom_ConicalSurface(PObj->Position(),
720                                  PObj->SemiAngle(),
721                                  PObj->Radius());
722 }
723
724
725 //=======================================================================
726 //function : Translate
727 //purpose  : Translates a Geom_ConicalSurface to a PGeom_ConicalSurface.
728 //=======================================================================
729
730 Handle(PGeom_ConicalSurface)  MgtGeom::Translate
731        (const Handle(Geom_ConicalSurface)& TObj)
732 {
733   return new PGeom_ConicalSurface(TObj->Position(),
734                                   TObj->RefRadius(),
735                                   TObj->SemiAngle());
736 }
737
738
739 //=======================================================================
740 //function : Translate
741 //purpose  : Translates a PGeom_Curve to a Geom_Curve.
742 //=======================================================================
743
744 Handle(Geom_Curve)  MgtGeom::Translate(const Handle(PGeom_Curve)& PObj)
745 {
746   Handle(Standard_Type) CurveType = PObj->DynamicType();
747   
748   if (CurveType == STANDARD_TYPE(PGeom_Line)) {
749     Handle(PGeom_Line)& TLine = 
750       (Handle(PGeom_Line)&) PObj;
751     return MgtGeom::Translate(TLine);
752   }
753   else if (CurveType ==  STANDARD_TYPE(PGeom_Circle)) {
754     Handle(PGeom_Circle)& TCircle = 
755       (Handle(PGeom_Circle)&) PObj;
756     return MgtGeom::Translate(TCircle);
757   }
758   else if (CurveType ==  STANDARD_TYPE(PGeom_Ellipse)) {
759     Handle(PGeom_Ellipse)& TEllipse = 
760       (Handle(PGeom_Ellipse)&) PObj;
761     return MgtGeom::Translate(TEllipse);
762   }
763   else if (CurveType ==  STANDARD_TYPE(PGeom_Hyperbola)) {
764     Handle(PGeom_Hyperbola)& THyperbola = 
765       (Handle(PGeom_Hyperbola)&) PObj;
766     return MgtGeom::Translate(THyperbola);
767   }
768   else if (CurveType ==  STANDARD_TYPE(PGeom_Parabola)) {
769     Handle(PGeom_Parabola)& TParabola = 
770       (Handle(PGeom_Parabola)&) PObj;
771     return MgtGeom::Translate(TParabola);
772   }
773   else if (CurveType ==  STANDARD_TYPE(PGeom_BezierCurve)) {
774     Handle(PGeom_BezierCurve)& TBezierCurve = 
775       (Handle(PGeom_BezierCurve)&) PObj;
776     return MgtGeom::Translate(TBezierCurve);
777   }
778   else if (CurveType ==  STANDARD_TYPE(PGeom_BSplineCurve)) {
779     Handle(PGeom_BSplineCurve)& TBSplineCurve = 
780       (Handle(PGeom_BSplineCurve)&) PObj;
781     return MgtGeom::Translate(TBSplineCurve);
782   }
783   else if (CurveType ==  STANDARD_TYPE(PGeom_TrimmedCurve)) {
784     Handle(PGeom_TrimmedCurve)& TTrimmedCurve = 
785       (Handle(PGeom_TrimmedCurve)&) PObj;
786     return MgtGeom::Translate(TTrimmedCurve);
787   }
788   else if (CurveType ==  STANDARD_TYPE(PGeom_OffsetCurve)) {
789     Handle(PGeom_OffsetCurve)& TOffsetCurve = 
790       (Handle(PGeom_OffsetCurve)&) PObj;
791     return MgtGeom::Translate(TOffsetCurve);
792   }
793   else {
794 #ifdef MGTGEOM_DEB
795     cout << "MgtGeom : Unknown curve type ???? : " << endl;
796 #endif
797     Standard_NullObject::Raise("No mapping for the current Persistent Curve");
798   }
799 // POP pour NT
800   Handle(Geom_Curve) dummy;
801   return dummy;
802 }
803
804
805 //=======================================================================
806 //function : Translate
807 //purpose  : Translates a Geom_Curve to a PGeom_Curve.
808 //=======================================================================
809
810 Handle(PGeom_Curve)  MgtGeom::Translate(const Handle(Geom_Curve)& TObj)
811 {
812   Handle(Standard_Type) CurveType = TObj->DynamicType();
813
814   if (CurveType == STANDARD_TYPE(Geom_Line)) {
815     Handle(Geom_Line)& PLine = 
816       (Handle(Geom_Line)&) TObj;
817     return MgtGeom::Translate(PLine);
818   }
819   else if (CurveType ==  STANDARD_TYPE(Geom_Circle)) {
820     Handle(Geom_Circle)& PCircle = 
821       (Handle(Geom_Circle)&) TObj;
822     return MgtGeom::Translate(PCircle);
823   }
824   else if (CurveType ==  STANDARD_TYPE(Geom_Ellipse)) {
825     Handle(Geom_Ellipse)& PEllipse = 
826       (Handle(Geom_Ellipse)&) TObj;
827     return MgtGeom::Translate(PEllipse);
828   }
829   else if (CurveType ==  STANDARD_TYPE(Geom_Hyperbola)) {
830     Handle(Geom_Hyperbola)& PHyperbola = 
831       (Handle(Geom_Hyperbola)&) TObj;
832     return MgtGeom::Translate(PHyperbola);
833   }
834   else if (CurveType ==  STANDARD_TYPE(Geom_Parabola)) {
835     Handle(Geom_Parabola)& PParabola = 
836       (Handle(Geom_Parabola)&) TObj;
837     return MgtGeom::Translate(PParabola);
838   }
839   else if (CurveType ==  STANDARD_TYPE(Geom_BezierCurve)) {
840     Handle(Geom_BezierCurve)& PBezierCurve = 
841       (Handle(Geom_BezierCurve)&) TObj;
842     return MgtGeom::Translate(PBezierCurve);
843   }
844   else if (CurveType ==  STANDARD_TYPE(Geom_BSplineCurve)) {
845     Handle(Geom_BSplineCurve)& PBSplineCurve = 
846       (Handle(Geom_BSplineCurve)&) TObj;
847     return MgtGeom::Translate(PBSplineCurve);
848   }
849   else if (CurveType ==  STANDARD_TYPE(Geom_TrimmedCurve)) {
850     Handle(Geom_TrimmedCurve)& PTrimmedCurve = 
851       (Handle(Geom_TrimmedCurve)&) TObj;
852     return MgtGeom::Translate(PTrimmedCurve);
853   }
854   else if (CurveType ==  STANDARD_TYPE(Geom_OffsetCurve)) {
855     Handle(Geom_OffsetCurve)& POffsetCurve = 
856       (Handle(Geom_OffsetCurve)&) TObj;
857     return MgtGeom::Translate(POffsetCurve);
858   }
859   else {
860 #ifdef MGTGEOM_DEB
861     cout << "MgtGeom : Unknown curve type ????"<<endl;
862 #endif
863     Standard_NullObject::Raise("No mapping for the current Transient Curve");
864
865   }
866 // POP pour NT
867   Handle(PGeom_Curve) dummy;
868   return dummy;
869 }
870
871
872 //=======================================================================
873 //function : Translate
874 //purpose  : Translates a PGeom_CylindricalSurface to a
875 //           Geom_CylindricalSurface.
876 //=======================================================================
877
878 Handle(Geom_CylindricalSurface)  MgtGeom::Translate
879        (const Handle(PGeom_CylindricalSurface)& PObj)
880 {
881   return  new Geom_CylindricalSurface(PObj->Position(),
882                                       PObj->Radius());
883 }
884
885
886 //=======================================================================
887 //function : Translate
888 //purpose  : Translates a Geom_CylindricalSurface to a PGeom_CylindricalSurface.
889 //=======================================================================
890
891 Handle(PGeom_CylindricalSurface)  MgtGeom::Translate(const Handle(Geom_CylindricalSurface)& TObj)
892 {
893   return new PGeom_CylindricalSurface(TObj->Position(),
894                                       TObj->Radius());
895 }
896
897
898 //=======================================================================
899 //function : Translate
900 //purpose  : Translates a PGeom_Direction to a Geom_Direction.
901 //=======================================================================
902
903 Handle(Geom_Direction)  MgtGeom::Translate
904        (const Handle(PGeom_Direction)& PObj)
905 {
906   gp_Vec vec = PObj->Vec();
907   return new Geom_Direction(vec.X(), vec.Y(), vec.Z()); }
908
909
910 //=======================================================================
911 //function : Translate
912 //purpose  : Translates a Geom_Direction to a PGeom_Direction.
913 //=======================================================================
914
915 Handle(PGeom_Direction)  MgtGeom::Translate
916        (const Handle(Geom_Direction)& TObj)
917 { return new PGeom_Direction(TObj->Vec()); }
918
919
920 //=======================================================================
921 //function : Translate
922 //purpose  : Translates a PGeom_Ellipse to a Geom_Ellipse.
923 //=======================================================================
924
925 Handle(Geom_Ellipse)  MgtGeom::Translate
926        (const Handle(PGeom_Ellipse)& PObj)
927 {
928   return new Geom_Ellipse(PObj->Position(),
929                           PObj->MajorRadius(),
930                           PObj->MinorRadius());
931 }
932
933
934 //=======================================================================
935 //function : Translate
936 //purpose  : Translates a Geom_Ellipse to a PGeom_Ellipse.
937 //=======================================================================
938
939 Handle(PGeom_Ellipse)  MgtGeom::Translate
940        (const Handle(Geom_Ellipse)& TObj)
941 {
942   return new PGeom_Ellipse(TObj->Position(),
943                            TObj->MajorRadius(),
944                            TObj->MinorRadius());
945 }
946
947
948 //=======================================================================
949 //function : Translate
950 //purpose  : Translates a PGeom_Hyperbola to a Geom_Hyperbola.
951 //=======================================================================
952
953 Handle(Geom_Hyperbola)  MgtGeom::Translate
954        (const Handle(PGeom_Hyperbola)& PObj)
955 {
956   return new Geom_Hyperbola(PObj->Position(),
957                             PObj->MajorRadius(),
958                             PObj->MinorRadius());
959 }
960
961
962 //=======================================================================
963 //function : Translate
964 //purpose  : Translates a Geom_Hyperbola to a PGeom_Hyperbola.
965 //=======================================================================
966
967 Handle(PGeom_Hyperbola)  MgtGeom::Translate(const Handle(Geom_Hyperbola)& TObj)
968 {
969   return new PGeom_Hyperbola(TObj->Position(),
970                              TObj->MajorRadius(),
971                              TObj->MinorRadius());
972 }
973
974
975 //=======================================================================
976 //function : Translate
977 //purpose  : Translates a PGeom_Line to a Geom_Line.
978 //=======================================================================
979
980 Handle(Geom_Line)  MgtGeom::Translate(const Handle(PGeom_Line)& PObj)
981 { return new Geom_Line(PObj->Position()); }
982
983
984 //=======================================================================
985 //function : Translate
986 //purpose  : Translates a Geom_Line to a PGeom_Line.
987 //=======================================================================
988
989 Handle(PGeom_Line)  MgtGeom::Translate(const Handle(Geom_Line)& TObj)
990 { return new PGeom_Line(TObj->Lin().Position()); }
991
992
993 //=======================================================================
994 //function : Translate
995 //purpose  : Translates a PGeom_OffsetCurve to a Geom_OffsetCurve.
996 //=======================================================================
997
998 Handle(Geom_OffsetCurve)  MgtGeom::Translate
999        (const Handle(PGeom_OffsetCurve)& PObj)
1000 {
1001   return new Geom_OffsetCurve(MgtGeom::Translate(PObj->BasisCurve()),
1002                               PObj->OffsetValue(),
1003                               PObj->OffsetDirection());
1004 }
1005
1006
1007 //=======================================================================
1008 //function : Translate
1009 //purpose  : Translates a Geom_OffsetCurve to a PGeom_OffsetCurve.
1010 //=======================================================================
1011
1012 Handle(PGeom_OffsetCurve)  MgtGeom::Translate(const Handle(Geom_OffsetCurve)& TObj)
1013 {
1014   return new PGeom_OffsetCurve(MgtGeom::Translate(TObj->BasisCurve()),
1015                                TObj->Offset(),
1016                                TObj->Direction());
1017 }
1018
1019
1020 //=======================================================================
1021 //function : Translate
1022 //purpose  : Translates a PGeom_OffsetSurface to a Geom_OffsetSurface.
1023 //=======================================================================
1024
1025 Handle(Geom_OffsetSurface)  MgtGeom::Translate
1026        (const Handle(PGeom_OffsetSurface)& PObj)
1027 {
1028   return new Geom_OffsetSurface(MgtGeom::Translate(PObj->BasisSurface()),
1029                                 PObj->OffsetValue());
1030 }
1031
1032
1033 //=======================================================================
1034 //function : Translate
1035 //purpose  : Translates a Geom_OffsetSurface to a PGeom_OffsetSurface.
1036 //=======================================================================
1037
1038 Handle(PGeom_OffsetSurface)  MgtGeom::Translate
1039        (const Handle(Geom_OffsetSurface)& TObj)
1040 {
1041   return new PGeom_OffsetSurface(MgtGeom::Translate(TObj->BasisSurface()),
1042                                  TObj->Offset());
1043 }
1044
1045
1046 //=======================================================================
1047 //function : Translate
1048 //purpose  : Translates a PGeom_Parabola to a Geom_Parabola.
1049 //=======================================================================
1050
1051 Handle(Geom_Parabola)  MgtGeom::Translate
1052        (const Handle(PGeom_Parabola)& PObj)
1053 {
1054   return new Geom_Parabola(PObj->Position(),
1055                            PObj->FocalLength());
1056 }
1057
1058
1059 //=======================================================================
1060 //function : Translate
1061 //purpose  : Translates a Geom_Parabola to a PGeom_Parabola.
1062 //=======================================================================
1063
1064 Handle(PGeom_Parabola)  MgtGeom::Translate
1065        (const Handle(Geom_Parabola)& TObj)
1066 {
1067   return new PGeom_Parabola(TObj->Position(),
1068                             TObj->Focal());
1069 }
1070
1071
1072 //=======================================================================
1073 //function : Translate
1074 //purpose  : Translates a PGeom_Plane to a Geom_Plane.
1075 //=======================================================================
1076
1077 Handle(Geom_Plane)  MgtGeom::Translate(const Handle(PGeom_Plane)& PObj)
1078 {  return new Geom_Plane(PObj->Position()); }
1079
1080
1081 //=======================================================================
1082 //function : Translate
1083 //purpose  : Translates a Geom_Plane to a PGeom_Plane.
1084 //=======================================================================
1085
1086 Handle(PGeom_Plane)  MgtGeom::Translate(const Handle(Geom_Plane)& TObj)
1087 {
1088   return new PGeom_Plane(TObj->Pln().Position());
1089 }
1090
1091 //=======================================================================
1092 //function : Translate
1093 //purpose  : Translates a PGeom_Point to a Geom_Point.
1094 //         : Optimized valid until new subtypes of GeomPoint exist
1095 //=======================================================================
1096
1097 Handle(Geom_Point)  MgtGeom::Translate
1098        (const Handle(PGeom_Point)& PObj)
1099 {
1100 /*
1101   Handle(Geom_Point) GeomP;
1102   Handle(Standard_Type) PointType = PObj->DynamicType();
1103   
1104   if (PointType == STANDARD_TYPE(PGeom_CartesianPoint)) {
1105     Handle(PGeom_CartesianPoint)& PCPoint = 
1106       (Handle(PGeom_CartesianPoint)&) PObj;
1107     GeomP = MgtGeom::Translate(PCPoint);
1108   }
1109   return GeomP;
1110 */
1111
1112   Handle(PGeom_CartesianPoint)& PCPoint = 
1113     (Handle(PGeom_CartesianPoint)&) PObj;
1114   return new Geom_CartesianPoint(PCPoint->Pnt());
1115 }
1116
1117
1118 //=======================================================================
1119 //function : Translate
1120 //purpose  : Translates a Geom_Point to a PGeom_Point.
1121 //         : Optimized valid until new subtypes of GeomPoint exist
1122 //=======================================================================
1123
1124 Handle(PGeom_Point)  MgtGeom::Translate
1125        (const Handle(Geom_Point)& TObj)
1126 {
1127 /*
1128   Handle(PGeom_Point) PGeomP;
1129   Handle(Standard_Type) PointType = TObj->DynamicType();
1130
1131   if (PointType == STANDARD_TYPE(Geom_CartesianPoint)) {
1132     Handle(Geom_CartesianPoint)& TCPoint = 
1133       (Handle(Geom_CartesianPoint)&) TObj;
1134     PGeomP = MgtGeom::Translate(TCPoint);
1135   }
1136   return PGeomP;
1137 */
1138
1139   Handle(Geom_CartesianPoint)& TCPoint = 
1140     (Handle(Geom_CartesianPoint)&) TObj;
1141
1142   return new PGeom_CartesianPoint(TCPoint->Pnt());
1143 }
1144
1145
1146 //=======================================================================
1147 //function : Translate
1148 //purpose  : Translates a PGeom_RectangularTrimmedSurface to a
1149 //           Geom_RectangularTrimmedSurface.
1150 //=======================================================================
1151
1152 Handle(Geom_RectangularTrimmedSurface)  MgtGeom::Translate
1153        (const Handle(PGeom_RectangularTrimmedSurface)& PObj)
1154 {
1155   return new Geom_RectangularTrimmedSurface
1156     (MgtGeom::Translate(PObj->BasisSurface()),
1157      PObj->FirstU(),
1158      PObj->LastU(),
1159      PObj->FirstV(),
1160      PObj->LastV(),
1161      Standard_True, Standard_True); // En attendant leur suppression.
1162 }
1163
1164
1165 //=======================================================================
1166 //function : Translate
1167 //purpose  : Translates a Geom_RectangularTrimmedSurface to a
1168 //           PGeom_RectangularTrimmedSurface.
1169 //=======================================================================
1170
1171 Handle(PGeom_RectangularTrimmedSurface)  MgtGeom::Translate
1172        (const Handle(Geom_RectangularTrimmedSurface)& TObj)
1173 {
1174   Standard_Real FirstU, LastU, FirstV, LastV;
1175   TObj->Bounds(FirstU, LastU, FirstV, LastV);
1176
1177   return new PGeom_RectangularTrimmedSurface
1178     (MgtGeom::Translate(TObj->BasisSurface()),
1179      FirstU, LastU,
1180      FirstV, LastV);
1181 }
1182
1183
1184 //=======================================================================
1185 //function : Translate
1186 //purpose  : Translates a PGeom_SphericalSurface to a
1187 //           Geom_SphericalSurface.
1188 //=======================================================================
1189
1190 Handle(Geom_SphericalSurface)  MgtGeom::Translate
1191        (const Handle(PGeom_SphericalSurface)& PObj)
1192 {
1193   return new Geom_SphericalSurface(PObj->Position(),
1194                                    PObj->Radius());
1195 }
1196
1197
1198 //=======================================================================
1199 //function : Translate
1200 //purpose  : Translates a Geom_SphericalSurface to a
1201 //           PGeom_SphericalSurface.
1202 //=======================================================================
1203
1204 Handle(PGeom_SphericalSurface)  MgtGeom::Translate
1205        (const Handle(Geom_SphericalSurface)& TObj)
1206 {
1207   return new PGeom_SphericalSurface(TObj->Position(),
1208                                     TObj->Radius());
1209 }
1210
1211
1212 //=======================================================================
1213 //function : Translate
1214 //purpose  : Translates a PGeom_Surface to a Geom_Surface.
1215 //=======================================================================
1216
1217 Handle(Geom_Surface)  MgtGeom::Translate(const Handle(PGeom_Surface)& PObj)
1218 {
1219   Handle(Standard_Type) SurfaceType = PObj->DynamicType();
1220
1221   if (SurfaceType == STANDARD_TYPE(PGeom_Plane)) {
1222     Handle(PGeom_Plane)& TPlane = 
1223       (Handle(PGeom_Plane)&) PObj;
1224     return MgtGeom::Translate(TPlane);
1225   }
1226   else if (SurfaceType ==  STANDARD_TYPE(PGeom_CylindricalSurface)) {
1227     Handle(PGeom_CylindricalSurface)& TCylindricalSurface = 
1228       (Handle(PGeom_CylindricalSurface)&) PObj;
1229     return MgtGeom::Translate(TCylindricalSurface);
1230   }
1231   else if (SurfaceType ==  STANDARD_TYPE(PGeom_ConicalSurface)) {
1232     Handle(PGeom_ConicalSurface)& TConicalSurface = 
1233       (Handle(PGeom_ConicalSurface)&) PObj;
1234     return MgtGeom::Translate(TConicalSurface);
1235   }
1236   else if (SurfaceType ==  STANDARD_TYPE(PGeom_SphericalSurface)) {
1237     Handle(PGeom_SphericalSurface)& TSphericalSurface = 
1238       (Handle(PGeom_SphericalSurface)&) PObj;
1239     return MgtGeom::Translate(TSphericalSurface);
1240   }
1241   else if (SurfaceType ==  STANDARD_TYPE(PGeom_ToroidalSurface)) {
1242     Handle(PGeom_ToroidalSurface)& TToroidalSurface = 
1243       (Handle(PGeom_ToroidalSurface)&) PObj;
1244     return MgtGeom::Translate(TToroidalSurface);
1245   }
1246   else if (SurfaceType ==  STANDARD_TYPE(PGeom_SurfaceOfLinearExtrusion)) {
1247     Handle(PGeom_SurfaceOfLinearExtrusion)& TSurfaceOfLinearExtrusion = 
1248       (Handle(PGeom_SurfaceOfLinearExtrusion)&) PObj;
1249     return MgtGeom::Translate(TSurfaceOfLinearExtrusion);
1250   }
1251   else if (SurfaceType ==  STANDARD_TYPE(PGeom_SurfaceOfRevolution)) {
1252     Handle(PGeom_SurfaceOfRevolution)& TSurfaceOfRevolution = 
1253       (Handle(PGeom_SurfaceOfRevolution)&) PObj;
1254     return MgtGeom::Translate(TSurfaceOfRevolution);
1255   }
1256   else if (SurfaceType ==  STANDARD_TYPE(PGeom_BezierSurface)) {
1257     Handle(PGeom_BezierSurface)& TBezierSurface = 
1258       (Handle(PGeom_BezierSurface)&) PObj;
1259     return MgtGeom::Translate(TBezierSurface);
1260   }
1261   else if (SurfaceType ==  STANDARD_TYPE(PGeom_BSplineSurface)) {
1262     Handle(PGeom_BSplineSurface)& TBSplineSurface = 
1263       (Handle(PGeom_BSplineSurface)&) PObj;
1264     return MgtGeom::Translate(TBSplineSurface);
1265   }
1266   else if (SurfaceType ==  STANDARD_TYPE(PGeom_RectangularTrimmedSurface)) {
1267     Handle(PGeom_RectangularTrimmedSurface)& TRectangularTrimmedSurface = 
1268       (Handle(PGeom_RectangularTrimmedSurface)&) PObj;
1269     return MgtGeom::Translate(TRectangularTrimmedSurface);
1270   }
1271   else if (SurfaceType ==  STANDARD_TYPE(PGeom_OffsetSurface)) {
1272     Handle(PGeom_OffsetSurface)& TOffsetSurface = 
1273       (Handle(PGeom_OffsetSurface)&) PObj;
1274     return MgtGeom::Translate(TOffsetSurface);
1275   }
1276   else {
1277 #ifdef MGTGEOM_DEB
1278     cout << "MgtGeom : Unknown surface type ????"<<endl;
1279 #endif
1280     Standard_NullObject::Raise("No mapping for the current Persistent Surface");
1281
1282   }
1283 // POP pour NT
1284   Handle(Geom_Surface) dummy;
1285   return dummy;
1286 }
1287
1288
1289 //=======================================================================
1290 //function : Translate
1291 //purpose  : Translates a Geom_Surface to a PGeom_Surface.
1292 //=======================================================================
1293
1294 Handle(PGeom_Surface)  MgtGeom::Translate(const Handle(Geom_Surface)& TObj)
1295 {
1296   Handle(Standard_Type) SurfaceType = TObj->DynamicType();
1297
1298   if (SurfaceType == STANDARD_TYPE(Geom_Plane)) {
1299     Handle(Geom_Plane)& PPlane = 
1300       (Handle(Geom_Plane)&) TObj;
1301     return MgtGeom::Translate(PPlane);
1302   }
1303   else if (SurfaceType ==  STANDARD_TYPE(Geom_CylindricalSurface)) {
1304     Handle(Geom_CylindricalSurface)& PCylindricalSurface = 
1305       (Handle(Geom_CylindricalSurface)&) TObj;
1306     return MgtGeom::Translate(PCylindricalSurface);
1307   }
1308   else if (SurfaceType ==  STANDARD_TYPE(Geom_ConicalSurface)) {
1309     Handle(Geom_ConicalSurface)& PConicalSurface = 
1310       (Handle(Geom_ConicalSurface)&) TObj;
1311     return MgtGeom::Translate(PConicalSurface);
1312   }
1313   else if (SurfaceType ==  STANDARD_TYPE(Geom_SphericalSurface)) {
1314     Handle(Geom_SphericalSurface)& PSphericalSurface = 
1315       (Handle(Geom_SphericalSurface)&) TObj;
1316     return MgtGeom::Translate(PSphericalSurface);
1317   }
1318   else if (SurfaceType ==  STANDARD_TYPE(Geom_ToroidalSurface)) {
1319     Handle(Geom_ToroidalSurface)& PToroidalSurface = 
1320       (Handle(Geom_ToroidalSurface)&) TObj;
1321     return MgtGeom::Translate(PToroidalSurface);
1322   }
1323   else if (SurfaceType ==  STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) {
1324     Handle(Geom_SurfaceOfLinearExtrusion)& PSurfaceOfLinearExtrusion = 
1325       (Handle(Geom_SurfaceOfLinearExtrusion)&) TObj;
1326     return MgtGeom::Translate(PSurfaceOfLinearExtrusion);
1327   }
1328   else if (SurfaceType ==  STANDARD_TYPE(Geom_SurfaceOfRevolution)) {
1329     Handle(Geom_SurfaceOfRevolution)& PSurfaceOfRevolution = 
1330       (Handle(Geom_SurfaceOfRevolution)&) TObj;
1331     return MgtGeom::Translate(PSurfaceOfRevolution);
1332   }
1333   else if (SurfaceType ==  STANDARD_TYPE(Geom_BezierSurface)) {
1334     Handle(Geom_BezierSurface)& PBezierSurface = 
1335       (Handle(Geom_BezierSurface)&) TObj;
1336     return MgtGeom::Translate(PBezierSurface);
1337   }
1338   else if (SurfaceType ==  STANDARD_TYPE(Geom_BSplineSurface)) {
1339     Handle(Geom_BSplineSurface)& PBSplineSurface = 
1340       (Handle(Geom_BSplineSurface)&) TObj;
1341     return MgtGeom::Translate(PBSplineSurface);
1342   }
1343   else if (SurfaceType ==  STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
1344     Handle(Geom_RectangularTrimmedSurface)& PRectangularTrimmedSurface = 
1345       (Handle(Geom_RectangularTrimmedSurface)&) TObj;
1346     return MgtGeom::Translate(PRectangularTrimmedSurface);
1347   }
1348   else if (SurfaceType ==  STANDARD_TYPE(Geom_OffsetSurface)) {
1349     Handle(Geom_OffsetSurface)& POffsetSurface = 
1350       (Handle(Geom_OffsetSurface)&) TObj;
1351     return MgtGeom::Translate(POffsetSurface);
1352   }
1353   else {
1354 #ifdef MGTGEOM_DEB
1355     cout << "MgtGeom : Unknown surface type ????"<<endl;
1356 #endif
1357     Standard_NullObject::Raise("No mapping for the current Transient Surface");
1358   }
1359 // POP pour NT
1360   Handle(PGeom_Surface) dummy;
1361   return dummy;
1362 }
1363
1364
1365 //=======================================================================
1366 //function : Translate
1367 //purpose  : Translates a PGeom_SurfaceOfLinearExtrusion to a
1368 //           Geom_SurfaceOfLinearExtrusion.
1369 //=======================================================================
1370
1371 Handle(Geom_SurfaceOfLinearExtrusion)  MgtGeom::Translate
1372        (const Handle(PGeom_SurfaceOfLinearExtrusion)& PObj)
1373 {
1374   return new Geom_SurfaceOfLinearExtrusion
1375     (MgtGeom::Translate(PObj->BasisCurve()),
1376      PObj->Direction());
1377 }
1378
1379
1380 //=======================================================================
1381 //function : Translate
1382 //purpose  : Translates a Geom_SurfaceOfLinearExtrusion to a
1383 //           PGeom_SurfaceOfLinearExtrusion.
1384 //=======================================================================
1385
1386 Handle(PGeom_SurfaceOfLinearExtrusion)  MgtGeom::Translate
1387        (const Handle(Geom_SurfaceOfLinearExtrusion)& TObj)
1388 {
1389   return new PGeom_SurfaceOfLinearExtrusion
1390     (MgtGeom::Translate(TObj->BasisCurve()),
1391      TObj->Direction());
1392 }
1393
1394
1395 //=======================================================================
1396 //function : Translate
1397 //purpose  : Translates a PGeom_SurfaceOfRevolution to a
1398 //           Geom_SurfaceOfRevolution.
1399 //=======================================================================
1400
1401 Handle(Geom_SurfaceOfRevolution)  MgtGeom::Translate
1402        (const Handle(PGeom_SurfaceOfRevolution)& PObj)
1403 {
1404   gp_Ax1 axis(PObj->Location(), PObj->Direction());
1405   return new Geom_SurfaceOfRevolution(MgtGeom::Translate(PObj->BasisCurve()),
1406                                       axis);
1407
1408 }
1409
1410
1411 //=======================================================================
1412 //function : Translate
1413 //purpose  : Translates a Geom_SurfaceOfRevolution to a
1414 //           PGeom_SurfaceOfRevolution.
1415 //=======================================================================
1416
1417 Handle(PGeom_SurfaceOfRevolution)  MgtGeom::Translate
1418        (const Handle(Geom_SurfaceOfRevolution)& TObj)
1419 {
1420   return new PGeom_SurfaceOfRevolution(MgtGeom::Translate(TObj->BasisCurve()),
1421                                        TObj->Direction(),
1422                                        TObj->Location());
1423 }
1424
1425
1426 //=======================================================================
1427 //function : Translate
1428 //purpose  : Translates a PGeom_ToroidalSurface to a Geom_ToroidalSurface.
1429 //=======================================================================
1430
1431 Handle(Geom_ToroidalSurface)  MgtGeom::Translate
1432        (const Handle(PGeom_ToroidalSurface)& PObj)
1433 {
1434   return new Geom_ToroidalSurface(PObj->Position(),
1435                                   PObj->MajorRadius(),
1436                                   PObj->MinorRadius());
1437 }
1438
1439
1440 //=======================================================================
1441 //function : Translate
1442 //purpose  : Translates a Geom_ToroidalSurface to a PGeom_ToroidalSurface.
1443 //=======================================================================
1444
1445 Handle(PGeom_ToroidalSurface)  MgtGeom::Translate
1446        (const Handle(Geom_ToroidalSurface)& TObj)
1447 {
1448   return new PGeom_ToroidalSurface(TObj->Position(),
1449                                    TObj->MajorRadius(),
1450                                    TObj->MinorRadius());
1451 }
1452
1453
1454 //=======================================================================
1455 //function : Translate
1456 //purpose  : Translates a PGeom_Transformation to a Geom_Transformation.
1457 //=======================================================================
1458
1459 Handle(Geom_Transformation)  MgtGeom::Translate
1460        (const Handle(PGeom_Transformation)& PObj)
1461 { return new Geom_Transformation(PObj->Trsf()); }
1462
1463
1464 //=======================================================================
1465 //function : Translate
1466 //purpose  : Translates a Geom_Transformation to a PGeom_Transformation.
1467 //=======================================================================
1468
1469 Handle(PGeom_Transformation)  MgtGeom::Translate
1470        (const Handle(Geom_Transformation)& TObj)
1471 { return new PGeom_Transformation(TObj->Trsf()); }
1472
1473
1474 //=======================================================================
1475 //function : Translate
1476 //purpose  : Translates a PGeom_TrimmedCurve to a Geom_TrimmedCurve.
1477 //=======================================================================
1478
1479 Handle(Geom_TrimmedCurve)  MgtGeom::Translate
1480        (const Handle(PGeom_TrimmedCurve)& PObj)
1481 {
1482   return new Geom_TrimmedCurve(MgtGeom::Translate(PObj->BasisCurve()),
1483                                PObj->FirstU(),
1484                                PObj->LastU(),
1485                                Standard_True); // En attendant sa suppression.
1486 }
1487
1488
1489 //=======================================================================
1490 //function : Translate
1491 //purpose  : Translates a Geom_TrimmedCurve to a PGeom_TrimmedCurve.
1492 //=======================================================================
1493
1494 Handle(PGeom_TrimmedCurve)  MgtGeom::Translate
1495        (const Handle(Geom_TrimmedCurve)& TObj)
1496 {
1497   return new PGeom_TrimmedCurve(MgtGeom::Translate(TObj->BasisCurve()),
1498                                 TObj->FirstParameter(),
1499                                 TObj->LastParameter());
1500 }
1501
1502
1503 //=======================================================================
1504 //function : Translate
1505 //purpose  : Translates a PGeom_VectorWithMagnitude to a
1506 //           Geom_VectorWithMagnitude.
1507 //=======================================================================
1508
1509 Handle(Geom_VectorWithMagnitude)  MgtGeom::Translate
1510        (const Handle(PGeom_VectorWithMagnitude)& PObj)
1511 { return new Geom_VectorWithMagnitude(PObj->Vec()); }
1512
1513
1514 //=======================================================================
1515 //function : Translate
1516 //purpose  : Translates a Geom_VectorWithMagnitude to a
1517 //           PGeom_VectorWithMagnitude.
1518 //=======================================================================
1519
1520 Handle(PGeom_VectorWithMagnitude)  MgtGeom::Translate
1521        (const Handle(Geom_VectorWithMagnitude)& TObj)
1522 { return new PGeom_VectorWithMagnitude(TObj->Vec()); }