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