Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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 || 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 (may be NULL for positioning from global LCS)
747   Handle(GEOM_Object) aStartLCS = NULL;
748   if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) {
749     aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
750     if (aStartLCS.IsNull()) return aGEOMObject._retn();
751   }
752
753   //Get the End LCS
754   Handle(GEOM_Object) aEndLCS =
755     GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
756   if (aEndLCS.IsNull()) return aGEOMObject._retn();
757
758   //Perform the Position
759   GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
760
761   return  aGEOMObject._retn();
762 }
763
764 //=============================================================================
765 /*!
766  *  PositionShapeCopy
767  */
768 //=============================================================================
769 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
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;
775
776   //Set a not done flag
777   GetOperations()->SetNotDone();
778
779   if (theObject == NULL || theEndLCS == NULL)
780     return aGEOMObject._retn();
781
782   //Get the basic object
783   Handle(GEOM_Object) aBasicObject =
784     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
785   if (aBasicObject.IsNull()) return aGEOMObject._retn();
786
787   //Get the Start LCS (may be NULL for positioning from global LCS)
788   Handle(GEOM_Object) aStartLCS = NULL;
789   if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) {
790     aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
791     if (aStartLCS.IsNull()) return aGEOMObject._retn();
792   }
793
794   //Get the End LCS
795   Handle(GEOM_Object) aEndLCS =
796     GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
797   if (aEndLCS.IsNull()) return aGEOMObject._retn();
798
799   //Perform the position
800   Handle(GEOM_Object) anObject =
801     GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
802   if (!GetOperations()->IsDone() || anObject.IsNull())
803     return aGEOMObject._retn();
804
805   return GetObject(anObject);
806 }
807
808 //=============================================================================
809 /*!
810  *  MultiTranslate1D
811  */
812 //=============================================================================
813 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
814                            (GEOM::GEOM_Object_ptr theObject,
815                             GEOM::GEOM_Object_ptr theVector,
816                             CORBA::Double theStep, CORBA::Long theNbTimes)
817 {
818   //Set a not done flag
819   GetOperations()->SetNotDone();
820
821   GEOM::GEOM_Object_var aGEOMObject;
822
823   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
824
825   //Get the object itself
826   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
827     (theObject->GetStudyID(), theObject->GetEntry());
828   if (aBasicObject.IsNull()) return aGEOMObject._retn();
829
830   //Get the vector of translation
831   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
832     (theVector->GetStudyID(), theVector->GetEntry());
833   if (aVector.IsNull()) return aGEOMObject._retn();
834
835   //Perform the translation
836   Handle(GEOM_Object) anObject =
837     GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
838   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
839
840   return GetObject(anObject);
841 }
842
843 //=============================================================================
844 /*!
845  *  MultiTranslate2D
846  */
847 //=============================================================================
848 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
849                                                                      GEOM::GEOM_Object_ptr theVector1,
850                                                                      CORBA::Double theStep1,
851                                                                      CORBA::Long theNbTimes1,
852                                                                      GEOM::GEOM_Object_ptr theVector2,
853                                                                      CORBA::Double theStep2,
854                                                                      CORBA::Long theNbTimes2)
855 {
856   //Set a not done flag
857   GetOperations()->SetNotDone();
858
859   GEOM::GEOM_Object_var aGEOMObject;
860
861   if (theObject == NULL || theVector1 == NULL || theVector2 == NULL) return aGEOMObject._retn();
862
863   //Get the object itself
864   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
865     (theObject->GetStudyID(), theObject->GetEntry());
866   if (aBasicObject.IsNull()) return aGEOMObject._retn();
867
868   //Get the vector1 of translation
869   Handle(GEOM_Object) aVector1 = GetOperations()->GetEngine()->GetObject
870     (theVector1->GetStudyID(), theVector1->GetEntry());
871   if (aVector1.IsNull()) return aGEOMObject._retn();
872
873   //Get the vector2 of translation
874   Handle(GEOM_Object) aVector2 = GetOperations()->GetEngine()->GetObject
875     (theVector2->GetStudyID(), theVector2->GetEntry());
876   if (aVector2.IsNull()) return aGEOMObject._retn();
877
878   //Perform the translation
879   Handle(GEOM_Object) anObject = GetOperations()->Translate2D
880     (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
881   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
882
883   return GetObject(anObject);
884 }
885
886 //=============================================================================
887 /*!
888  *  MultiRotate1D
889  */
890 //=============================================================================
891 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
892                                                                   GEOM::GEOM_Object_ptr theVector,
893                                                                   CORBA::Long theNbTimes)
894 {
895   //Set a not done flag
896   GetOperations()->SetNotDone();
897
898   GEOM::GEOM_Object_var aGEOMObject;
899
900   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
901
902   //Get the object itself
903   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
904     (theObject->GetStudyID(), theObject->GetEntry());
905   if (aBasicObject.IsNull()) return aGEOMObject._retn();
906
907   //Get the a directon of rotation
908   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
909     (theVector->GetStudyID(), theVector->GetEntry());
910   if (aVector.IsNull()) return aGEOMObject._retn();
911
912   //Perform the rotation
913   Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
914   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
915
916   return GetObject(anObject);
917 }
918
919 //=============================================================================
920 /*!
921  *  MultiRotate2D
922  */
923 //=============================================================================
924 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
925                                                                   GEOM::GEOM_Object_ptr theVector,
926                                                                   CORBA::Double theAngle,
927                                                                   CORBA::Long theNbTimes1,
928                                                                   CORBA::Double theStep,
929                                                                   CORBA::Long theNbTimes2)
930 {
931   //Set a not done flag
932   GetOperations()->SetNotDone();
933
934   GEOM::GEOM_Object_var aGEOMObject;
935
936   if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
937
938   //Get the object itself
939   Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
940     (theObject->GetStudyID(), theObject->GetEntry());
941   if (aBasicObject.IsNull()) return aGEOMObject._retn();
942
943   //Get the a directon of rotation
944   Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
945     (theVector->GetStudyID(), theVector->GetEntry());
946   if (aVector.IsNull()) return aGEOMObject._retn();
947
948   //Perform the rotation
949   Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
950     (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
951   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
952
953   return GetObject(anObject);
954 }
955
956 //=============================================================================
957 /*!
958  *  RotateThreePoints
959  */
960 //=============================================================================
961 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
962                                              (GEOM::GEOM_Object_ptr theObject,
963                                               GEOM::GEOM_Object_ptr theCentPoint,
964                                               GEOM::GEOM_Object_ptr thePoint1,
965                                               GEOM::GEOM_Object_ptr thePoint2)
966 {
967   //Set a not done flag
968   GetOperations()->SetNotDone();
969   GEOM::GEOM_Object_var aGEOMObject;
970
971   if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
972
973   //check if the object is a subshape
974   if(!theObject->IsMainShape()) {
975     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
976     return aGEOMObject._retn();
977   }
978
979   aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
980
981   //Get the object itself
982   Handle(GEOM_Object) anObject =
983     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
984   if (anObject.IsNull()) return aGEOMObject._retn();
985
986   //Get the central point of rotation
987   Handle(GEOM_Object) aCentPoint =
988     GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
989   if (aCentPoint.IsNull()) return aGEOMObject._retn();
990
991   //Get the first point
992   Handle(GEOM_Object) aPoint1 =
993     GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
994   if (aPoint1.IsNull()) return aGEOMObject._retn();
995
996   //Get the second point
997   Handle(GEOM_Object) aPoint2 =
998     GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
999   if (aPoint2.IsNull()) return aGEOMObject._retn();
1000
1001   //Perform the translation
1002   GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1003
1004   return aGEOMObject._retn();
1005 }
1006
1007 //=============================================================================
1008 /*!
1009  *  RotateThreePointsCopy
1010  */
1011 //=============================================================================
1012 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1013                                              (GEOM::GEOM_Object_ptr theObject,
1014                                               GEOM::GEOM_Object_ptr theCentPoint,
1015                                               GEOM::GEOM_Object_ptr thePoint1,
1016                                               GEOM::GEOM_Object_ptr thePoint2)
1017 {
1018   GEOM::GEOM_Object_var aGEOMObject;
1019
1020   //Set a not done flag
1021   GetOperations()->SetNotDone();
1022
1023   if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
1024
1025   //Get the object itself
1026   Handle(GEOM_Object) aBasicObject =
1027     GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1028   if (aBasicObject.IsNull()) return aGEOMObject._retn();
1029
1030   //Get the central point of rotation
1031   Handle(GEOM_Object) aCentPoint =
1032     GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
1033   if (aCentPoint.IsNull()) return aGEOMObject._retn();
1034
1035   //Get the first point
1036   Handle(GEOM_Object) aPoint1 =
1037     GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
1038   if (aPoint1.IsNull()) return aGEOMObject._retn();
1039
1040   //Get the second point
1041   Handle(GEOM_Object) aPoint2 =
1042     GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
1043   if (aPoint2.IsNull()) return aGEOMObject._retn();
1044
1045   //Perform the rotation
1046   Handle(GEOM_Object) anObject =
1047     GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1048   if (!GetOperations()->IsDone() || anObject.IsNull())
1049     return aGEOMObject._retn();
1050
1051   return GetObject(anObject);
1052 }
1053