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