Salome HOME
PAL12608: Add possibility to check geometry of a shape.
[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 /*!
290  *  Rotate
291  */
292 //=============================================================================         
293 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
294                                                            GEOM::GEOM_Object_ptr theAxis,
295                                                            CORBA::Double theAngle)
296 {
297   //Set a not done flag
298   GetOperations()->SetNotDone(); 
299   GEOM::GEOM_Object_var aGEOMObject;
300
301   if (theObject == NULL || theAxis == NULL) 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   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
310
311   //Get the object itself
312   Handle(GEOM_Object) anObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
313   if (anObject.IsNull()) return aGEOMObject._retn();
314
315   //Get the axis of revolution
316   Handle(GEOM_Object) anAxis =
317     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
318   if (anAxis.IsNull()) return aGEOMObject._retn();
319   
320   //Perform the rotation
321   GetOperations()->Rotate(anObject, anAxis, theAngle);   
322
323   return aGEOMObject._retn();  
324 }
325
326 //=============================================================================
327 /*!
328  *  RotateCopy
329  */
330 //=============================================================================                                            
331 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
332                                                                GEOM::GEOM_Object_ptr theAxis,
333                                                                CORBA::Double theAngle)
334 {
335   GEOM::GEOM_Object_var aGEOMObject;
336
337   //Set a not done flag
338   GetOperations()->SetNotDone(); 
339
340   if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
341
342   //Get the object itself
343   Handle(GEOM_Object) aBasicObject =
344     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
345   if (aBasicObject.IsNull()) return aGEOMObject._retn();
346
347   //Get the axis of rotation
348   Handle(GEOM_Object) anAxis =
349     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
350   if (anAxis.IsNull()) return aGEOMObject._retn();
351   
352   //Perform the rotation
353   Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);   
354   if (!GetOperations()->IsDone() || anObject.IsNull())
355     return aGEOMObject._retn();
356
357   return GetObject(anObject);  
358 }
359
360
361 //=============================================================================
362 /*!
363  *  MirrorPlane
364  */
365 //============================================================================= 
366 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
367                                             (GEOM::GEOM_Object_ptr theObject,
368                                              GEOM::GEOM_Object_ptr thePlane)
369 {
370   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
371
372   //Set a not done flag
373   GetOperations()->SetNotDone(); 
374
375   if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
376
377   //check if the object is a subshape
378   if(!theObject->IsMainShape()) {
379     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
380     return aGEOMObject._retn();
381   }
382
383   //Get the object itself
384   Handle(GEOM_Object) anObject =
385     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
386   if (anObject.IsNull()) return aGEOMObject._retn();
387
388   //Get the plane
389   Handle(GEOM_Object) aPlane =
390     GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
391   if (aPlane.IsNull()) return aGEOMObject._retn();
392
393   //Perform the mirror
394   GetOperations()->MirrorPlane(anObject, aPlane);   
395
396   return aGEOMObject._retn();  
397 }
398  
399 //=============================================================================
400 /*!
401  *  MirrorPlaneCopy
402  */
403 //============================================================================= 
404 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
405                                             (GEOM::GEOM_Object_ptr theObject,
406                                              GEOM::GEOM_Object_ptr thePlane)
407 {
408   GEOM::GEOM_Object_var aGEOMObject;
409
410   //Set a not done flag
411   GetOperations()->SetNotDone(); 
412
413   if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
414
415   //Get the object itself
416   Handle(GEOM_Object) aBasicObject =
417     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
418   if (aBasicObject.IsNull()) return aGEOMObject._retn();
419
420   //Get the vector of translation
421   Handle(GEOM_Object) aPlane =
422     GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
423   if (aPlane.IsNull()) return aGEOMObject._retn();
424   
425   //Perform the mirror
426   Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);   
427   if (!GetOperations()->IsDone() || anObject.IsNull())
428     return aGEOMObject._retn();
429
430   return GetObject(anObject);  
431 }
432
433 //=============================================================================
434 /*!
435  *  MirrorAxis
436  */
437 //============================================================================= 
438 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
439                                             (GEOM::GEOM_Object_ptr theObject,
440                                              GEOM::GEOM_Object_ptr theAxis)
441 {
442   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
443
444   //Set a not done flag
445   GetOperations()->SetNotDone(); 
446
447   if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
448
449   //check if the object is a subshape
450   if(!theObject->IsMainShape()) {
451     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
452     return aGEOMObject._retn();
453   }
454
455   //Get the object itself
456   Handle(GEOM_Object) anObject =
457     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
458   if (anObject.IsNull()) return aGEOMObject._retn();
459
460   //Get the axis
461   Handle(GEOM_Object) aAxis =
462     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
463   if (aAxis.IsNull()) return aGEOMObject._retn();
464
465   //Perform the mirror
466   GetOperations()->MirrorAxis(anObject, aAxis);   
467
468   return aGEOMObject._retn();  
469 }
470  
471 //=============================================================================
472 /*!
473  *  MirrorAxisCopy
474  */
475 //============================================================================= 
476 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
477                                             (GEOM::GEOM_Object_ptr theObject,
478                                              GEOM::GEOM_Object_ptr theAxis)
479 {
480   GEOM::GEOM_Object_var aGEOMObject;
481
482   //Set a not done flag
483   GetOperations()->SetNotDone(); 
484
485   if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
486
487   //Get the object itself
488   Handle(GEOM_Object) aBasicObject =
489     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
490   if (aBasicObject.IsNull()) return aGEOMObject._retn();
491
492   //Get the vector of translation
493   Handle(GEOM_Object) aAxis =
494     GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
495   if (aAxis.IsNull()) return aGEOMObject._retn();
496   
497   //Perform the mirror
498   Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);   
499   if (!GetOperations()->IsDone() || anObject.IsNull())
500     return aGEOMObject._retn();
501
502   return GetObject(anObject);  
503 }
504
505 //=============================================================================
506 /*!
507  *  MirrorPoint
508  */
509 //============================================================================= 
510 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
511                                             (GEOM::GEOM_Object_ptr theObject,
512                                              GEOM::GEOM_Object_ptr thePoint)
513 {
514   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
515
516   //Set a not done flag
517   GetOperations()->SetNotDone(); 
518
519   if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
520
521   //check if the object is a subshape
522   if(!theObject->IsMainShape()) {
523     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
524     return aGEOMObject._retn();
525   }
526
527   //Get the object itself
528   Handle(GEOM_Object) anObject =
529     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
530   if (anObject.IsNull()) return aGEOMObject._retn();
531
532   //Get the point
533   Handle(GEOM_Object) aPoint =
534     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
535   if (aPoint.IsNull()) return aGEOMObject._retn();
536
537   //Perform the mirror
538   GetOperations()->MirrorPoint(anObject, aPoint);   
539
540   return aGEOMObject._retn();  
541 }
542  
543 //=============================================================================
544 /*!
545  *  MirrorPointCopy
546  */
547 //============================================================================= 
548 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
549                                             (GEOM::GEOM_Object_ptr theObject,
550                                              GEOM::GEOM_Object_ptr thePoint)
551 {
552   GEOM::GEOM_Object_var aGEOMObject;
553
554   //Set a not done flag
555   GetOperations()->SetNotDone(); 
556
557   if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
558
559   //Get the object itself
560   Handle(GEOM_Object) aBasicObject =
561     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
562   if (aBasicObject.IsNull()) return aGEOMObject._retn();
563
564   //Get the vector of translation
565   Handle(GEOM_Object) aPoint =
566     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
567   if (aPoint.IsNull()) return aGEOMObject._retn();
568   
569   //Perform the mirror
570   Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);   
571   if (!GetOperations()->IsDone() || anObject.IsNull())
572     return aGEOMObject._retn();
573
574   return GetObject(anObject);  
575 }
576
577
578 //=============================================================================
579 /*!
580  *  OffsetShape
581  */
582 //============================================================================= 
583 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
584                                              (GEOM::GEOM_Object_ptr theObject,
585                                               CORBA::Double theOffset)
586 {
587   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
588
589   //Set a not done flag
590   GetOperations()->SetNotDone();
591
592   if (theObject == NULL) return aGEOMObject._retn();
593
594   //check if the object is a subshape
595   if(!theObject->IsMainShape()) {
596     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
597     return aGEOMObject._retn();
598   }
599
600
601   //Get the basic object
602   Handle(GEOM_Object) aBasicObject =
603     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
604   if (aBasicObject.IsNull()) return aGEOMObject._retn();
605
606   //Create the offset shape
607   GetOperations()->OffsetShape(aBasicObject, theOffset);
608
609   return aGEOMObject._retn();
610 }
611
612 //=============================================================================
613 /*!
614  *  OffsetShapeCopy
615  */
616 //============================================================================= 
617 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
618                                              (GEOM::GEOM_Object_ptr theObject,
619                                               CORBA::Double theOffset)
620 {
621   GEOM::GEOM_Object_var aGEOMObject;
622
623   //Set a not done flag
624   GetOperations()->SetNotDone();
625
626   if (theObject == NULL) return aGEOMObject._retn();
627
628   //Get the basic object
629   Handle(GEOM_Object) aBasicObject =
630     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
631   if (aBasicObject.IsNull()) return aGEOMObject._retn();
632
633   //Create the offset shape
634   Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
635   if (!GetOperations()->IsDone() || anObject.IsNull())
636     return aGEOMObject._retn();
637
638   return GetObject(anObject);
639 }
640
641
642 //=============================================================================
643 /*!
644  *  ScaleShape
645  */
646 //============================================================================= 
647 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
648                                              (GEOM::GEOM_Object_ptr theObject,
649                                               GEOM::GEOM_Object_ptr thePoint,
650                                               CORBA::Double theFactor)
651 {
652   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
653
654   //Set a not done flag
655   GetOperations()->SetNotDone();
656
657   if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
658
659   //check if the object is a subshape
660   if(!theObject->IsMainShape()) {
661     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
662     return aGEOMObject._retn();
663   }
664
665   //Get the object itself
666   Handle(GEOM_Object) anObject =
667     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
668   if (anObject.IsNull()) return aGEOMObject._retn();
669
670   //Get the point
671   Handle(GEOM_Object) aPoint =
672     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
673   if (aPoint.IsNull()) return aGEOMObject._retn();
674
675   //Perform the scale
676   GetOperations()->ScaleShape(anObject, aPoint, theFactor);
677
678   return  aGEOMObject._retn();
679 }
680
681 //=============================================================================
682 /*!
683  *  ScaleShapeCopy
684  */
685 //============================================================================= 
686 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
687                                              (GEOM::GEOM_Object_ptr theObject,
688                                               GEOM::GEOM_Object_ptr thePoint,
689                                               CORBA::Double theFactor)
690 {
691   GEOM::GEOM_Object_var aGEOMObject;
692
693   //Set a not done flag
694   GetOperations()->SetNotDone();
695
696   if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
697
698   //Get the basic object
699   Handle(GEOM_Object) aBasicObject =
700     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
701   if (aBasicObject.IsNull()) return aGEOMObject._retn();
702
703   //Get the point
704   Handle(GEOM_Object) aPoint =
705     GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
706   if (aPoint.IsNull()) return aGEOMObject._retn();
707
708   //Perform the scale
709   Handle(GEOM_Object) anObject =
710     GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
711   if (!GetOperations()->IsDone() || anObject.IsNull())
712     return aGEOMObject._retn();
713
714   return GetObject(anObject);
715 }
716
717 //=============================================================================
718 /*!
719  *  PositionShape
720  */
721 //============================================================================= 
722 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
723                                              (GEOM::GEOM_Object_ptr theObject,
724                                               GEOM::GEOM_Object_ptr theStartLCS,
725                                               GEOM::GEOM_Object_ptr theEndLCS)
726 {
727   GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
728
729   //Set a not done flag
730   GetOperations()->SetNotDone();
731
732   if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL)
733     return aGEOMObject._retn();
734
735   //check if the object is a subshape
736   if(!theObject->IsMainShape()) {
737     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
738     return aGEOMObject._retn();
739   }
740
741   //Get the basic object
742   Handle(GEOM_Object) anObject =
743     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
744   if (anObject.IsNull()) return aGEOMObject._retn();
745
746   //Get the Start LCS
747   Handle(GEOM_Object) aStartLCS =
748     GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
749   if (aStartLCS.IsNull()) return aGEOMObject._retn();
750
751   //Get the End LCS
752   Handle(GEOM_Object) aEndLCS =
753     GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
754   if (aEndLCS.IsNull()) return aGEOMObject._retn();
755
756   //Perform the Position
757   GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
758
759   return  aGEOMObject._retn();
760 }
761
762 //=============================================================================
763 /*!
764  *  PositionShapeCopy
765  */
766 //============================================================================= 
767 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
768                                              (GEOM::GEOM_Object_ptr theObject,
769                                               GEOM::GEOM_Object_ptr theStartLCS,
770                                               GEOM::GEOM_Object_ptr theEndLCS)
771 {
772   GEOM::GEOM_Object_var aGEOMObject;
773
774   //Set a not done flag
775   GetOperations()->SetNotDone();
776
777   if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL)
778     return aGEOMObject._retn();
779
780   //Get the basic object
781   Handle(GEOM_Object) aBasicObject =
782     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
783   if (aBasicObject.IsNull()) return aGEOMObject._retn();
784
785   //Get the Start LCS
786   Handle(GEOM_Object) aStartLCS =
787     GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
788   if (aStartLCS.IsNull()) return aGEOMObject._retn();
789
790   //Get the End LCS
791   Handle(GEOM_Object) aEndLCS =
792     GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
793   if (aEndLCS.IsNull()) return aGEOMObject._retn();
794
795   //Perform the position
796   Handle(GEOM_Object) anObject =
797     GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
798   if (!GetOperations()->IsDone() || anObject.IsNull())
799     return aGEOMObject._retn();
800
801   return GetObject(anObject);
802 }
803
804 //=============================================================================
805 /*!
806  *  MultiTranslate1D
807  */
808 //============================================================================= 
809 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
810                            (GEOM::GEOM_Object_ptr theObject,
811                             GEOM::GEOM_Object_ptr theVector,
812                             CORBA::Double theStep, CORBA::Long theNbTimes)
813 {
814   //Set a not done flag
815   GetOperations()->SetNotDone(); 
816
817   GEOM::GEOM_Object_var aGEOMObject;
818
819   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
820
821   //Get the object itself
822   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
823     (theObject->GetStudyID(), theObject->GetEntry());
824   if (aBasicObject.IsNull()) return aGEOMObject._retn();
825
826   //Get the vector of translation
827   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
828     (theVector->GetStudyID(), theVector->GetEntry());
829   if (aVector.IsNull()) return aGEOMObject._retn();
830
831   //Perform the translation
832   Handle(GEOM_Object) anObject =
833     GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);   
834   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
835
836   return GetObject(anObject); 
837 }
838
839 //=============================================================================
840 /*!
841  *  MultiTranslate2D
842  */
843 //============================================================================= 
844 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, 
845                                                                      GEOM::GEOM_Object_ptr theVector1, 
846                                                                      CORBA::Double theStep1, 
847                                                                      CORBA::Long theNbTimes1,
848                                                                      GEOM::GEOM_Object_ptr theVector2, 
849                                                                      CORBA::Double theStep2, 
850                                                                      CORBA::Long theNbTimes2)
851 {
852   //Set a not done flag
853   GetOperations()->SetNotDone(); 
854
855   GEOM::GEOM_Object_var aGEOMObject;
856
857   if (theObject == NULL || theVector1 == NULL || theVector2 == NULL) return aGEOMObject._retn();
858
859   //Get the object itself
860   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
861     (theObject->GetStudyID(), theObject->GetEntry());
862   if (aBasicObject.IsNull()) return aGEOMObject._retn();
863
864   //Get the vector1 of translation
865   Handle(GEOM_Object) aVector1 = GetOperations()->GetEngine()->GetObject
866     (theVector1->GetStudyID(), theVector1->GetEntry());
867   if (aVector1.IsNull()) return aGEOMObject._retn();
868
869   //Get the vector2 of translation
870   Handle(GEOM_Object) aVector2 = GetOperations()->GetEngine()->GetObject
871     (theVector2->GetStudyID(), theVector2->GetEntry());
872   if (aVector2.IsNull()) return aGEOMObject._retn();
873
874   //Perform the translation
875   Handle(GEOM_Object) anObject = GetOperations()->Translate2D
876     (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);   
877   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
878
879   return GetObject(anObject); 
880 }
881
882 //=============================================================================
883 /*!
884  *  MultiRotate1D
885  */
886 //============================================================================= 
887 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
888                                                                   GEOM::GEOM_Object_ptr theVector,
889                                                                   CORBA::Long theNbTimes)
890 {
891   //Set a not done flag
892   GetOperations()->SetNotDone(); 
893
894   GEOM::GEOM_Object_var aGEOMObject;
895
896   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
897
898   //Get the object itself
899   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
900     (theObject->GetStudyID(), theObject->GetEntry());
901   if (aBasicObject.IsNull()) return aGEOMObject._retn();
902
903   //Get the a directon of rotation
904   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
905     (theVector->GetStudyID(), theVector->GetEntry());
906   if (aVector.IsNull()) return aGEOMObject._retn();
907
908   //Perform the rotation
909   Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);   
910   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
911
912   return GetObject(anObject);  
913 }
914
915 //=============================================================================
916 /*!
917  *  MultiRotate2D
918  */
919 //============================================================================= 
920 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
921                                                                   GEOM::GEOM_Object_ptr theVector,
922                                                                   CORBA::Double theAngle, 
923                                                                   CORBA::Long theNbTimes1, 
924                                                                   CORBA::Double theStep, 
925                                                                   CORBA::Long theNbTimes2)
926 {
927   //Set a not done flag
928   GetOperations()->SetNotDone(); 
929
930   GEOM::GEOM_Object_var aGEOMObject;
931
932   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
933
934   //Get the object itself
935   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
936     (theObject->GetStudyID(), theObject->GetEntry());
937   if (aBasicObject.IsNull()) return aGEOMObject._retn();
938
939   //Get the a directon of rotation
940   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
941     (theVector->GetStudyID(), theVector->GetEntry());
942   if (aVector.IsNull()) return aGEOMObject._retn();
943
944   //Perform the rotation
945   Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
946     (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);   
947   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
948
949   return GetObject(anObject);  
950 }