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