Salome HOME
PAL17233: Projection 2D doesn't work (bis)
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ITransformOperations.cxx
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 <GEOMImpl_ITransformOperations.hxx>
23
24 #include "utilities.h"
25 #include <OpUtil.hxx>
26 #include <Utils_ExceptHandlers.hxx>
27
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
32
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
35
36 #include <GEOMImpl_TranslateDriver.hxx>
37 #include <GEOMImpl_MirrorDriver.hxx>
38 #include <GEOMImpl_OffsetDriver.hxx>
39 #include <GEOMImpl_ScaleDriver.hxx>
40 #include <GEOMImpl_RotateDriver.hxx>
41 #include <GEOMImpl_PositionDriver.hxx>
42
43 #include <GEOMImpl_ITranslate.hxx>
44 #include <GEOMImpl_IMirror.hxx>
45 #include <GEOMImpl_IOffset.hxx>
46 #include <GEOMImpl_IScale.hxx>
47 #include <GEOMImpl_IRotate.hxx>
48 #include <GEOMImpl_IPosition.hxx>
49
50 #include <GEOMImpl_Types.hxx>
51
52 #include <Standard_Failure.hxx>
53 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
54
55 //=============================================================================
56 /*!
57  *   constructor:
58  */
59 //=============================================================================
60
61 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
62 : GEOM_IOperations(theEngine, theDocID)
63 {
64   MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
65 }
66
67 //=============================================================================
68 /*!
69  *  destructor
70  */
71 //=============================================================================
72
73 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
74 {
75   MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
76 }
77
78
79 //=============================================================================
80 /*!
81  *  TranslateTwoPoints
82  */
83 //=============================================================================
84 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
85        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
86 {
87   SetErrorCode(KO);
88
89   if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
90
91   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
92   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
93
94   // Get last functions of the arguments
95   Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
96   Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
97
98   //Add a translate function
99   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
100
101   if (aFunction.IsNull()) return NULL;
102
103   //Check if the function is set correctly
104   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
105
106   GEOMImpl_ITranslate aTI (aFunction);
107   aTI.SetPoint1(aP1F);
108   aTI.SetPoint2(aP2F);
109   aTI.SetOriginal(aLastFunction);
110
111   //Compute the translation
112   try {
113 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
114     OCC_CATCH_SIGNALS;
115 #endif
116     if (!GetSolver()->ComputeFunction(aFunction)) {
117       SetErrorCode("Translation driver failed");
118       return NULL;
119     }
120   }
121   catch (Standard_Failure) {
122     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
123     SetErrorCode(aFail->GetMessageString());
124     return NULL;
125   }
126
127   //Make a Python command
128   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
129     << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
130
131   SetErrorCode(OK);
132   return theObject;
133 }
134
135 //=============================================================================
136 /*!
137  *  TranslateDXDYDZ
138  */
139 //=============================================================================
140 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
141        (Handle(GEOM_Object) theObject, double theX, double theY,  double theZ)
142 {
143   SetErrorCode(KO);
144
145   if (theObject.IsNull()) return NULL;
146
147   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
148   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
149
150   //Add a translate function
151   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
152
153   if (aFunction.IsNull()) return NULL;
154
155   //Check if the function is set correctly
156   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
157
158   GEOMImpl_ITranslate aTI(aFunction);
159   aTI.SetDX(theX);
160   aTI.SetDY(theY);
161   aTI.SetDZ(theZ);
162   aTI.SetOriginal(aLastFunction);
163
164   //Compute the translation
165   try {
166 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
167     OCC_CATCH_SIGNALS;
168 #endif
169     if (!GetSolver()->ComputeFunction(aFunction)) {
170       SetErrorCode("Translation driver failed");
171       return NULL;
172     }
173   }
174   catch (Standard_Failure) {
175     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
176     SetErrorCode(aFail->GetMessageString());
177     return NULL;
178   }
179
180   //Make a Python command
181   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateDXDYDZ("
182     << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
183
184   SetErrorCode(OK);
185   return theObject;
186 }
187
188
189 //=============================================================================
190 /*!
191  *  TranslateTwoPointsCopy
192  */
193 //=============================================================================
194 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
195        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
196 {
197   SetErrorCode(KO);
198
199   if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
200
201   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
202   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
203
204   //Add a new Copy object
205   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
206
207   //Add a translate function
208   Handle(GEOM_Function) aFunction =
209     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
210
211   //Check if the function is set correctly
212   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
213
214   GEOMImpl_ITranslate aTI(aFunction);
215   aTI.SetPoint1(thePoint1->GetLastFunction());
216   aTI.SetPoint2(thePoint2->GetLastFunction());
217   //aTI.SetShape(theObject->GetValue());
218   aTI.SetOriginal(aLastFunction);
219
220   //Compute the translation
221   try {
222 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
223     OCC_CATCH_SIGNALS;
224 #endif
225     if (!GetSolver()->ComputeFunction(aFunction)) {
226       SetErrorCode("Translation driver failed");
227       return NULL;
228     }
229   }
230   catch (Standard_Failure) {
231     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
232     SetErrorCode(aFail->GetMessageString());
233     return NULL;
234   }
235
236   //Make a Python command
237   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
238     << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
239
240   SetErrorCode(OK);
241   return aCopy;
242 }
243
244 //=============================================================================
245 /*!
246  *  TranslateDXDYDZCopy
247  */
248 //=============================================================================
249 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
250        (Handle(GEOM_Object) theObject, double theX, double theY,  double theZ)
251 {
252   SetErrorCode(KO);
253
254   if (theObject.IsNull()) return NULL;
255
256   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
257   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
258
259   //Add a new Copy object
260   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
261
262   //Add a translate function
263   Handle(GEOM_Function) aFunction =
264     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
265
266   //Check if the function is set correctly
267   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
268
269   GEOMImpl_ITranslate aTI(aFunction);
270   aTI.SetDX(theX);
271   aTI.SetDY(theY);
272   aTI.SetDZ(theZ);
273   aTI.SetOriginal(aLastFunction);
274
275   //Compute the translation
276   try {
277 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
278     OCC_CATCH_SIGNALS;
279 #endif
280     if (!GetSolver()->ComputeFunction(aFunction)) {
281       SetErrorCode("Translation driver failed");
282       return NULL;
283     }
284   }
285   catch (Standard_Failure) {
286     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
287     SetErrorCode(aFail->GetMessageString());
288     return NULL;
289   }
290
291   //Make a Python command
292   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
293     << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
294
295   SetErrorCode(OK);
296   return aCopy;
297 }
298
299
300 //=============================================================================
301 /*!
302  *  TranslateVector
303  */
304 //=============================================================================
305 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
306        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
307 {
308   SetErrorCode(KO);
309
310   if (theObject.IsNull() || theVector.IsNull()) return NULL;
311
312   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
313   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
314
315   // Get last functions of the arguments
316   Handle(GEOM_Function) aVF = theVector->GetLastFunction();
317
318   //Add a translate function
319   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
320
321   if (aFunction.IsNull()) return NULL;
322
323   //Check if the function is set correctly
324   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
325
326   GEOMImpl_ITranslate aTI (aFunction);
327   aTI.SetVector(aVF);
328   aTI.SetOriginal(aLastFunction);
329
330   //Compute the translation
331   try {
332 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
333     OCC_CATCH_SIGNALS;
334 #endif
335     if (!GetSolver()->ComputeFunction(aFunction)) {
336       SetErrorCode("Translation driver failed");
337       return NULL;
338     }
339   }
340   catch (Standard_Failure) {
341     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
342     SetErrorCode(aFail->GetMessageString());
343     return NULL;
344   }
345
346   //Make a Python command
347   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
348                                << theObject << ", " << theVector << ")";
349
350   SetErrorCode(OK);
351   return theObject;
352 }
353
354 //=============================================================================
355 /*!
356  *  TranslateVectorCopy
357  */
358 //=============================================================================
359 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
360        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
361 {
362   SetErrorCode(KO);
363
364   if (theObject.IsNull() || theVector.IsNull()) return NULL;
365
366   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
367   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
368
369   //Add a new Copy object
370   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
371
372   //Add a translate function
373   Handle(GEOM_Function) aFunction =
374     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
375
376   //Check if the function is set correctly
377   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
378
379   GEOMImpl_ITranslate aTI(aFunction);
380   aTI.SetVector(theVector->GetLastFunction());
381 //  aTI.SetShape(theObject->GetValue());
382   aTI.SetOriginal(aLastFunction);
383
384   //Compute the translation
385   try {
386 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
387     OCC_CATCH_SIGNALS;
388 #endif
389     if (!GetSolver()->ComputeFunction(aFunction)) {
390       SetErrorCode("Translation driver failed");
391       return NULL;
392     }
393   }
394   catch (Standard_Failure) {
395     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
396     SetErrorCode(aFail->GetMessageString());
397     return NULL;
398   }
399
400   //Make a Python command
401   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
402                                << theObject << ", " << theVector << ")";
403
404   SetErrorCode(OK);
405   return aCopy;
406 }
407
408 //=============================================================================
409 /*!
410  *  Translate1D
411  */
412 //=============================================================================
413 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
414        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
415         double theStep, Standard_Integer theNbTimes)
416 {
417   SetErrorCode(KO);
418
419   if (theObject.IsNull() || theVector.IsNull()) return NULL;
420
421   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
422   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
423
424   //Add a new Copy object
425   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
426
427   //Add a translate function
428   Handle(GEOM_Function) aFunction =
429     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
430
431   //Check if the function is set correctly
432   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
433
434   GEOMImpl_ITranslate aTI(aFunction);
435   aTI.SetVector(theVector->GetLastFunction());
436   aTI.SetOriginal(aLastFunction);
437   aTI.SetStep1(theStep);
438   aTI.SetNbIter1(theNbTimes);
439
440   //Compute the translation
441   try {
442 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
443     OCC_CATCH_SIGNALS;
444 #endif
445     if (!GetSolver()->ComputeFunction(aFunction)) {
446       SetErrorCode("Translation driver failed");
447       return NULL;
448     }
449   }
450   catch (Standard_Failure) {
451     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
452     SetErrorCode(aFail->GetMessageString());
453     return NULL;
454   }
455
456   //Make a Python command
457   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
458     << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
459
460   SetErrorCode(OK);
461   return aCopy;
462 }
463
464 //=============================================================================
465 /*!
466  *  Translate2D
467  */
468 //=============================================================================
469 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
470                                                                 Handle(GEOM_Object) theVector,
471                                                                 double theStep1,
472                                                                 Standard_Integer theNbTimes1,
473                                                                 Handle(GEOM_Object) theVector2,
474                                                                 double theStep2,
475                                                                 Standard_Integer theNbTimes2)
476 {
477   SetErrorCode(KO);
478
479   if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
480
481   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
482   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
483
484   //Add a new Copy object
485   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
486
487   //Add a translate function
488   Handle(GEOM_Function) aFunction =
489     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
490
491   //Check if the function is set correctly
492   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
493
494   GEOMImpl_ITranslate aTI(aFunction);
495   aTI.SetVector(theVector->GetLastFunction());
496   aTI.SetVector2(theVector2->GetLastFunction());
497   aTI.SetOriginal(aLastFunction);
498   aTI.SetStep1(theStep1);
499   aTI.SetNbIter1(theNbTimes1);
500   aTI.SetStep2(theStep2);
501   aTI.SetNbIter2(theNbTimes2);
502
503   //Compute the translation
504   try {
505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
506     OCC_CATCH_SIGNALS;
507 #endif
508     if (!GetSolver()->ComputeFunction(aFunction)) {
509       SetErrorCode("Translation driver failed");
510       return NULL;
511     }
512   }
513   catch (Standard_Failure) {
514     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
515     SetErrorCode(aFail->GetMessageString());
516     return NULL;
517   }
518
519   //Make a Python command
520   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
521     << theObject << ", " << theVector  << ", " << theStep1 << ", " << theNbTimes1
522       << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
523
524   SetErrorCode(OK);
525   return aCopy;
526 }
527
528
529 //=============================================================================
530 /*!
531  *  MirrorPlane
532  */
533 //=============================================================================
534 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
535        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
536 {
537   SetErrorCode(KO);
538
539   if (theObject.IsNull() || thePlane.IsNull()) return NULL;
540
541   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
542   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
543
544   // Get last functions of the arguments
545   Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
546
547   //Add a mirror function
548   Handle(GEOM_Function) aFunction =
549     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
550   if (aFunction.IsNull()) return NULL;
551
552   //Check if the function is set correctly
553   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
554
555   GEOMImpl_IMirror aTI (aFunction);
556   aTI.SetPlane(aPF);
557   aTI.SetOriginal(aLastFunction);
558
559   //Compute the mirror
560   try {
561 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
562     OCC_CATCH_SIGNALS;
563 #endif
564     if (!GetSolver()->ComputeFunction(aFunction)) {
565       SetErrorCode("Mirror driver failed");
566       return NULL;
567     }
568   }
569   catch (Standard_Failure) {
570     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
571     SetErrorCode(aFail->GetMessageString());
572     return NULL;
573   }
574
575   //Make a Python command
576   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
577                                << theObject << ", " << thePlane << ")";
578
579   SetErrorCode(OK);
580   return theObject;
581 }
582
583 //=============================================================================
584 /*!
585  *  MirrorPlaneCopy
586  */
587 //=============================================================================
588 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
589        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
590 {
591   SetErrorCode(KO);
592
593   if (theObject.IsNull() || thePlane.IsNull()) return NULL;
594
595   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
596   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
597
598   //Add a new Copy object
599   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
600
601   //Add a mirror function
602   Handle(GEOM_Function) aFunction =
603     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
604
605   //Check if the function is set correctly
606   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
607
608   GEOMImpl_IMirror aTI (aFunction);
609   aTI.SetPlane(thePlane->GetLastFunction());
610   aTI.SetOriginal(aLastFunction);
611
612   //Compute the mirror
613   try {
614 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
615     OCC_CATCH_SIGNALS;
616 #endif
617     if (!GetSolver()->ComputeFunction(aFunction)) {
618       SetErrorCode("Mirror driver failed");
619       return NULL;
620     }
621   }
622   catch (Standard_Failure) {
623     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
624     SetErrorCode(aFail->GetMessageString());
625     return NULL;
626   }
627
628   //Make a Python command
629   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
630                                << theObject << ", " << thePlane << ")";
631
632   SetErrorCode(OK);
633   return aCopy;
634 }
635
636 //=============================================================================
637 /*!
638  *  MirrorPoint
639  */
640 //=============================================================================
641 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
642        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
643 {
644   SetErrorCode(KO);
645
646   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
647
648   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
649   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
650
651   // Get last functions of the arguments
652   Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
653
654   //Add a mirror function
655   Handle(GEOM_Function) aFunction =
656     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
657   if (aFunction.IsNull()) return NULL;
658
659   //Check if the function is set correctly
660   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
661
662   GEOMImpl_IMirror aTI (aFunction);
663   aTI.SetPoint(aPF);
664   aTI.SetOriginal(aLastFunction);
665
666   //Compute the mirror
667   try {
668 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
669     OCC_CATCH_SIGNALS;
670 #endif
671     if (!GetSolver()->ComputeFunction(aFunction)) {
672       SetErrorCode("Mirror driver failed");
673       return NULL;
674     }
675   }
676   catch (Standard_Failure) {
677     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
678     SetErrorCode(aFail->GetMessageString());
679     return NULL;
680   }
681
682   //Make a Python command
683   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
684                                << theObject << ", " << thePoint << ")";
685
686   SetErrorCode(OK);
687   return NULL;
688 }
689
690 //=============================================================================
691 /*!
692  *  MirrorPointCopy
693  */
694 //=============================================================================
695 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
696        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
697 {
698   SetErrorCode(KO);
699
700   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
701
702   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
703   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
704
705   //Add a new Copy object
706   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
707
708   //Add a mirror function
709   Handle(GEOM_Function) aFunction =
710     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
711
712   //Check if the function is set correctly
713   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
714
715   GEOMImpl_IMirror aTI (aFunction);
716   aTI.SetPoint(thePoint->GetLastFunction());
717   aTI.SetOriginal(aLastFunction);
718
719   //Compute the mirror
720   try {
721 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
722     OCC_CATCH_SIGNALS;
723 #endif
724     if (!GetSolver()->ComputeFunction(aFunction)) {
725       SetErrorCode("Mirror driver failed");
726       return NULL;
727     }
728   }
729   catch (Standard_Failure) {
730     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
731     SetErrorCode(aFail->GetMessageString());
732     return NULL;
733   }
734
735   //Make a Python command
736   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
737                                << theObject << ", " << thePoint << ")";
738
739   SetErrorCode(OK);
740   return aCopy;
741 }
742
743 //=============================================================================
744 /*!
745  *  MirrorAxis
746  */
747 //=============================================================================
748 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
749        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
750 {
751   SetErrorCode(KO);
752
753   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
754
755   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
756   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
757
758   // Get last functions of the arguments
759   Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
760
761   //Add a mirror function
762   Handle(GEOM_Function) aFunction =
763     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
764   if (aFunction.IsNull()) return NULL;
765
766   //Check if the function is set correctly
767   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
768
769   GEOMImpl_IMirror aTI (aFunction);
770   aTI.SetAxis(anAF);
771   aTI.SetOriginal(aLastFunction);
772
773   //Compute the mirror
774   try {
775 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
776     OCC_CATCH_SIGNALS;
777 #endif
778     if (!GetSolver()->ComputeFunction(aFunction)) {
779       SetErrorCode("Mirror driver failed");
780       return NULL;
781     }
782   }
783   catch (Standard_Failure) {
784     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
785     SetErrorCode(aFail->GetMessageString());
786     return NULL;
787   }
788
789   //Make a Python command
790   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
791                                << theObject << ", " << theAxis << ")";
792
793   SetErrorCode(OK);
794   return NULL;
795 }
796
797 //=============================================================================
798 /*!
799  *  MirrorAxisCopy
800  */
801 //=============================================================================
802 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
803        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
804 {
805   SetErrorCode(KO);
806
807   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
808
809   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
810   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
811
812   //Add a new Copy object
813   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
814
815   //Add a mirror function
816   Handle(GEOM_Function) aFunction =
817     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
818
819   //Check if the function is set correctly
820   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
821
822   GEOMImpl_IMirror aTI (aFunction);
823   aTI.SetAxis(theAxis->GetLastFunction());
824   aTI.SetOriginal(aLastFunction);
825
826   //Compute the mirror
827   try {
828 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
829     OCC_CATCH_SIGNALS;
830 #endif
831     if (!GetSolver()->ComputeFunction(aFunction)) {
832       SetErrorCode("Mirror driver failed");
833       return NULL;
834     }
835   }
836   catch (Standard_Failure) {
837     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
838     SetErrorCode(aFail->GetMessageString());
839     return NULL;
840   }
841
842   //Make a Python command
843   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
844                                << theObject << ", " << theAxis << ")";
845
846   SetErrorCode(OK);
847   return aCopy;
848 }
849
850
851 //=============================================================================
852 /*!
853  *  OffsetShape
854  */
855 //=============================================================================
856 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
857                               (Handle(GEOM_Object) theObject, double theOffset)
858 {
859   SetErrorCode(KO);
860
861   if (theObject.IsNull()) return NULL;
862
863   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
864   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
865
866   //Add a new Offset function
867   Handle(GEOM_Function) aFunction =
868     theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
869   if (aFunction.IsNull()) return NULL;
870
871   //Check if the function is set correctly
872   if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
873
874   GEOMImpl_IOffset aTI (aFunction);
875   aTI.SetShape(anOriginal);
876   aTI.SetValue(theOffset);
877
878   //Compute the offset
879   try {
880 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
881     OCC_CATCH_SIGNALS;
882 #endif
883     if (!GetSolver()->ComputeFunction(aFunction)) {
884       SetErrorCode("Offset driver failed");
885       return NULL;
886     }
887   }
888   catch (Standard_Failure) {
889     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
890     SetErrorCode(aFail->GetMessageString());
891     return NULL;
892   }
893
894   //Make a Python command
895   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
896                                << theObject << ", " << theOffset << ")";
897
898   SetErrorCode(OK);
899   return theObject;
900 }
901
902 //=============================================================================
903 /*!
904  *  OffsetShapeCopy
905  */
906 //=============================================================================
907 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
908                               (Handle(GEOM_Object) theObject, double theOffset)
909 {
910   SetErrorCode(KO);
911
912   if (theObject.IsNull()) return NULL;
913
914   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
915   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
916
917   //Add a new Copy object
918   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
919
920   //Add a new Offset function
921   Handle(GEOM_Function) aFunction =
922     aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
923   if (aFunction.IsNull()) return NULL;
924
925   //Check if the function is set correctly
926   if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
927
928   GEOMImpl_IOffset aTI (aFunction);
929   aTI.SetShape(anOriginal);
930   aTI.SetValue(theOffset);
931
932   //Compute the offset
933   try {
934 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
935     OCC_CATCH_SIGNALS;
936 #endif
937     if (!GetSolver()->ComputeFunction(aFunction)) {
938       SetErrorCode("Offset driver failed");
939       return NULL;
940     }
941   }
942   catch (Standard_Failure) {
943     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
944     SetErrorCode(aFail->GetMessageString());
945     return NULL;
946   }
947
948   //Make a Python command
949   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
950                                << theObject << ", " << theOffset << ")";
951
952   SetErrorCode(OK);
953   return aCopy;
954 }
955
956
957 //=============================================================================
958 /*!
959  *  ScaleShape
960  */
961 //=============================================================================
962 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
963        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
964 {
965   SetErrorCode(KO);
966
967   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
968
969   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
970   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
971
972   // Get last functions of the arguments
973   Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
974
975   //Add a scale function
976   Handle(GEOM_Function) aFunction =
977     theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
978   if (aFunction.IsNull()) return NULL;
979
980   //Check if the function is set correctly
981   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
982
983   GEOMImpl_IScale aTI (aFunction);
984   aTI.SetShape(anOriginal);
985   aTI.SetPoint(aPF);
986   aTI.SetFactor(theFactor);
987
988   //Compute the scale
989   try {
990 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
991     OCC_CATCH_SIGNALS;
992 #endif
993     if (!GetSolver()->ComputeFunction(aFunction)) {
994       SetErrorCode("Scale driver failed");
995       return NULL;
996     }
997   }
998   catch (Standard_Failure) {
999     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1000     SetErrorCode(aFail->GetMessageString());
1001     return NULL;
1002   }
1003
1004   //Make a Python command
1005   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
1006     << theObject << ", " << thePoint << ", " << theFactor << ")";
1007
1008   SetErrorCode(OK);
1009   return theObject;
1010 }
1011
1012 //=============================================================================
1013 /*!
1014  *  ScaleShapeCopy
1015  */
1016 //=============================================================================
1017 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1018        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1019 {
1020   SetErrorCode(KO);
1021
1022   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
1023
1024   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1025   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1026
1027   //Add a new Copy object
1028   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1029
1030   //Add a scale function
1031   Handle(GEOM_Function) aFunction =
1032     aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1033   if (aFunction.IsNull()) return NULL;
1034
1035   //Check if the function is set correctly
1036   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1037
1038   GEOMImpl_IScale aTI (aFunction);
1039   aTI.SetShape(anOriginal);
1040   aTI.SetPoint(thePoint->GetLastFunction());
1041   aTI.SetFactor(theFactor);
1042
1043   //Compute the scale
1044   try {
1045 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1046     OCC_CATCH_SIGNALS;
1047 #endif
1048     if (!GetSolver()->ComputeFunction(aFunction)) {
1049       SetErrorCode("Scale driver failed");
1050       return NULL;
1051     }
1052   }
1053   catch (Standard_Failure) {
1054     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1055     SetErrorCode(aFail->GetMessageString());
1056     return NULL;
1057   }
1058
1059   //Make a Python command
1060   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1061     << theObject << ", " << thePoint << ", " << theFactor << ")";
1062
1063   SetErrorCode(OK);
1064   return aCopy;
1065 }
1066
1067 //=============================================================================
1068 /*!
1069  *  PositionShape
1070  */
1071 //=============================================================================
1072 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1073         (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1074 {
1075   SetErrorCode(KO);
1076
1077   if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1078
1079   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1080   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1081
1082   //Add a Position function
1083   Standard_Integer aType = POSITION_SHAPE;
1084   if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1085
1086   Handle(GEOM_Function) aFunction =
1087     theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1088   if (aFunction.IsNull()) return NULL;
1089
1090   //Check if the function is set correctly
1091   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1092
1093   //Set operation arguments
1094   GEOMImpl_IPosition aTI (aFunction);
1095   aTI.SetShape(anOriginal);
1096   aTI.SetEndLCS(theEndLCS->GetLastFunction());
1097   if (!theStartLCS.IsNull())
1098     aTI.SetStartLCS(theStartLCS->GetLastFunction());
1099
1100   //Compute the Position
1101   try {
1102 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1103     OCC_CATCH_SIGNALS;
1104 #endif
1105     if (!GetSolver()->ComputeFunction(aFunction)) {
1106       SetErrorCode("Position driver failed");
1107       return NULL;
1108     }
1109   }
1110   catch (Standard_Failure) {
1111     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1112     SetErrorCode(aFail->GetMessageString());
1113     return NULL;
1114   }
1115
1116   //Make a Python command
1117   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1118     << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1119
1120   SetErrorCode(OK);
1121   return theObject;
1122 }
1123
1124 //=============================================================================
1125 /*!
1126  *  PositionShapeCopy
1127  */
1128 //=============================================================================
1129 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1130        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1131 {
1132   SetErrorCode(KO);
1133
1134   if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1135
1136   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1137   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1138
1139   //Add a new Copy object
1140   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1141
1142   //Add a position function
1143   Standard_Integer aType = POSITION_SHAPE_COPY;
1144   if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1145
1146   Handle(GEOM_Function) aFunction =
1147     aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1148   if (aFunction.IsNull()) return NULL;
1149
1150   //Check if the function is set correctly
1151   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1152
1153   GEOMImpl_IPosition aTI (aFunction);
1154   aTI.SetShape(anOriginal);
1155   aTI.SetEndLCS(theEndLCS->GetLastFunction());
1156   if (!theStartLCS.IsNull())
1157     aTI.SetStartLCS(theStartLCS->GetLastFunction());
1158
1159   //Compute the position
1160   try {
1161 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1162     OCC_CATCH_SIGNALS;
1163 #endif
1164     if (!GetSolver()->ComputeFunction(aFunction)) {
1165       SetErrorCode("Position driver failed");
1166       return NULL;
1167     }
1168   }
1169   catch (Standard_Failure) {
1170     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1171     SetErrorCode(aFail->GetMessageString());
1172     return NULL;
1173   }
1174
1175   //Make a Python command
1176   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1177     << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1178
1179   SetErrorCode(OK);
1180   return aCopy;
1181 }
1182
1183 //=============================================================================
1184 /*!
1185  *  Rotate
1186  */
1187 //=============================================================================
1188 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1189                                                            Handle(GEOM_Object) theAxis,
1190                                                            double theAngle)
1191 {
1192   SetErrorCode(KO);
1193
1194   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1195
1196   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1197   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1198
1199   // Get last functions of the arguments
1200   Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1201
1202   //Add a rotate function
1203   aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1204
1205   if (aFunction.IsNull()) return NULL;
1206
1207   //Check if the function is set correctly
1208   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1209
1210   GEOMImpl_IRotate aRI(aFunction);
1211   aRI.SetAxis(anAF);
1212   aRI.SetOriginal(aLastFunction);
1213   aRI.SetAngle(theAngle);
1214
1215   //Compute the translation
1216   try {
1217 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1218     OCC_CATCH_SIGNALS;
1219 #endif
1220     if (!GetSolver()->ComputeFunction(aFunction)) {
1221       SetErrorCode("Rotate driver failed");
1222       return NULL;
1223     }
1224   }
1225   catch (Standard_Failure) {
1226     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1227     SetErrorCode(aFail->GetMessageString());
1228     return NULL;
1229   }
1230
1231   //Make a Python command
1232   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject
1233     << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1234
1235   SetErrorCode(OK);
1236   return theObject;
1237 }
1238
1239 //=============================================================================
1240 /*!
1241  *  Rotate
1242  */
1243 //=============================================================================
1244 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1245 {
1246   SetErrorCode(KO);
1247
1248   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1249
1250   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1251   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1252
1253   //Add a new Copy object
1254   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1255
1256   //Add a rotate function
1257   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1258   if (aFunction.IsNull()) return NULL;
1259
1260     //Check if the function is set correctly
1261   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1262
1263   GEOMImpl_IRotate aRI(aFunction);
1264   aRI.SetAxis(theAxis->GetLastFunction());
1265   aRI.SetOriginal(aLastFunction);
1266   aRI.SetAngle(theAngle);
1267
1268   //Compute the translation
1269   try {
1270 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1271     OCC_CATCH_SIGNALS;
1272 #endif
1273     if (!GetSolver()->ComputeFunction(aFunction)) {
1274       SetErrorCode("Rotate driver failed");
1275       return NULL;
1276     }
1277   }
1278   catch (Standard_Failure) {
1279     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1280     SetErrorCode(aFail->GetMessageString());
1281     return NULL;
1282   }
1283
1284   //Make a Python command
1285   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1286     << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1287
1288   SetErrorCode(OK);
1289   return aCopy;
1290 }
1291
1292 //=============================================================================
1293 /*!
1294  *  Rotate1D
1295  */
1296 //=============================================================================
1297 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1298                                                              Handle(GEOM_Object) theAxis,
1299                                                              Standard_Integer theNbTimes)
1300 {
1301   SetErrorCode(KO);
1302
1303   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1304
1305   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1306   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1307
1308   //Add a new Copy object
1309   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1310
1311   //Add a rotate function
1312   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1313   if (aFunction.IsNull()) return NULL;
1314
1315     //Check if the function is set correctly
1316   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1317
1318   GEOMImpl_IRotate aRI(aFunction);
1319   aRI.SetOriginal(aLastFunction);
1320   aRI.SetAxis(theAxis->GetLastFunction());
1321   aRI.SetNbIter1(theNbTimes);
1322
1323   //Compute the translation
1324   try {
1325 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1326     OCC_CATCH_SIGNALS;
1327 #endif
1328     if (!GetSolver()->ComputeFunction(aFunction)) {
1329       SetErrorCode("Rotate driver failed");
1330       return NULL;
1331     }
1332   }
1333   catch (Standard_Failure) {
1334     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1335     SetErrorCode(aFail->GetMessageString());
1336     return NULL;
1337   }
1338
1339   //Make a Python command
1340   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1341     << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1342
1343   SetErrorCode(OK);
1344   return aCopy;
1345 }
1346
1347 //=============================================================================
1348 /*!
1349  *  Rotate2D
1350  */
1351 //=============================================================================
1352 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1353                                                              Handle(GEOM_Object) theAxis,
1354                                                              double theAngle,
1355                                                              Standard_Integer theNbTimes1,
1356                                                              double theStep,
1357                                                              Standard_Integer theNbTimes2)
1358 {
1359   SetErrorCode(KO);
1360
1361   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1362
1363   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1364   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1365
1366   //Add a new Copy object
1367   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1368
1369   //Add a rotate function
1370   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1371   if (aFunction.IsNull()) return NULL;
1372
1373     //Check if the function is set correctly
1374   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1375
1376   GEOMImpl_IRotate aRI(aFunction);
1377   aRI.SetAxis(theAxis->GetLastFunction());
1378   aRI.SetOriginal(aLastFunction);
1379   aRI.SetNbIter1(theNbTimes1);
1380   aRI.SetNbIter2(theNbTimes2);
1381   aRI.SetAngle(theAngle);
1382   aRI.SetStep(theStep);
1383
1384   //Compute the translation
1385   try {
1386 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1387     OCC_CATCH_SIGNALS;
1388 #endif
1389     if (!GetSolver()->ComputeFunction(aFunction)) {
1390       SetErrorCode("Rotate driver failed");
1391       return NULL;
1392     }
1393   }
1394   catch (Standard_Failure) {
1395     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1396     SetErrorCode(aFail->GetMessageString());
1397     return NULL;
1398   }
1399
1400   //Make a Python command
1401   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1402     << theObject << ", " << theAxis << ", " << theAngle << ", "
1403       << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1404
1405   SetErrorCode(OK);
1406   return aCopy;
1407 }
1408
1409 //=============================================================================
1410 /*!
1411  *  RotateThreePoints
1412  */
1413 //=============================================================================
1414 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1415                                                                       Handle(GEOM_Object) theCentPoint, 
1416                                                                       Handle(GEOM_Object) thePoint1,
1417                                                                       Handle(GEOM_Object) thePoint2)
1418 {
1419   SetErrorCode(KO);
1420
1421   if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1422
1423   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1424   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1425
1426   // Get last functions of the arguments
1427   Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1428   Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1429   Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1430
1431
1432   //Add a rotate function
1433   aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1434
1435   if (aFunction.IsNull()) return NULL;
1436
1437   //Check if the function is set correctly
1438   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1439
1440   GEOMImpl_IRotate aRI(aFunction);
1441   aRI.SetCentPoint(aCPF);
1442   aRI.SetPoint1(aP1F);
1443   aRI.SetPoint2(aP2F);
1444   aRI.SetOriginal(aLastFunction);
1445
1446   //Compute the translation
1447   try {
1448 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1449     OCC_CATCH_SIGNALS;
1450 #endif
1451     if (!GetSolver()->ComputeFunction(aFunction)) {
1452       SetErrorCode("Rotate driver failed");
1453       return NULL;
1454     }
1455   }
1456   catch (Standard_Failure) {
1457     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1458     SetErrorCode(aFail->GetMessageString());
1459     return NULL;
1460   }
1461
1462   //Make a Python command
1463   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1464                                << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1465
1466   SetErrorCode(OK);
1467   return theObject;
1468 }
1469
1470 //=============================================================================
1471 /*!
1472  *  RotateThreePointsCopy
1473  */
1474 //=============================================================================
1475 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject, 
1476                                                          Handle(GEOM_Object) theCentPoint, 
1477                                                          Handle(GEOM_Object) thePoint1,
1478                                                          Handle(GEOM_Object) thePoint2)
1479 {
1480   SetErrorCode(KO);
1481
1482   if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1483
1484   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1485   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1486
1487   //Add a new Copy object
1488   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1489
1490   //Add a rotate function
1491   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1492   if (aFunction.IsNull()) return NULL;
1493
1494     //Check if the function is set correctly
1495   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1496
1497   GEOMImpl_IRotate aRI(aFunction);
1498   aRI.SetCentPoint(theCentPoint->GetLastFunction());
1499   aRI.SetPoint1(thePoint1->GetLastFunction());
1500   aRI.SetPoint2(thePoint2->GetLastFunction());
1501   aRI.SetOriginal(aLastFunction);
1502
1503   //Compute the translation
1504   try {
1505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1506     OCC_CATCH_SIGNALS;
1507 #endif
1508     if (!GetSolver()->ComputeFunction(aFunction)) {
1509       SetErrorCode("Rotate driver failed");
1510       return NULL;
1511     }
1512   }
1513   catch (Standard_Failure) {
1514     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1515     SetErrorCode(aFail->GetMessageString());
1516     return NULL;
1517   }
1518
1519   //Make a Python command
1520   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1521                                << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1522
1523   SetErrorCode(OK);
1524   return aCopy;
1525 }
1526