Salome HOME
EDF 2281: Added the possibility to choose the orientation of the divided disk
[modules/geom.git] / src / GEOM_I / GEOM_ITransformOperations_i.cc
1 // Copyright (C) 2007-2012  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 sub-shape
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 sub-shape
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 sub-shape
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 sub-shape
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 sub-shape
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 sub-shape
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 sub-shape
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 sub-shape
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 sub-shape
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  *  ProjectShapeCopy
643  */
644 //=============================================================================
645 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ProjectShapeCopy
646                                              (GEOM::GEOM_Object_ptr theSource,
647                                               GEOM::GEOM_Object_ptr theTarget)
648 {
649   GEOM::GEOM_Object_var aGEOMObject;
650
651   //Set a not done flag
652   GetOperations()->SetNotDone();
653
654   //Get the input objects
655   Handle(GEOM_Object) aSource = GetObjectImpl(theSource);
656   Handle(GEOM_Object) aTarget = GetObjectImpl(theTarget);
657   if (aSource.IsNull() || aTarget.IsNull()) return aGEOMObject._retn();
658
659   //Create the projection
660   Handle(GEOM_Object) anObject = GetOperations()->ProjectShapeCopy(aSource, aTarget);
661   if (!GetOperations()->IsDone() || anObject.IsNull())
662     return aGEOMObject._retn();
663
664   return GetObject(anObject);
665 }
666
667 //=============================================================================
668 /*!
669  *  ScaleShape
670  */
671 //=============================================================================
672 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
673                                              (GEOM::GEOM_Object_ptr theObject,
674                                               GEOM::GEOM_Object_ptr thePoint,
675                                               CORBA::Double         theFactor)
676 {
677   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
678
679   //Set a not done flag
680   GetOperations()->SetNotDone();
681
682   if (theObject->_is_nil()) return aGEOMObject._retn();
683
684   //check if the object is a sub-shape
685   if (!theObject->IsMainShape()) {
686     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
687     return aGEOMObject._retn();
688   }
689
690   //Get the object itself
691   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
692   if (anObject.IsNull()) return aGEOMObject._retn();
693
694   //Get the point
695   Handle(GEOM_Object) aPoint;
696   if (!thePoint->_is_nil()) {
697     aPoint = GetObjectImpl(thePoint);
698     if (aPoint.IsNull()) return aGEOMObject._retn();
699   }
700
701   //Perform the scale
702   GetOperations()->ScaleShape(anObject, aPoint, theFactor);
703
704   return  aGEOMObject._retn();
705 }
706
707 //=============================================================================
708 /*!
709  *  ScaleShapeCopy
710  */
711 //=============================================================================
712 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
713                                              (GEOM::GEOM_Object_ptr theObject,
714                                               GEOM::GEOM_Object_ptr thePoint,
715                                               CORBA::Double         theFactor)
716 {
717   GEOM::GEOM_Object_var aGEOMObject;
718
719   //Set a not done flag
720   GetOperations()->SetNotDone();
721
722   //Get the basic object
723   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
724   if (aBasicObject.IsNull()) return aGEOMObject._retn();
725
726   //Get the point
727   Handle(GEOM_Object) aPoint;
728   if (!thePoint->_is_nil()) {
729     aPoint = GetObjectImpl(thePoint);
730     if (aPoint.IsNull()) return aGEOMObject._retn();
731   }
732
733   //Perform the scale
734   Handle(GEOM_Object) anObject =
735     GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
736   if (!GetOperations()->IsDone() || anObject.IsNull())
737     return aGEOMObject._retn();
738
739   return GetObject(anObject);
740 }
741
742 //=============================================================================
743 /*!
744  *  ScaleShapeAlongAxes
745  */
746 //=============================================================================
747 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
748                                              (GEOM::GEOM_Object_ptr theObject,
749                                               GEOM::GEOM_Object_ptr thePoint,
750                                               CORBA::Double         theFactorX,
751                                               CORBA::Double         theFactorY,
752                                               CORBA::Double         theFactorZ)
753 {
754   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
755
756   //Set a not done flag
757   GetOperations()->SetNotDone();
758
759   if (theObject->_is_nil()) return aGEOMObject._retn();
760
761   //check if the object is a sub-shape
762   if (!theObject->IsMainShape()) {
763     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
764     return aGEOMObject._retn();
765   }
766
767   //Get the object itself
768   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
769   if (anObject.IsNull()) return aGEOMObject._retn();
770
771   //Get the point
772   Handle(GEOM_Object) aPoint;
773   if (!thePoint->_is_nil()) {
774     aPoint = GetObjectImpl(thePoint);
775     if (aPoint.IsNull()) return aGEOMObject._retn();
776   }
777
778   //Perform the scale
779   GetOperations()->ScaleShapeAlongAxes
780     (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
781
782   return  aGEOMObject._retn();
783 }
784
785 //=============================================================================
786 /*!
787  *  ScaleShapeAlongAxesCopy
788  */
789 //=============================================================================
790 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
791                                              (GEOM::GEOM_Object_ptr theObject,
792                                               GEOM::GEOM_Object_ptr thePoint,
793                                               CORBA::Double         theFactorX,
794                                               CORBA::Double         theFactorY,
795                                               CORBA::Double         theFactorZ)
796 {
797   GEOM::GEOM_Object_var aGEOMObject;
798
799   //Set a not done flag
800   GetOperations()->SetNotDone();
801
802   //Get the basic object
803   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
804   if (aBasicObject.IsNull()) return aGEOMObject._retn();
805
806   //Get the point
807   Handle(GEOM_Object) aPoint;
808   if (!thePoint->_is_nil()) {
809     aPoint = GetObjectImpl(thePoint);
810     if (aPoint.IsNull()) return aGEOMObject._retn();
811   }
812
813   //Perform the scale
814   Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
815     (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
816   if (!GetOperations()->IsDone() || anObject.IsNull())
817     return aGEOMObject._retn();
818
819   return GetObject(anObject);
820 }
821
822 //=============================================================================
823 /*!
824  *  PositionShape
825  */
826 //=============================================================================
827 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
828                                              (GEOM::GEOM_Object_ptr theObject,
829                                               GEOM::GEOM_Object_ptr theStartLCS,
830                                               GEOM::GEOM_Object_ptr theEndLCS)
831 {
832   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
833
834   //Set a not done flag
835   GetOperations()->SetNotDone();
836
837   if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
838     return aGEOMObject._retn();
839
840   //check if the object is a sub-shape
841   if (!theObject->IsMainShape()) {
842     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
843     return aGEOMObject._retn();
844   }
845
846   //Get the basic object
847   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
848   if (anObject.IsNull()) return aGEOMObject._retn();
849
850   //Get the Start LCS (may be NULL for positioning from global LCS)
851   Handle(GEOM_Object) aStartLCS;
852   if (!CORBA::is_nil(theStartLCS)) {
853     aStartLCS = GetObjectImpl(theStartLCS);
854     if (aStartLCS.IsNull()) return aGEOMObject._retn();
855   }
856
857   //Get the End LCS
858   Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
859   if (aEndLCS.IsNull()) return aGEOMObject._retn();
860
861   //Perform the Position
862   GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
863
864   return  aGEOMObject._retn();
865 }
866
867 //=============================================================================
868 /*!
869  *  PositionShapeCopy
870  */
871 //=============================================================================
872 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
873                                              (GEOM::GEOM_Object_ptr theObject,
874                                               GEOM::GEOM_Object_ptr theStartLCS,
875                                               GEOM::GEOM_Object_ptr theEndLCS)
876 {
877   GEOM::GEOM_Object_var aGEOMObject;
878
879   //Set a not done flag
880   GetOperations()->SetNotDone();
881
882   //Get the basic object
883   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
884   if (aBasicObject.IsNull()) return aGEOMObject._retn();
885
886   //Get the Start LCS (may be NULL for positioning from global LCS)
887   Handle(GEOM_Object) aStartLCS;
888   if (!CORBA::is_nil(theStartLCS)) {
889     aStartLCS = GetObjectImpl(theStartLCS);
890     if (aStartLCS.IsNull()) return aGEOMObject._retn();
891   }
892
893   //Get the End LCS
894   Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
895   if (aEndLCS.IsNull()) return aGEOMObject._retn();
896
897   //Perform the position
898   Handle(GEOM_Object) anObject =
899     GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
900   if (!GetOperations()->IsDone() || anObject.IsNull())
901     return aGEOMObject._retn();
902
903   return GetObject(anObject);
904 }
905
906 //=============================================================================
907 /*!
908  *  PositionAlongPath
909  */
910 //=============================================================================
911 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
912                                              (GEOM::GEOM_Object_ptr theObject,
913                                               GEOM::GEOM_Object_ptr thePath,
914                                               CORBA::Double         theDistance,
915                                               CORBA::Boolean        theCopy,
916                                               CORBA::Boolean        theReverse)
917 {
918   GEOM::GEOM_Object_var aGEOMObject;
919
920   //Set a not done flag
921   GetOperations()->SetNotDone();
922
923   //Get the basic object
924   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
925   if (aBasicObject.IsNull()) return aGEOMObject._retn();
926
927   //Get the path object
928   Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
929   if (aPathObject.IsNull()) return aGEOMObject._retn();
930
931   //Perform the position
932   Handle(GEOM_Object) anObject =
933     GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
934   if (!GetOperations()->IsDone() || anObject.IsNull())
935     return aGEOMObject._retn();
936
937   return GetObject(anObject);
938 }
939
940 //=============================================================================
941 /*!
942  *  MultiTranslate1D
943  */
944 //=============================================================================
945 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
946                            (GEOM::GEOM_Object_ptr theObject,
947                             GEOM::GEOM_Object_ptr theVector,
948                             CORBA::Double theStep, CORBA::Long theNbTimes)
949 {
950   //Set a not done flag
951   GetOperations()->SetNotDone();
952
953   GEOM::GEOM_Object_var aGEOMObject;
954
955   //Get the object itself
956   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
957   if (aBasicObject.IsNull()) return aGEOMObject._retn();
958
959   //Get the vector of translation
960   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
961   if (aVector.IsNull()) return aGEOMObject._retn();
962
963   //Perform the translation
964   Handle(GEOM_Object) anObject =
965     GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
966   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
967
968   return GetObject(anObject);
969 }
970
971 //=============================================================================
972 /*!
973  *  MultiTranslate2D
974  */
975 //=============================================================================
976 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
977                                                                      GEOM::GEOM_Object_ptr theVector1,
978                                                                      CORBA::Double theStep1,
979                                                                      CORBA::Long theNbTimes1,
980                                                                      GEOM::GEOM_Object_ptr theVector2,
981                                                                      CORBA::Double theStep2,
982                                                                      CORBA::Long theNbTimes2)
983 {
984   //Set a not done flag
985   GetOperations()->SetNotDone();
986
987   GEOM::GEOM_Object_var aGEOMObject;
988
989   //Get the object itself
990   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
991   if (aBasicObject.IsNull()) return aGEOMObject._retn();
992
993   //Get the vector1 of translation
994   Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
995   if (aVector1.IsNull()) return aGEOMObject._retn();
996
997   //Get the vector2 of translation
998   Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
999   if (aVector2.IsNull()) return aGEOMObject._retn();
1000
1001   //Perform the translation
1002   Handle(GEOM_Object) anObject = GetOperations()->Translate2D
1003     (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
1004   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1005
1006   return GetObject(anObject);
1007 }
1008
1009 //=============================================================================
1010 /*!
1011  *  MultiRotate1D
1012  */
1013 //=============================================================================
1014 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
1015                                                                   GEOM::GEOM_Object_ptr theVector,
1016                                                                   CORBA::Long theNbTimes)
1017 {
1018   //Set a not done flag
1019   GetOperations()->SetNotDone();
1020
1021   GEOM::GEOM_Object_var aGEOMObject;
1022
1023   //Get the object itself
1024   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1025   if (aBasicObject.IsNull()) return aGEOMObject._retn();
1026
1027   //Get the a directon of rotation
1028   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1029   if (aVector.IsNull()) return aGEOMObject._retn();
1030
1031   //Perform the rotation
1032   Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1033   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1034
1035   return GetObject(anObject);
1036 }
1037
1038 //=============================================================================
1039 /*!
1040  *  MultiRotate2D
1041  */
1042 //=============================================================================
1043 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1044                                                                   GEOM::GEOM_Object_ptr theVector,
1045                                                                   CORBA::Double theAngle,
1046                                                                   CORBA::Long theNbTimes1,
1047                                                                   CORBA::Double theStep,
1048                                                                   CORBA::Long theNbTimes2)
1049 {
1050   //Set a not done flag
1051   GetOperations()->SetNotDone();
1052
1053   GEOM::GEOM_Object_var aGEOMObject;
1054
1055   //Get the object itself
1056   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1057   if (aBasicObject.IsNull()) return aGEOMObject._retn();
1058
1059   //Get the a directon of rotation
1060   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1061   if (aVector.IsNull()) return aGEOMObject._retn();
1062
1063   //Perform the rotation
1064   Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1065     (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1066   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1067
1068   return GetObject(anObject);
1069 }
1070
1071 //=============================================================================
1072 /*!
1073  *  RotateThreePoints
1074  */
1075 //=============================================================================
1076 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1077                                              (GEOM::GEOM_Object_ptr theObject,
1078                                               GEOM::GEOM_Object_ptr theCentPoint,
1079                                               GEOM::GEOM_Object_ptr thePoint1,
1080                                               GEOM::GEOM_Object_ptr thePoint2)
1081 {
1082   //Set a not done flag
1083   GetOperations()->SetNotDone();
1084   GEOM::GEOM_Object_var aGEOMObject;
1085
1086   if (CORBA::is_nil(theObject))
1087     return aGEOMObject._retn();
1088
1089   //check if the object is a sub-shape
1090   if (!theObject->IsMainShape()) {
1091     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1092     return aGEOMObject._retn();
1093   }
1094
1095   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1096
1097   //Get the object itself
1098   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1099   if (anObject.IsNull()) return aGEOMObject._retn();
1100
1101   //Get the central point of rotation
1102   Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1103   if (aCentPoint.IsNull()) return aGEOMObject._retn();
1104
1105   //Get the first point
1106   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1107   if (aPoint1.IsNull()) return aGEOMObject._retn();
1108
1109   //Get the second point
1110   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1111   if (aPoint2.IsNull()) return aGEOMObject._retn();
1112
1113   //Perform the translation
1114   GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1115
1116   return aGEOMObject._retn();
1117 }
1118
1119 //=============================================================================
1120 /*!
1121  *  RotateThreePointsCopy
1122  */
1123 //=============================================================================
1124 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1125                                              (GEOM::GEOM_Object_ptr theObject,
1126                                               GEOM::GEOM_Object_ptr theCentPoint,
1127                                               GEOM::GEOM_Object_ptr thePoint1,
1128                                               GEOM::GEOM_Object_ptr thePoint2)
1129 {
1130   GEOM::GEOM_Object_var aGEOMObject;
1131
1132   //Set a not done flag
1133   GetOperations()->SetNotDone();
1134
1135   //Get the object itself
1136   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1137   if (aBasicObject.IsNull()) return aGEOMObject._retn();
1138
1139   //Get the central point of rotation
1140   Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1141   if (aCentPoint.IsNull()) return aGEOMObject._retn();
1142
1143   //Get the first point
1144   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1145   if (aPoint1.IsNull()) return aGEOMObject._retn();
1146
1147   //Get the second point
1148   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1149   if (aPoint2.IsNull()) return aGEOMObject._retn();
1150
1151   //Perform the rotation
1152   Handle(GEOM_Object) anObject =
1153     GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1154   if (!GetOperations()->IsDone() || anObject.IsNull())
1155     return aGEOMObject._retn();
1156
1157   return GetObject(anObject);
1158 }
1159
1160 //=============================================================================
1161 /*!
1162  *  TransformLikeOtherCopy
1163  */
1164 //=============================================================================
1165 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TransformLikeOtherCopy
1166                                              (GEOM::GEOM_Object_ptr theObject,
1167                                               GEOM::GEOM_Object_ptr theSample)
1168 {
1169   GEOM::GEOM_Object_var aGEOMObject;
1170
1171   //Set a not done flag
1172   GetOperations()->SetNotDone();
1173
1174   //Get the object itself
1175   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1176   if (anObject.IsNull()) return aGEOMObject._retn();
1177
1178   //Get the sample object
1179   Handle(GEOM_Object) aSample = GetObjectImpl(theSample);
1180   if (aSample.IsNull()) return aGEOMObject._retn();
1181
1182   //Perform the transformation
1183   Handle(GEOM_Object) aResObject =
1184     GetOperations()->TransformLikeOtherCopy(anObject, aSample);
1185   if (!GetOperations()->IsDone() || aResObject.IsNull())
1186     return aGEOMObject._retn();
1187
1188   return GetObject(aResObject);
1189 }
1190
1191 //=============================================================================
1192 /*!
1193  *  RecomputeObject
1194  */
1195 //=============================================================================
1196 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1197                                              (GEOM::GEOM_Object_ptr theObject)
1198 {
1199   //Set a not done flag
1200   GetOperations()->SetNotDone();
1201   GEOM::GEOM_Object_var aGEOMObject;
1202
1203   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1204
1205   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1206
1207   //Get the object itself
1208   Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1209   if (anObject.IsNull()) return aGEOMObject._retn();
1210
1211   //Perform the recomputation
1212   Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1213   if (aLastFunction.IsNull()) return aGEOMObject._retn();
1214   GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1215
1216   return aGEOMObject._retn();
1217 }