Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/geom.git] / src / GEOM_I / GEOM_ITransformOperations_i.cc
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <Standard_Stream.hxx>
24
25 #include "GEOM_ITransformOperations_i.hh"
26
27 #include "utilities.h"
28 #include "OpUtil.hxx"
29 #include "Utils_ExceptHandlers.hxx"
30
31 #include <TDF_Label.hxx>
32 #include <TDF_Tool.hxx>
33 #include <TCollection_AsciiString.hxx>
34 #include "GEOM_Engine.hxx"
35 #include "GEOM_Object.hxx"
36
37 #define SUBSHAPE_ERROR "Sub shape cannot be transformed"
38
39 //=============================================================================
40 /*!
41  *   constructor:
42  */
43 //=============================================================================
44
45 GEOM_ITransformOperations_i::GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA,
46                                                           GEOM::GEOM_Gen_ptr theEngine,
47                                                           ::GEOMImpl_ITransformOperations* theImpl)
48      :GEOM_IOperations_i(thePOA, theEngine, theImpl)
49 {
50   MESSAGE("GEOM_ITransformOperations_i::GEOM_ITransformOperations_i");
51 }
52
53 //=============================================================================
54 /*!
55  *  destructor
56  */
57 //=============================================================================
58
59 GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i()
60 {
61   MESSAGE("GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i");
62 }
63
64
65 //=============================================================================
66 /*!
67  *  TranslateTwoPoints
68  */
69 //=============================================================================
70 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints
71                                              (GEOM::GEOM_Object_ptr theObject,
72                                               GEOM::GEOM_Object_ptr thePoint1,
73                                               GEOM::GEOM_Object_ptr thePoint2)
74 {
75   //Set a not done flag
76   GetOperations()->SetNotDone();
77   GEOM::GEOM_Object_var aGEOMObject;
78
79   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
80
81   //check if the object is a subshape
82   if (!theObject->IsMainShape()) {
83     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
84     return aGEOMObject._retn();
85   }
86
87   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
88
89   //Get the object itself
90   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
91   if (anObject.IsNull()) return aGEOMObject._retn();
92
93   //Get the first point of translation
94   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
95   if (aPoint1.IsNull()) return aGEOMObject._retn();
96
97   //Get the second point of translation
98   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
99   if (aPoint2.IsNull()) return aGEOMObject._retn();
100
101   //Perform the translation
102   GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2);
103
104   return aGEOMObject._retn();
105 }
106
107 //=============================================================================
108 /*!
109  *  TranslateTwoPointsCopy
110  */
111 //=============================================================================
112 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
113                                              (GEOM::GEOM_Object_ptr theObject,
114                                               GEOM::GEOM_Object_ptr thePoint1,
115                                               GEOM::GEOM_Object_ptr thePoint2)
116 {
117   GEOM::GEOM_Object_var aGEOMObject;
118
119   //Set a not done flag
120   GetOperations()->SetNotDone();
121
122   //Get the object itself
123   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
124   if (aBasicObject.IsNull()) return aGEOMObject._retn();
125
126   //Get the first point of translation
127   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
128   if (aPoint1.IsNull()) return aGEOMObject._retn();
129
130   //Get the second point of translation
131   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
132   if (aPoint2.IsNull()) return aGEOMObject._retn();
133
134   //Create the translated shape
135   Handle(GEOM_Object) anObject =
136     GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
137   if (!GetOperations()->IsDone() || anObject.IsNull())
138     return aGEOMObject._retn();
139
140   return GetObject(anObject);
141 }
142
143 //=============================================================================
144 /*!
145  *  TranslateDXDYDZ
146  */
147 //=============================================================================
148 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ
149                       (GEOM::GEOM_Object_ptr theObject,
150                        CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
151 {
152   //Set a not done flag
153   GetOperations()->SetNotDone();
154   GEOM::GEOM_Object_var aGEOMObject;
155
156   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
157
158   //check if the object is a subshape
159   if (!theObject->IsMainShape()) {
160     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
161     return aGEOMObject._retn();
162   }
163
164   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
165
166   //Get the object itself
167   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
168   if (anObject.IsNull()) return aGEOMObject._retn();
169
170   //Perform the translation
171   GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
172
173   return aGEOMObject._retn();
174 }
175
176 //=============================================================================
177 /*!
178  *  TranslateDXDYDZCopy
179  */
180 //=============================================================================
181 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
182                                              (GEOM::GEOM_Object_ptr theObject,
183                                               CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
184 {
185   GEOM::GEOM_Object_var aGEOMObject;
186
187   //Set a not done flag
188   GetOperations()->SetNotDone();
189
190   //Get the object itself
191   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
192   if (aBasicObject.IsNull()) return aGEOMObject._retn();
193
194   //Create the translated shape
195   Handle(GEOM_Object) anObject =
196     GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
197   if (!GetOperations()->IsDone() || anObject.IsNull())
198     return aGEOMObject._retn();
199
200   return GetObject(anObject);
201 }
202
203 //=============================================================================
204 /*!
205  *  TranslateVector
206  */
207 //=============================================================================
208 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
209                                             (GEOM::GEOM_Object_ptr theObject,
210                                              GEOM::GEOM_Object_ptr theVector)
211 {
212   //Set a not done flag
213   GetOperations()->SetNotDone();
214   GEOM::GEOM_Object_var aGEOMObject;
215
216   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
217
218   //check if the object is a subshape
219   if (!theObject->IsMainShape()) {
220     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
221     return aGEOMObject._retn();
222   }
223
224   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
225
226   //Get the object itself
227   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
228   if (anObject.IsNull()) return aGEOMObject._retn();
229
230   //Get the vector of translation
231   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
232   if (aVector.IsNull()) return aGEOMObject._retn();
233
234   //Perform the translation
235   GetOperations()->TranslateVector(anObject, aVector);
236
237   return aGEOMObject._retn();
238 }
239
240 //=============================================================================
241 /*!
242  *  TranslateVectorCopy
243  */
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
246                                             (GEOM::GEOM_Object_ptr theObject,
247                                              GEOM::GEOM_Object_ptr theVector)
248 {
249   GEOM::GEOM_Object_var aGEOMObject;
250
251   //Set a not done flag
252   GetOperations()->SetNotDone();
253
254   //Get the object itself
255   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
256   if (aBasicObject.IsNull()) return aGEOMObject._retn();
257
258   //Get the vector of translation
259   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
260   if (aVector.IsNull()) return aGEOMObject._retn();
261
262   //Perform the translation
263   Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);
264   if (!GetOperations()->IsDone() || anObject.IsNull())
265     return aGEOMObject._retn();
266
267   return GetObject(anObject);
268 }
269
270 //=============================================================================
271 /*!
272  *  TranslateVectorDistance
273  */
274 //=============================================================================
275 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
276                                             (GEOM::GEOM_Object_ptr theObject,
277                                              GEOM::GEOM_Object_ptr theVector,
278                                              CORBA::Double theDistance,
279                                              CORBA::Boolean theCopy)
280 {
281   GEOM::GEOM_Object_var aGEOMObject;
282   GetOperations()->SetNotDone(); //Set a not done flag
283
284   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
285
286   //check if the object is a subshape
287   if (!theCopy && !theObject->IsMainShape()) {
288     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
289     return aGEOMObject._retn();
290   }
291
292   if (!theCopy)
293     aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
294
295   //Get the object itself
296   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
297   if (aBasicObject.IsNull()) return aGEOMObject._retn();
298
299   //Get the vector of translation
300   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
301   if (aVector.IsNull()) return aGEOMObject._retn();
302
303   //Perform the translation
304   if (theCopy) {
305     Handle(GEOM_Object) anObject = GetOperations()->
306       TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
307     if (!GetOperations()->IsDone() || anObject.IsNull())
308       return aGEOMObject._retn();
309
310     return GetObject(anObject);
311   }
312
313   GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
314   return aGEOMObject._retn();
315 }
316
317 //=============================================================================
318 /*!
319  *  Rotate
320  */
321 //=============================================================================
322 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
323                                                            GEOM::GEOM_Object_ptr theAxis,
324                                                            CORBA::Double theAngle)
325 {
326   //Set a not done flag
327   GetOperations()->SetNotDone();
328   GEOM::GEOM_Object_var aGEOMObject;
329
330   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
331
332   //check if the object is a subshape
333   if (!theObject->IsMainShape()) {
334     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
335     return aGEOMObject._retn();
336   }
337
338   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
339
340   //Get the object itself
341   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
342   if (anObject.IsNull()) return aGEOMObject._retn();
343
344   //Get the axis of revolution
345   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
346   if (anAxis.IsNull()) return aGEOMObject._retn();
347
348   //Perform the rotation
349   GetOperations()->Rotate(anObject, anAxis, theAngle);
350
351   return aGEOMObject._retn();
352 }
353
354 //=============================================================================
355 /*!
356  *  RotateCopy
357  */
358 //=============================================================================
359 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
360                                                                GEOM::GEOM_Object_ptr theAxis,
361                                                                CORBA::Double theAngle)
362 {
363   GEOM::GEOM_Object_var aGEOMObject;
364
365   //Set a not done flag
366   GetOperations()->SetNotDone();
367
368   //Get the object itself
369   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
370   if (aBasicObject.IsNull()) return aGEOMObject._retn();
371
372   //Get the axis of rotation
373   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
374   if (anAxis.IsNull()) return aGEOMObject._retn();
375
376   //Perform the rotation
377   Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
378   if (!GetOperations()->IsDone() || anObject.IsNull())
379     return aGEOMObject._retn();
380
381   return GetObject(anObject);
382 }
383
384 //=============================================================================
385 /*!
386  *  MirrorPlane
387  */
388 //=============================================================================
389 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
390                                             (GEOM::GEOM_Object_ptr theObject,
391                                              GEOM::GEOM_Object_ptr thePlane)
392 {
393   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
394
395   //Set a not done flag
396   GetOperations()->SetNotDone();
397
398   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
399
400   //check if the object is a subshape
401   if (!theObject->IsMainShape()) {
402     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
403     return aGEOMObject._retn();
404   }
405
406   //Get the object itself
407   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
408   if (anObject.IsNull()) return aGEOMObject._retn();
409
410   //Get the plane
411   Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
412   if (aPlane.IsNull()) return aGEOMObject._retn();
413
414   //Perform the mirror
415   GetOperations()->MirrorPlane(anObject, aPlane);
416
417   return aGEOMObject._retn();
418 }
419
420 //=============================================================================
421 /*!
422  *  MirrorPlaneCopy
423  */
424 //=============================================================================
425 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
426                                             (GEOM::GEOM_Object_ptr theObject,
427                                              GEOM::GEOM_Object_ptr thePlane)
428 {
429   GEOM::GEOM_Object_var aGEOMObject;
430
431   //Set a not done flag
432   GetOperations()->SetNotDone();
433
434   //Get the object itself
435   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
436   if (aBasicObject.IsNull()) return aGEOMObject._retn();
437
438   //Get the vector of translation
439   Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
440   if (aPlane.IsNull()) return aGEOMObject._retn();
441
442   //Perform the mirror
443   Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
444   if (!GetOperations()->IsDone() || anObject.IsNull())
445     return aGEOMObject._retn();
446
447   return GetObject(anObject);
448 }
449
450 //=============================================================================
451 /*!
452  *  MirrorAxis
453  */
454 //=============================================================================
455 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
456                                             (GEOM::GEOM_Object_ptr theObject,
457                                              GEOM::GEOM_Object_ptr theAxis)
458 {
459   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
460
461   //Set a not done flag
462   GetOperations()->SetNotDone();
463
464   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
465
466   //check if the object is a subshape
467   if (!theObject->IsMainShape()) {
468     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
469     return aGEOMObject._retn();
470   }
471
472   //Get the object itself
473   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
474   if (anObject.IsNull()) return aGEOMObject._retn();
475
476   //Get the axis
477   Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
478   if (aAxis.IsNull()) return aGEOMObject._retn();
479
480   //Perform the mirror
481   GetOperations()->MirrorAxis(anObject, aAxis);
482
483   return aGEOMObject._retn();
484 }
485
486 //=============================================================================
487 /*!
488  *  MirrorAxisCopy
489  */
490 //=============================================================================
491 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
492                                             (GEOM::GEOM_Object_ptr theObject,
493                                              GEOM::GEOM_Object_ptr theAxis)
494 {
495   GEOM::GEOM_Object_var aGEOMObject;
496
497   //Set a not done flag
498   GetOperations()->SetNotDone();
499
500   //Get the object itself
501   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
502   if (aBasicObject.IsNull()) return aGEOMObject._retn();
503
504   //Get the vector of translation
505   Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
506   if (aAxis.IsNull()) return aGEOMObject._retn();
507
508   //Perform the mirror
509   Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
510   if (!GetOperations()->IsDone() || anObject.IsNull())
511     return aGEOMObject._retn();
512
513   return GetObject(anObject);
514 }
515
516 //=============================================================================
517 /*!
518  *  MirrorPoint
519  */
520 //=============================================================================
521 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
522                                             (GEOM::GEOM_Object_ptr theObject,
523                                              GEOM::GEOM_Object_ptr thePoint)
524 {
525   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
526
527   //Set a not done flag
528   GetOperations()->SetNotDone();
529
530   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
531
532   //check if the object is a subshape
533   if (!theObject->IsMainShape()) {
534     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
535     return aGEOMObject._retn();
536   }
537
538   //Get the object itself
539   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
540   if (anObject.IsNull()) return aGEOMObject._retn();
541
542   //Get the point
543   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
544   if (aPoint.IsNull()) return aGEOMObject._retn();
545
546   //Perform the mirror
547   GetOperations()->MirrorPoint(anObject, aPoint);
548
549   return aGEOMObject._retn();
550 }
551
552 //=============================================================================
553 /*!
554  *  MirrorPointCopy
555  */
556 //=============================================================================
557 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
558                                             (GEOM::GEOM_Object_ptr theObject,
559                                              GEOM::GEOM_Object_ptr thePoint)
560 {
561   GEOM::GEOM_Object_var aGEOMObject;
562
563   //Set a not done flag
564   GetOperations()->SetNotDone();
565
566   //Get the object itself
567   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
568   if (aBasicObject.IsNull()) return aGEOMObject._retn();
569
570   //Get the vector of translation
571   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
572   if (aPoint.IsNull()) return aGEOMObject._retn();
573
574   //Perform the mirror
575   Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
576   if (!GetOperations()->IsDone() || anObject.IsNull())
577     return aGEOMObject._retn();
578
579   return GetObject(anObject);
580 }
581
582 //=============================================================================
583 /*!
584  *  OffsetShape
585  */
586 //=============================================================================
587 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
588                                              (GEOM::GEOM_Object_ptr theObject,
589                                               CORBA::Double theOffset)
590 {
591   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
592
593   //Set a not done flag
594   GetOperations()->SetNotDone();
595
596   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
597
598   //check if the object is a subshape
599   if (!theObject->IsMainShape()) {
600     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
601     return aGEOMObject._retn();
602   }
603
604   //Get the basic object
605   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
606   if (aBasicObject.IsNull()) return aGEOMObject._retn();
607
608   //Create the offset shape
609   GetOperations()->OffsetShape(aBasicObject, theOffset);
610
611   return aGEOMObject._retn();
612 }
613
614 //=============================================================================
615 /*!
616  *  OffsetShapeCopy
617  */
618 //=============================================================================
619 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
620                                              (GEOM::GEOM_Object_ptr theObject,
621                                               CORBA::Double theOffset)
622 {
623   GEOM::GEOM_Object_var aGEOMObject;
624
625   //Set a not done flag
626   GetOperations()->SetNotDone();
627
628   //Get the basic object
629   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
630   if (aBasicObject.IsNull()) return aGEOMObject._retn();
631
632   //Create the offset shape
633   Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
634   if (!GetOperations()->IsDone() || anObject.IsNull())
635     return aGEOMObject._retn();
636
637   return GetObject(anObject);
638 }
639
640 //=============================================================================
641 /*!
642  *  ScaleShape
643  */
644 //=============================================================================
645 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
646                                              (GEOM::GEOM_Object_ptr theObject,
647                                               GEOM::GEOM_Object_ptr thePoint,
648                                               CORBA::Double         theFactor)
649 {
650   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
651
652   //Set a not done flag
653   GetOperations()->SetNotDone();
654
655   if (theObject->_is_nil()) return aGEOMObject._retn();
656
657   //check if the object is a subshape
658   if (!theObject->IsMainShape()) {
659     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
660     return aGEOMObject._retn();
661   }
662
663   //Get the object itself
664   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
665   if (anObject.IsNull()) return aGEOMObject._retn();
666
667   //Get the point
668   Handle(GEOM_Object) aPoint;
669   if (!thePoint->_is_nil()) {
670     aPoint = GetObjectImpl(thePoint);
671     if (aPoint.IsNull()) return aGEOMObject._retn();
672   }
673
674   //Perform the scale
675   GetOperations()->ScaleShape(anObject, aPoint, theFactor);
676
677   return  aGEOMObject._retn();
678 }
679
680 //=============================================================================
681 /*!
682  *  ScaleShapeCopy
683  */
684 //=============================================================================
685 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
686                                              (GEOM::GEOM_Object_ptr theObject,
687                                               GEOM::GEOM_Object_ptr thePoint,
688                                               CORBA::Double         theFactor)
689 {
690   GEOM::GEOM_Object_var aGEOMObject;
691
692   //Set a not done flag
693   GetOperations()->SetNotDone();
694
695   //Get the basic object
696   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
697   if (aBasicObject.IsNull()) return aGEOMObject._retn();
698
699   //Get the point
700   Handle(GEOM_Object) aPoint;
701   if (!thePoint->_is_nil()) {
702     aPoint = GetObjectImpl(thePoint);
703     if (aPoint.IsNull()) return aGEOMObject._retn();
704   }
705
706   //Perform the scale
707   Handle(GEOM_Object) anObject =
708     GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
709   if (!GetOperations()->IsDone() || anObject.IsNull())
710     return aGEOMObject._retn();
711
712   return GetObject(anObject);
713 }
714
715 //=============================================================================
716 /*!
717  *  ScaleShapeAlongAxes
718  */
719 //=============================================================================
720 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
721                                              (GEOM::GEOM_Object_ptr theObject,
722                                               GEOM::GEOM_Object_ptr thePoint,
723                                               CORBA::Double         theFactorX,
724                                               CORBA::Double         theFactorY,
725                                               CORBA::Double         theFactorZ)
726 {
727   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
728
729   //Set a not done flag
730   GetOperations()->SetNotDone();
731
732   if (theObject->_is_nil()) return aGEOMObject._retn();
733
734   //check if the object is a subshape
735   if (!theObject->IsMainShape()) {
736     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
737     return aGEOMObject._retn();
738   }
739
740   //Get the object itself
741   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
742   if (anObject.IsNull()) return aGEOMObject._retn();
743
744   //Get the point
745   Handle(GEOM_Object) aPoint;
746   if (!thePoint->_is_nil()) {
747     aPoint = GetObjectImpl(thePoint);
748     if (aPoint.IsNull()) return aGEOMObject._retn();
749   }
750
751   //Perform the scale
752   GetOperations()->ScaleShapeAlongAxes
753     (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
754
755   return  aGEOMObject._retn();
756 }
757
758 //=============================================================================
759 /*!
760  *  ScaleShapeAlongAxesCopy
761  */
762 //=============================================================================
763 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
764                                              (GEOM::GEOM_Object_ptr theObject,
765                                               GEOM::GEOM_Object_ptr thePoint,
766                                               CORBA::Double         theFactorX,
767                                               CORBA::Double         theFactorY,
768                                               CORBA::Double         theFactorZ)
769 {
770   GEOM::GEOM_Object_var aGEOMObject;
771
772   //Set a not done flag
773   GetOperations()->SetNotDone();
774
775   //Get the basic object
776   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
777   if (aBasicObject.IsNull()) return aGEOMObject._retn();
778
779   //Get the point
780   Handle(GEOM_Object) aPoint;
781   if (!thePoint->_is_nil()) {
782     aPoint = GetObjectImpl(thePoint);
783     if (aPoint.IsNull()) return aGEOMObject._retn();
784   }
785
786   //Perform the scale
787   Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
788     (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
789   if (!GetOperations()->IsDone() || anObject.IsNull())
790     return aGEOMObject._retn();
791
792   return GetObject(anObject);
793 }
794
795 //=============================================================================
796 /*!
797  *  PositionShape
798  */
799 //=============================================================================
800 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
801                                              (GEOM::GEOM_Object_ptr theObject,
802                                               GEOM::GEOM_Object_ptr theStartLCS,
803                                               GEOM::GEOM_Object_ptr theEndLCS)
804 {
805   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
806
807   //Set a not done flag
808   GetOperations()->SetNotDone();
809
810   if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
811     return aGEOMObject._retn();
812
813   //check if the object is a subshape
814   if (!theObject->IsMainShape()) {
815     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
816     return aGEOMObject._retn();
817   }
818
819   //Get the basic object
820   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
821   if (anObject.IsNull()) return aGEOMObject._retn();
822
823   //Get the Start LCS (may be NULL for positioning from global LCS)
824   Handle(GEOM_Object) aStartLCS;
825   if (!CORBA::is_nil(theStartLCS)) {
826     aStartLCS = GetObjectImpl(theStartLCS);
827     if (aStartLCS.IsNull()) return aGEOMObject._retn();
828   }
829
830   //Get the End LCS
831   Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
832   if (aEndLCS.IsNull()) return aGEOMObject._retn();
833
834   //Perform the Position
835   GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
836
837   return  aGEOMObject._retn();
838 }
839
840 //=============================================================================
841 /*!
842  *  PositionShapeCopy
843  */
844 //=============================================================================
845 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
846                                              (GEOM::GEOM_Object_ptr theObject,
847                                               GEOM::GEOM_Object_ptr theStartLCS,
848                                               GEOM::GEOM_Object_ptr theEndLCS)
849 {
850   GEOM::GEOM_Object_var aGEOMObject;
851
852   //Set a not done flag
853   GetOperations()->SetNotDone();
854
855   //Get the basic object
856   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
857   if (aBasicObject.IsNull()) return aGEOMObject._retn();
858
859   //Get the Start LCS (may be NULL for positioning from global LCS)
860   Handle(GEOM_Object) aStartLCS;
861   if (!CORBA::is_nil(theStartLCS)) {
862     aStartLCS = GetObjectImpl(theStartLCS);
863     if (aStartLCS.IsNull()) return aGEOMObject._retn();
864   }
865
866   //Get the End LCS
867   Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
868   if (aEndLCS.IsNull()) return aGEOMObject._retn();
869
870   //Perform the position
871   Handle(GEOM_Object) anObject =
872     GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
873   if (!GetOperations()->IsDone() || anObject.IsNull())
874     return aGEOMObject._retn();
875
876   return GetObject(anObject);
877 }
878
879 //=============================================================================
880 /*!
881  *  PositionAlongPath
882  */
883 //=============================================================================
884 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
885                                              (GEOM::GEOM_Object_ptr theObject,
886                                               GEOM::GEOM_Object_ptr thePath,
887                                               CORBA::Double         theDistance,
888                                               CORBA::Boolean        theCopy,
889                                               CORBA::Boolean        theReverse)
890 {
891   GEOM::GEOM_Object_var aGEOMObject;
892
893   //Set a not done flag
894   GetOperations()->SetNotDone();
895
896   //Get the basic object
897   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
898   if (aBasicObject.IsNull()) return aGEOMObject._retn();
899
900   //Get the path object
901   Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
902   if (aPathObject.IsNull()) return aGEOMObject._retn();
903
904   //Perform the position
905   Handle(GEOM_Object) anObject =
906     GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
907   if (!GetOperations()->IsDone() || anObject.IsNull())
908     return aGEOMObject._retn();
909
910   return GetObject(anObject);
911 }
912
913 //=============================================================================
914 /*!
915  *  MultiTranslate1D
916  */
917 //=============================================================================
918 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
919                            (GEOM::GEOM_Object_ptr theObject,
920                             GEOM::GEOM_Object_ptr theVector,
921                             CORBA::Double theStep, CORBA::Long theNbTimes)
922 {
923   //Set a not done flag
924   GetOperations()->SetNotDone();
925
926   GEOM::GEOM_Object_var aGEOMObject;
927
928   //Get the object itself
929   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
930   if (aBasicObject.IsNull()) return aGEOMObject._retn();
931
932   //Get the vector of translation
933   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
934   if (aVector.IsNull()) return aGEOMObject._retn();
935
936   //Perform the translation
937   Handle(GEOM_Object) anObject =
938     GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
939   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
940
941   return GetObject(anObject);
942 }
943
944 //=============================================================================
945 /*!
946  *  MultiTranslate2D
947  */
948 //=============================================================================
949 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
950                                                                      GEOM::GEOM_Object_ptr theVector1,
951                                                                      CORBA::Double theStep1,
952                                                                      CORBA::Long theNbTimes1,
953                                                                      GEOM::GEOM_Object_ptr theVector2,
954                                                                      CORBA::Double theStep2,
955                                                                      CORBA::Long theNbTimes2)
956 {
957   //Set a not done flag
958   GetOperations()->SetNotDone();
959
960   GEOM::GEOM_Object_var aGEOMObject;
961
962   //Get the object itself
963   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
964   if (aBasicObject.IsNull()) return aGEOMObject._retn();
965
966   //Get the vector1 of translation
967   Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
968   if (aVector1.IsNull()) return aGEOMObject._retn();
969
970   //Get the vector2 of translation
971   Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
972   if (aVector2.IsNull()) return aGEOMObject._retn();
973
974   //Perform the translation
975   Handle(GEOM_Object) anObject = GetOperations()->Translate2D
976     (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
977   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
978
979   return GetObject(anObject);
980 }
981
982 //=============================================================================
983 /*!
984  *  MultiRotate1D
985  */
986 //=============================================================================
987 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
988                                                                   GEOM::GEOM_Object_ptr theVector,
989                                                                   CORBA::Long theNbTimes)
990 {
991   //Set a not done flag
992   GetOperations()->SetNotDone();
993
994   GEOM::GEOM_Object_var aGEOMObject;
995
996   //Get the object itself
997   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
998   if (aBasicObject.IsNull()) return aGEOMObject._retn();
999
1000   //Get the a directon of rotation
1001   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1002   if (aVector.IsNull()) return aGEOMObject._retn();
1003
1004   //Perform the rotation
1005   Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1006   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1007
1008   return GetObject(anObject);
1009 }
1010
1011 //=============================================================================
1012 /*!
1013  *  MultiRotate2D
1014  */
1015 //=============================================================================
1016 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1017                                                                   GEOM::GEOM_Object_ptr theVector,
1018                                                                   CORBA::Double theAngle,
1019                                                                   CORBA::Long theNbTimes1,
1020                                                                   CORBA::Double theStep,
1021                                                                   CORBA::Long theNbTimes2)
1022 {
1023   //Set a not done flag
1024   GetOperations()->SetNotDone();
1025
1026   GEOM::GEOM_Object_var aGEOMObject;
1027
1028   //Get the object itself
1029   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1030   if (aBasicObject.IsNull()) return aGEOMObject._retn();
1031
1032   //Get the a directon of rotation
1033   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1034   if (aVector.IsNull()) return aGEOMObject._retn();
1035
1036   //Perform the rotation
1037   Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1038     (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1039   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1040
1041   return GetObject(anObject);
1042 }
1043
1044 //=============================================================================
1045 /*!
1046  *  RotateThreePoints
1047  */
1048 //=============================================================================
1049 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1050                                              (GEOM::GEOM_Object_ptr theObject,
1051                                               GEOM::GEOM_Object_ptr theCentPoint,
1052                                               GEOM::GEOM_Object_ptr thePoint1,
1053                                               GEOM::GEOM_Object_ptr thePoint2)
1054 {
1055   //Set a not done flag
1056   GetOperations()->SetNotDone();
1057   GEOM::GEOM_Object_var aGEOMObject;
1058
1059   if (CORBA::is_nil(theObject))
1060     return aGEOMObject._retn();
1061
1062   //check if the object is a subshape
1063   if (!theObject->IsMainShape()) {
1064     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1065     return aGEOMObject._retn();
1066   }
1067
1068   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1069
1070   //Get the object itself
1071   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1072   if (anObject.IsNull()) return aGEOMObject._retn();
1073
1074   //Get the central point of rotation
1075   Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1076   if (aCentPoint.IsNull()) return aGEOMObject._retn();
1077
1078   //Get the first point
1079   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1080   if (aPoint1.IsNull()) return aGEOMObject._retn();
1081
1082   //Get the second point
1083   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1084   if (aPoint2.IsNull()) return aGEOMObject._retn();
1085
1086   //Perform the translation
1087   GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1088
1089   return aGEOMObject._retn();
1090 }
1091
1092 //=============================================================================
1093 /*!
1094  *  RotateThreePointsCopy
1095  */
1096 //=============================================================================
1097 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1098                                              (GEOM::GEOM_Object_ptr theObject,
1099                                               GEOM::GEOM_Object_ptr theCentPoint,
1100                                               GEOM::GEOM_Object_ptr thePoint1,
1101                                               GEOM::GEOM_Object_ptr thePoint2)
1102 {
1103   GEOM::GEOM_Object_var aGEOMObject;
1104
1105   //Set a not done flag
1106   GetOperations()->SetNotDone();
1107
1108   //Get the object itself
1109   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1110   if (aBasicObject.IsNull()) return aGEOMObject._retn();
1111
1112   //Get the central point of rotation
1113   Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1114   if (aCentPoint.IsNull()) return aGEOMObject._retn();
1115
1116   //Get the first point
1117   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1118   if (aPoint1.IsNull()) return aGEOMObject._retn();
1119
1120   //Get the second point
1121   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1122   if (aPoint2.IsNull()) return aGEOMObject._retn();
1123
1124   //Perform the rotation
1125   Handle(GEOM_Object) anObject =
1126     GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1127   if (!GetOperations()->IsDone() || anObject.IsNull())
1128     return aGEOMObject._retn();
1129
1130   return GetObject(anObject);
1131 }
1132
1133 //=============================================================================
1134 /*!
1135  *  RecomputeObject
1136  */
1137 //=============================================================================
1138 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1139                                              (GEOM::GEOM_Object_ptr theObject)
1140 {
1141   //Set a not done flag
1142   GetOperations()->SetNotDone();
1143   GEOM::GEOM_Object_var aGEOMObject;
1144
1145   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1146
1147   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1148
1149   //Get the object itself
1150   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1151   if (anObject.IsNull()) return aGEOMObject._retn();
1152
1153   //Perform the recomputation
1154   Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1155   if (aLastFunction.IsNull()) return aGEOMObject._retn();
1156   GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1157
1158   return aGEOMObject._retn();
1159 }