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