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