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