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