Salome HOME
ENV: Windows porting.
[modules/geom.git] / src / GEOM_I / GEOM_ITransformOperations_i.cc
1 #include <Standard_Stream.hxx>
2
3 #include "GEOM_ITransformOperations_i.hh"
4
5 #include "utilities.h"
6 #include "OpUtil.hxx"
7 #include "Utils_ExceptHandlers.hxx"
8
9 #include <TDF_Label.hxx>
10 #include <TDF_Tool.hxx>
11 #include <TCollection_AsciiString.hxx>
12 #include "GEOM_Engine.hxx"
13 #include "GEOM_Object.hxx"
14
15 #define SUBSHAPE_ERROR "Sub shape cannot be transformed"
16
17 //=============================================================================
18 /*!
19  *   constructor:
20  */
21 //=============================================================================
22
23 GEOM_ITransformOperations_i::GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA,
24                                                           GEOM::GEOM_Gen_ptr theEngine,
25                                                           ::GEOMImpl_ITransformOperations* theImpl)
26      :GEOM_IOperations_i(thePOA, theEngine, theImpl)
27 {
28   MESSAGE("GEOM_ITransformOperations_i::GEOM_ITransformOperations_i");
29 }
30
31 //=============================================================================
32 /*!
33  *  destructor
34  */
35 //=============================================================================
36
37 GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i()
38 {
39   MESSAGE("GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i");
40 }
41
42
43 //=============================================================================
44 /*!
45  *  TranslateTwoPoints
46  */
47 //============================================================================= 
48 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints
49                                              (GEOM::GEOM_Object_ptr theObject,
50                                               GEOM::GEOM_Object_ptr thePoint1,
51                                               GEOM::GEOM_Object_ptr thePoint2)
52 {
53   //Set a not done flag
54   GetOperations()->SetNotDone();
55   GEOM::GEOM_Object_var aGEOMObject;
56   
57   if (thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
58
59   //check if the object is a subshape
60   if(!theObject->IsMainShape()) {
61     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
62     return aGEOMObject._retn();
63   }
64
65   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
66
67   //Get the object itself
68   Handle(GEOM_Object) anObject =
69     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
70   if (anObject.IsNull()) return aGEOMObject._retn();
71
72   //Get the first point of translation
73   Handle(GEOM_Object) aPoint1 =
74     GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
75   if (aPoint1.IsNull()) return aGEOMObject._retn();
76
77   //Get the second point of translation
78   Handle(GEOM_Object) aPoint2 =
79     GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
80   if (aPoint2.IsNull()) return aGEOMObject._retn();
81
82   //Perform the translation
83   GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2);
84
85   return aGEOMObject._retn();
86 }
87
88 //=============================================================================
89 /*!
90  *  TranslateTwoPointsCopy
91  */
92 //============================================================================= 
93 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
94                                              (GEOM::GEOM_Object_ptr theObject,
95                                               GEOM::GEOM_Object_ptr thePoint1,
96                                               GEOM::GEOM_Object_ptr thePoint2)
97 {
98   GEOM::GEOM_Object_var aGEOMObject;
99
100   //Set a not done flag
101   GetOperations()->SetNotDone();
102
103   if (thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
104
105   //Get the object itself
106   Handle(GEOM_Object) aBasicObject =
107     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
108   if (aBasicObject.IsNull()) return aGEOMObject._retn();
109
110   //Get the first point of translation
111   Handle(GEOM_Object) aPoint1 =
112     GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
113   if (aPoint1.IsNull()) return aGEOMObject._retn();
114
115   //Get the second point of translation
116   Handle(GEOM_Object) aPoint2 =
117     GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
118   if (aPoint2.IsNull()) return aGEOMObject._retn();
119
120   //Create the translated shape
121   Handle(GEOM_Object) anObject =
122     GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
123   if (!GetOperations()->IsDone() || anObject.IsNull())
124     return aGEOMObject._retn();
125
126   return GetObject(anObject);
127 }
128
129 //=============================================================================
130 /*!
131  *  TranslateDXDYDZ
132  */
133 //============================================================================= 
134 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, 
135                                                                     CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
136 {
137   //Set a not done flag
138   GetOperations()->SetNotDone(); 
139   GEOM::GEOM_Object_var aGEOMObject ;
140
141   if (theObject == NULL) return aGEOMObject._retn();
142
143   //check if the object is a subshape
144   if(!theObject->IsMainShape()) {
145     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
146     return aGEOMObject._retn();
147   }
148
149   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
150
151   //Get the object itself
152   Handle(GEOM_Object) anObject =
153     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
154   if (anObject.IsNull()) return aGEOMObject._retn();
155
156   //Perform the translation
157   GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
158
159   return aGEOMObject._retn();
160 }
161
162
163 //=============================================================================
164 /*!
165  *  TranslateDXDYDZCopy
166  */
167 //============================================================================= 
168 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
169                                              (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
170 {
171   GEOM::GEOM_Object_var aGEOMObject;
172
173   //Set a not done flag
174   GetOperations()->SetNotDone();
175
176   if (theObject == NULL) return aGEOMObject._retn();
177
178   //Get the object itself
179   Handle(GEOM_Object) aBasicObject =
180     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
181   if (aBasicObject.IsNull()) return aGEOMObject._retn();
182
183
184
185   //Create the translated shape
186   Handle(GEOM_Object) anObject =
187     GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
188   if (!GetOperations()->IsDone() || anObject.IsNull())
189     return aGEOMObject._retn();
190
191   return GetObject(anObject);
192 }
193
194  
195 //=============================================================================
196 /*!
197  *  TranslateVector
198  */
199 //============================================================================= 
200 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
201                                             (GEOM::GEOM_Object_ptr theObject,
202                                              GEOM::GEOM_Object_ptr theVector)
203 {
204   //Set a not done flag
205   GetOperations()->SetNotDone(); 
206   GEOM::GEOM_Object_var aGEOMObject;
207
208   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
209
210   //check if the object is a subshape
211   if(!theObject->IsMainShape()) {
212     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
213     return aGEOMObject._retn();
214   }
215
216    aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
217
218   //Get the object itself
219   Handle(GEOM_Object) anObject =
220     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
221   if (anObject.IsNull()) return aGEOMObject._retn();
222
223   //Get the vector of translation
224   Handle(GEOM_Object) aVector =
225     GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry());
226   if (aVector.IsNull()) return aGEOMObject._retn();
227   
228   //Perform the translation
229   GetOperations()->TranslateVector(anObject, aVector);   
230
231   return aGEOMObject._retn();  
232 }
233  
234 //=============================================================================
235 /*!
236  *  TranslateVectorCopy
237  */
238 //============================================================================= 
239 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
240                                             (GEOM::GEOM_Object_ptr theObject,
241                                              GEOM::GEOM_Object_ptr theVector)
242 {
243   GEOM::GEOM_Object_var aGEOMObject;
244
245   //Set a not done flag
246   GetOperations()->SetNotDone(); 
247
248   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
249
250   //Get the object itself
251   Handle(GEOM_Object) aBasicObject =
252     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
253   if (aBasicObject.IsNull()) return aGEOMObject._retn();
254
255   //Get the vector of translation
256   Handle(GEOM_Object) aVector =
257     GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry());
258   if (aVector.IsNull()) return aGEOMObject._retn();
259   
260   //Perform the translation
261   Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);   
262   if (!GetOperations()->IsDone() || anObject.IsNull())
263     return aGEOMObject._retn();
264
265   return GetObject(anObject);  
266 }
267
268
269 //=============================================================================
270 /*!
271  *  Rotate
272  */
273 //=============================================================================         
274 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
275                                                            GEOM::GEOM_Object_ptr theAxis,
276                                                            CORBA::Double theAngle)
277 {
278   //Set a not done flag
279   GetOperations()->SetNotDone(); 
280   GEOM::GEOM_Object_var aGEOMObject;
281
282   if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
283
284   //check if the object is a subshape
285   if(!theObject->IsMainShape()) {
286     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
287     return aGEOMObject._retn();
288   }
289
290   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
291
292   //Get the object itself
293   Handle(GEOM_Object) anObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
294   if (anObject.IsNull()) return aGEOMObject._retn();
295
296   //Get the axis of revolution
297   Handle(GEOM_Object) anAxis =
298     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
299   if (anAxis.IsNull()) return aGEOMObject._retn();
300   
301   //Perform the rotation
302   GetOperations()->Rotate(anObject, anAxis, theAngle);   
303
304   return aGEOMObject._retn();  
305 }
306
307 //=============================================================================
308 /*!
309  *  RotateCopy
310  */
311 //=============================================================================                                            
312 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
313                                                                GEOM::GEOM_Object_ptr theAxis,
314                                                                CORBA::Double theAngle)
315 {
316   GEOM::GEOM_Object_var aGEOMObject;
317
318   //Set a not done flag
319   GetOperations()->SetNotDone(); 
320
321   if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
322
323   //Get the object itself
324   Handle(GEOM_Object) aBasicObject =
325     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
326   if (aBasicObject.IsNull()) return aGEOMObject._retn();
327
328   //Get the axis of rotation
329   Handle(GEOM_Object) anAxis =
330     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
331   if (anAxis.IsNull()) return aGEOMObject._retn();
332   
333   //Perform the rotation
334   Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);   
335   if (!GetOperations()->IsDone() || anObject.IsNull())
336     return aGEOMObject._retn();
337
338   return GetObject(anObject);  
339 }
340
341
342 //=============================================================================
343 /*!
344  *  MirrorPlane
345  */
346 //============================================================================= 
347 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
348                                             (GEOM::GEOM_Object_ptr theObject,
349                                              GEOM::GEOM_Object_ptr thePlane)
350 {
351   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
352
353   //Set a not done flag
354   GetOperations()->SetNotDone(); 
355
356   if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
357
358   //check if the object is a subshape
359   if(!theObject->IsMainShape()) {
360     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
361     return aGEOMObject._retn();
362   }
363
364   //Get the object itself
365   Handle(GEOM_Object) anObject =
366     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
367   if (anObject.IsNull()) return aGEOMObject._retn();
368
369   //Get the plane
370   Handle(GEOM_Object) aPlane =
371     GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
372   if (aPlane.IsNull()) return aGEOMObject._retn();
373
374   //Perform the mirror
375   GetOperations()->MirrorPlane(anObject, aPlane);   
376
377   return aGEOMObject._retn();  
378 }
379  
380 //=============================================================================
381 /*!
382  *  MirrorPlaneCopy
383  */
384 //============================================================================= 
385 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
386                                             (GEOM::GEOM_Object_ptr theObject,
387                                              GEOM::GEOM_Object_ptr thePlane)
388 {
389   GEOM::GEOM_Object_var aGEOMObject;
390
391   //Set a not done flag
392   GetOperations()->SetNotDone(); 
393
394   if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
395
396   //Get the object itself
397   Handle(GEOM_Object) aBasicObject =
398     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
399   if (aBasicObject.IsNull()) return aGEOMObject._retn();
400
401   //Get the vector of translation
402   Handle(GEOM_Object) aPlane =
403     GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
404   if (aPlane.IsNull()) return aGEOMObject._retn();
405   
406   //Perform the mirror
407   Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);   
408   if (!GetOperations()->IsDone() || anObject.IsNull())
409     return aGEOMObject._retn();
410
411   return GetObject(anObject);  
412 }
413
414 //=============================================================================
415 /*!
416  *  MirrorAxis
417  */
418 //============================================================================= 
419 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
420                                             (GEOM::GEOM_Object_ptr theObject,
421                                              GEOM::GEOM_Object_ptr theAxis)
422 {
423   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
424
425   //Set a not done flag
426   GetOperations()->SetNotDone(); 
427
428   if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
429
430   //check if the object is a subshape
431   if(!theObject->IsMainShape()) {
432     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
433     return aGEOMObject._retn();
434   }
435
436   //Get the object itself
437   Handle(GEOM_Object) anObject =
438     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
439   if (anObject.IsNull()) return aGEOMObject._retn();
440
441   //Get the axis
442   Handle(GEOM_Object) aAxis =
443     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
444   if (aAxis.IsNull()) return aGEOMObject._retn();
445
446   //Perform the mirror
447   GetOperations()->MirrorAxis(anObject, aAxis);   
448
449   return aGEOMObject._retn();  
450 }
451  
452 //=============================================================================
453 /*!
454  *  MirrorAxisCopy
455  */
456 //============================================================================= 
457 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
458                                             (GEOM::GEOM_Object_ptr theObject,
459                                              GEOM::GEOM_Object_ptr theAxis)
460 {
461   GEOM::GEOM_Object_var aGEOMObject;
462
463   //Set a not done flag
464   GetOperations()->SetNotDone(); 
465
466   if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
467
468   //Get the object itself
469   Handle(GEOM_Object) aBasicObject =
470     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
471   if (aBasicObject.IsNull()) return aGEOMObject._retn();
472
473   //Get the vector of translation
474   Handle(GEOM_Object) aAxis =
475     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
476   if (aAxis.IsNull()) return aGEOMObject._retn();
477   
478   //Perform the mirror
479   Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);   
480   if (!GetOperations()->IsDone() || anObject.IsNull())
481     return aGEOMObject._retn();
482
483   return GetObject(anObject);  
484 }
485
486 //=============================================================================
487 /*!
488  *  MirrorPoint
489  */
490 //============================================================================= 
491 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
492                                             (GEOM::GEOM_Object_ptr theObject,
493                                              GEOM::GEOM_Object_ptr thePoint)
494 {
495   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
496
497   //Set a not done flag
498   GetOperations()->SetNotDone(); 
499
500   if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
501
502   //check if the object is a subshape
503   if(!theObject->IsMainShape()) {
504     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
505     return aGEOMObject._retn();
506   }
507
508   //Get the object itself
509   Handle(GEOM_Object) anObject =
510     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
511   if (anObject.IsNull()) return aGEOMObject._retn();
512
513   //Get the point
514   Handle(GEOM_Object) aPoint =
515     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
516   if (aPoint.IsNull()) return aGEOMObject._retn();
517
518   //Perform the mirror
519   GetOperations()->MirrorPoint(anObject, aPoint);   
520
521   return aGEOMObject._retn();  
522 }
523  
524 //=============================================================================
525 /*!
526  *  MirrorPointCopy
527  */
528 //============================================================================= 
529 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
530                                             (GEOM::GEOM_Object_ptr theObject,
531                                              GEOM::GEOM_Object_ptr thePoint)
532 {
533   GEOM::GEOM_Object_var aGEOMObject;
534
535   //Set a not done flag
536   GetOperations()->SetNotDone(); 
537
538   if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
539
540   //Get the object itself
541   Handle(GEOM_Object) aBasicObject =
542     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
543   if (aBasicObject.IsNull()) return aGEOMObject._retn();
544
545   //Get the vector of translation
546   Handle(GEOM_Object) aPoint =
547     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
548   if (aPoint.IsNull()) return aGEOMObject._retn();
549   
550   //Perform the mirror
551   Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);   
552   if (!GetOperations()->IsDone() || anObject.IsNull())
553     return aGEOMObject._retn();
554
555   return GetObject(anObject);  
556 }
557
558
559 //=============================================================================
560 /*!
561  *  OffsetShape
562  */
563 //============================================================================= 
564 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
565                                              (GEOM::GEOM_Object_ptr theObject,
566                                               CORBA::Double theOffset)
567 {
568   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
569
570   //Set a not done flag
571   GetOperations()->SetNotDone();
572
573   if (theObject == NULL) return aGEOMObject._retn();
574
575   //check if the object is a subshape
576   if(!theObject->IsMainShape()) {
577     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
578     return aGEOMObject._retn();
579   }
580
581
582   //Get the basic object
583   Handle(GEOM_Object) aBasicObject =
584     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
585   if (aBasicObject.IsNull()) return aGEOMObject._retn();
586
587   //Create the offset shape
588   GetOperations()->OffsetShape(aBasicObject, theOffset);
589
590   return aGEOMObject._retn();
591 }
592
593 //=============================================================================
594 /*!
595  *  OffsetShapeCopy
596  */
597 //============================================================================= 
598 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
599                                              (GEOM::GEOM_Object_ptr theObject,
600                                               CORBA::Double theOffset)
601 {
602   GEOM::GEOM_Object_var aGEOMObject;
603
604   //Set a not done flag
605   GetOperations()->SetNotDone();
606
607   if (theObject == NULL) return aGEOMObject._retn();
608
609   //Get the basic object
610   Handle(GEOM_Object) aBasicObject =
611     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
612   if (aBasicObject.IsNull()) return aGEOMObject._retn();
613
614   //Create the offset shape
615   Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
616   if (!GetOperations()->IsDone() || anObject.IsNull())
617     return aGEOMObject._retn();
618
619   return GetObject(anObject);
620 }
621
622
623 //=============================================================================
624 /*!
625  *  ScaleShape
626  */
627 //============================================================================= 
628 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
629                                              (GEOM::GEOM_Object_ptr theObject,
630                                               GEOM::GEOM_Object_ptr thePoint,
631                                               CORBA::Double theFactor)
632 {
633   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
634
635   //Set a not done flag
636   GetOperations()->SetNotDone();
637
638   if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
639
640   //check if the object is a subshape
641   if(!theObject->IsMainShape()) {
642     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
643     return aGEOMObject._retn();
644   }
645
646   //Get the object itself
647   Handle(GEOM_Object) anObject =
648     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
649   if (anObject.IsNull()) return aGEOMObject._retn();
650
651   //Get the point
652   Handle(GEOM_Object) aPoint =
653     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
654   if (aPoint.IsNull()) return aGEOMObject._retn();
655
656   //Perform the scale
657   GetOperations()->ScaleShape(anObject, aPoint, theFactor);
658
659   return  aGEOMObject._retn();
660 }
661
662 //=============================================================================
663 /*!
664  *  ScaleShapeCopy
665  */
666 //============================================================================= 
667 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
668                                              (GEOM::GEOM_Object_ptr theObject,
669                                               GEOM::GEOM_Object_ptr thePoint,
670                                               CORBA::Double theFactor)
671 {
672   GEOM::GEOM_Object_var aGEOMObject;
673
674   //Set a not done flag
675   GetOperations()->SetNotDone();
676
677   if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
678
679   //Get the basic object
680   Handle(GEOM_Object) aBasicObject =
681     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
682   if (aBasicObject.IsNull()) return aGEOMObject._retn();
683
684   //Get the point
685   Handle(GEOM_Object) aPoint =
686     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
687   if (aPoint.IsNull()) return aGEOMObject._retn();
688
689   //Perform the scale
690   Handle(GEOM_Object) anObject =
691     GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
692   if (!GetOperations()->IsDone() || anObject.IsNull())
693     return aGEOMObject._retn();
694
695   return GetObject(anObject);
696 }
697
698 //=============================================================================
699 /*!
700  *  PositionShape
701  */
702 //============================================================================= 
703 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
704                                              (GEOM::GEOM_Object_ptr theObject,
705                                               GEOM::GEOM_Object_ptr theStartLCS,
706                                               GEOM::GEOM_Object_ptr theEndLCS)
707 {
708   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
709
710   //Set a not done flag
711   GetOperations()->SetNotDone();
712
713   if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL)
714     return aGEOMObject._retn();
715
716   //check if the object is a subshape
717   if(!theObject->IsMainShape()) {
718     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
719     return aGEOMObject._retn();
720   }
721
722   //Get the basic object
723   Handle(GEOM_Object) anObject =
724     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
725   if (anObject.IsNull()) return aGEOMObject._retn();
726
727   //Get the Start LCS
728   Handle(GEOM_Object) aStartLCS =
729     GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
730   if (aStartLCS.IsNull()) return aGEOMObject._retn();
731
732   //Get the End LCS
733   Handle(GEOM_Object) aEndLCS =
734     GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
735   if (aEndLCS.IsNull()) return aGEOMObject._retn();
736
737   //Perform the Position
738   GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
739
740   return  aGEOMObject._retn();
741 }
742
743 //=============================================================================
744 /*!
745  *  PositionShapeCopy
746  */
747 //============================================================================= 
748 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
749                                              (GEOM::GEOM_Object_ptr theObject,
750                                               GEOM::GEOM_Object_ptr theStartLCS,
751                                               GEOM::GEOM_Object_ptr theEndLCS)
752 {
753   GEOM::GEOM_Object_var aGEOMObject;
754
755   //Set a not done flag
756   GetOperations()->SetNotDone();
757
758   if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL)
759     return aGEOMObject._retn();
760
761   //Get the basic object
762   Handle(GEOM_Object) aBasicObject =
763     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
764   if (aBasicObject.IsNull()) return aGEOMObject._retn();
765
766   //Get the Start LCS
767   Handle(GEOM_Object) aStartLCS =
768     GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
769   if (aStartLCS.IsNull()) return aGEOMObject._retn();
770
771   //Get the End LCS
772   Handle(GEOM_Object) aEndLCS =
773     GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
774   if (aEndLCS.IsNull()) return aGEOMObject._retn();
775
776   //Perform the position
777   Handle(GEOM_Object) anObject =
778     GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
779   if (!GetOperations()->IsDone() || anObject.IsNull())
780     return aGEOMObject._retn();
781
782   return GetObject(anObject);
783 }
784
785 //=============================================================================
786 /*!
787  *  MultiTranslate1D
788  */
789 //============================================================================= 
790 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
791                            (GEOM::GEOM_Object_ptr theObject,
792                             GEOM::GEOM_Object_ptr theVector,
793                             CORBA::Double theStep, CORBA::Long theNbTimes)
794 {
795   //Set a not done flag
796   GetOperations()->SetNotDone(); 
797
798   GEOM::GEOM_Object_var aGEOMObject;
799
800   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
801
802   //Get the object itself
803   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
804     (theObject->GetStudyID(), theObject->GetEntry());
805   if (aBasicObject.IsNull()) return aGEOMObject._retn();
806
807   //Get the vector of translation
808   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
809     (theVector->GetStudyID(), theVector->GetEntry());
810   if (aVector.IsNull()) return aGEOMObject._retn();
811
812   //Perform the translation
813   Handle(GEOM_Object) anObject =
814     GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);   
815   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
816
817   return GetObject(anObject); 
818 }
819
820 //=============================================================================
821 /*!
822  *  MultiTranslate2D
823  */
824 //============================================================================= 
825 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, 
826                                                                      GEOM::GEOM_Object_ptr theVector1, 
827                                                                      CORBA::Double theStep1, 
828                                                                      CORBA::Long theNbTimes1,
829                                                                      GEOM::GEOM_Object_ptr theVector2, 
830                                                                      CORBA::Double theStep2, 
831                                                                      CORBA::Long theNbTimes2)
832 {
833   //Set a not done flag
834   GetOperations()->SetNotDone(); 
835
836   GEOM::GEOM_Object_var aGEOMObject;
837
838   if (theObject == NULL || theVector1 == NULL || theVector2 == NULL) return aGEOMObject._retn();
839
840   //Get the object itself
841   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
842     (theObject->GetStudyID(), theObject->GetEntry());
843   if (aBasicObject.IsNull()) return aGEOMObject._retn();
844
845   //Get the vector1 of translation
846   Handle(GEOM_Object) aVector1 = GetOperations()->GetEngine()->GetObject
847     (theVector1->GetStudyID(), theVector1->GetEntry());
848   if (aVector1.IsNull()) return aGEOMObject._retn();
849
850   //Get the vector2 of translation
851   Handle(GEOM_Object) aVector2 = GetOperations()->GetEngine()->GetObject
852     (theVector2->GetStudyID(), theVector2->GetEntry());
853   if (aVector2.IsNull()) return aGEOMObject._retn();
854
855   //Perform the translation
856   Handle(GEOM_Object) anObject = GetOperations()->Translate2D
857     (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);   
858   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
859
860   return GetObject(anObject); 
861 }
862
863 //=============================================================================
864 /*!
865  *  MultiRotate1D
866  */
867 //============================================================================= 
868 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
869                                                                   GEOM::GEOM_Object_ptr theVector,
870                                                                   CORBA::Long theNbTimes)
871 {
872   //Set a not done flag
873   GetOperations()->SetNotDone(); 
874
875   GEOM::GEOM_Object_var aGEOMObject;
876
877   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
878
879   //Get the object itself
880   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
881     (theObject->GetStudyID(), theObject->GetEntry());
882   if (aBasicObject.IsNull()) return aGEOMObject._retn();
883
884   //Get the a directon of rotation
885   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
886     (theVector->GetStudyID(), theVector->GetEntry());
887   if (aVector.IsNull()) return aGEOMObject._retn();
888
889   //Perform the rotation
890   Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);   
891   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
892
893   return GetObject(anObject);  
894 }
895
896 //=============================================================================
897 /*!
898  *  MultiRotate2D
899  */
900 //============================================================================= 
901 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
902                                                                   GEOM::GEOM_Object_ptr theVector,
903                                                                   CORBA::Double theAngle, 
904                                                                   CORBA::Long theNbTimes1, 
905                                                                   CORBA::Double theStep, 
906                                                                   CORBA::Long theNbTimes2)
907 {
908   //Set a not done flag
909   GetOperations()->SetNotDone(); 
910
911   GEOM::GEOM_Object_var aGEOMObject;
912
913   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
914
915   //Get the object itself
916   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
917     (theObject->GetStudyID(), theObject->GetEntry());
918   if (aBasicObject.IsNull()) return aGEOMObject._retn();
919
920   //Get the a directon of rotation
921   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
922     (theVector->GetStudyID(), theVector->GetEntry());
923   if (aVector.IsNull()) return aGEOMObject._retn();
924
925   //Perform the rotation
926   Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
927     (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);   
928   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
929
930   return GetObject(anObject);  
931 }