]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMImpl/GEOMImpl_ITransformOperations.cxx
Salome HOME
IMP 0021064: correct implementation
[modules/geom.git] / src / GEOMImpl / GEOMImpl_ITransformOperations.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 #include <Standard_Stream.hxx>
23
24 #include <GEOMImpl_ITransformOperations.hxx>
25
26 #include "utilities.h"
27 #include <OpUtil.hxx>
28 #include <Utils_ExceptHandlers.hxx>
29
30 #include <GEOM_Function.hxx>
31 #include <GEOM_PythonDump.hxx>
32
33 #include <GEOMImpl_TranslateDriver.hxx>
34 #include <GEOMImpl_MirrorDriver.hxx>
35 #include <GEOMImpl_OffsetDriver.hxx>
36 #include <GEOMImpl_ScaleDriver.hxx>
37 #include <GEOMImpl_RotateDriver.hxx>
38 #include <GEOMImpl_PositionDriver.hxx>
39
40 #include <GEOMImpl_ITranslate.hxx>
41 #include <GEOMImpl_IMirror.hxx>
42 #include <GEOMImpl_IOffset.hxx>
43 #include <GEOMImpl_IScale.hxx>
44 #include <GEOMImpl_IRotate.hxx>
45 #include <GEOMImpl_IPosition.hxx>
46
47 #include <GEOMImpl_Types.hxx>
48
49 #include <TFunction_DriverTable.hxx>
50 #include <TFunction_Driver.hxx>
51 #include <TFunction_Logbook.hxx>
52 #include <TDF_Tool.hxx>
53
54 #include <BRep_Tool.hxx>
55 #include <BRep_Builder.hxx>
56 #include <TopExp.hxx>
57 #include <TopoDS.hxx>
58 #include <TopoDS_Edge.hxx>
59 #include <TopoDS_Vertex.hxx>
60 #include <TopoDS_Compound.hxx>
61 #include <gp_Pnt.hxx>
62 #include <gp_Vec.hxx>
63 #include <gp_Trsf.hxx>
64
65 #include <StdFail_NotDone.hxx>
66 #include <Standard_Failure.hxx>
67 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
68
69 //=============================================================================
70 /*!
71  *   constructor:
72  */
73 //=============================================================================
74
75 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
76 : GEOM_IOperations(theEngine, theDocID)
77 {
78   MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
79 }
80
81 //=============================================================================
82 /*!
83  *  destructor
84  */
85 //=============================================================================
86
87 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
88 {
89   MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
90 }
91
92
93 //=============================================================================
94 /*!
95  *  TranslateTwoPoints
96  */
97 //=============================================================================
98 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
99        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
100 {
101   SetErrorCode(KO);
102
103   if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
104
105   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
106   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
107
108   // Get last functions of the arguments
109   Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
110   Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
111
112   //Add a translate function
113   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
114
115   if (aFunction.IsNull()) return NULL;
116
117   //Check if the function is set correctly
118   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
119
120   GEOMImpl_ITranslate aTI (aFunction);
121   aTI.SetPoint1(aP1F);
122   aTI.SetPoint2(aP2F);
123   aTI.SetOriginal(aLastFunction);
124
125   //Compute the translation
126   try {
127 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
128     OCC_CATCH_SIGNALS;
129 #endif
130     if (!GetSolver()->ComputeFunction(aFunction)) {
131       SetErrorCode("Translation driver failed");
132       return NULL;
133     }
134   }
135   catch (Standard_Failure) {
136     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
137     SetErrorCode(aFail->GetMessageString());
138     return NULL;
139   }
140
141   //Make a Python command
142   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
143     << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
144
145   SetErrorCode(OK);
146   return theObject;
147 }
148
149 //=============================================================================
150 /*!
151  *  TranslateDXDYDZ
152  */
153 //=============================================================================
154 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
155        (Handle(GEOM_Object) theObject, double theX, double theY,  double theZ)
156 {
157   SetErrorCode(KO);
158
159   if (theObject.IsNull()) return NULL;
160
161   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
162   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
163
164   //Add a translate function
165   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
166
167   if (aFunction.IsNull()) return NULL;
168
169   //Check if the function is set correctly
170   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
171
172   GEOMImpl_ITranslate aTI(aFunction);
173   aTI.SetDX(theX);
174   aTI.SetDY(theY);
175   aTI.SetDZ(theZ);
176   aTI.SetOriginal(aLastFunction);
177
178   //Compute the translation
179   try {
180 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
181     OCC_CATCH_SIGNALS;
182 #endif
183     if (!GetSolver()->ComputeFunction(aFunction)) {
184       SetErrorCode("Translation driver failed");
185       return NULL;
186     }
187   }
188   catch (Standard_Failure) {
189     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
190     SetErrorCode(aFail->GetMessageString());
191     return NULL;
192   }
193
194   //Make a Python command
195   GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
196     << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
197
198   SetErrorCode(OK);
199   return theObject;
200 }
201
202
203 //=============================================================================
204 /*!
205  *  TranslateTwoPointsCopy
206  */
207 //=============================================================================
208 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
209        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
210 {
211   SetErrorCode(KO);
212
213   if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
214
215   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
216   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
217
218   //Add a new Copy object
219   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
220
221   //Add a translate function
222   Handle(GEOM_Function) aFunction =
223     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
224
225   //Check if the function is set correctly
226   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
227
228   GEOMImpl_ITranslate aTI(aFunction);
229   aTI.SetPoint1(thePoint1->GetLastFunction());
230   aTI.SetPoint2(thePoint2->GetLastFunction());
231   //aTI.SetShape(theObject->GetValue());
232   aTI.SetOriginal(aLastFunction);
233
234   //Compute the translation
235   try {
236 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
237     OCC_CATCH_SIGNALS;
238 #endif
239     if (!GetSolver()->ComputeFunction(aFunction)) {
240       SetErrorCode("Translation driver failed");
241       return NULL;
242     }
243   }
244   catch (Standard_Failure) {
245     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
246     SetErrorCode(aFail->GetMessageString());
247     return NULL;
248   }
249
250   //Make a Python command
251   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
252     << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
253
254   SetErrorCode(OK);
255   return aCopy;
256 }
257
258 //=============================================================================
259 /*!
260  *  TranslateDXDYDZCopy
261  */
262 //=============================================================================
263 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
264        (Handle(GEOM_Object) theObject, double theX, double theY,  double theZ)
265 {
266   SetErrorCode(KO);
267
268   if (theObject.IsNull()) return NULL;
269
270   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
271   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
272
273   //Add a new Copy object
274   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
275
276   //Add a translate function
277   Handle(GEOM_Function) aFunction =
278     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
279
280   //Check if the function is set correctly
281   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
282
283   GEOMImpl_ITranslate aTI(aFunction);
284   aTI.SetDX(theX);
285   aTI.SetDY(theY);
286   aTI.SetDZ(theZ);
287   aTI.SetOriginal(aLastFunction);
288
289   //Compute the translation
290   try {
291 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
292     OCC_CATCH_SIGNALS;
293 #endif
294     if (!GetSolver()->ComputeFunction(aFunction)) {
295       SetErrorCode("Translation driver failed");
296       return NULL;
297     }
298   }
299   catch (Standard_Failure) {
300     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
301     SetErrorCode(aFail->GetMessageString());
302     return NULL;
303   }
304
305   //Make a Python command
306   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
307     << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
308
309   SetErrorCode(OK);
310   return aCopy;
311 }
312
313
314 //=============================================================================
315 /*!
316  *  TranslateVector
317  */
318 //=============================================================================
319 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
320        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
321 {
322   SetErrorCode(KO);
323
324   if (theObject.IsNull() || theVector.IsNull()) return NULL;
325
326   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
327   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
328
329   // Get last functions of the arguments
330   Handle(GEOM_Function) aVF = theVector->GetLastFunction();
331
332   //Add a translate function
333   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
334
335   if (aFunction.IsNull()) return NULL;
336
337   //Check if the function is set correctly
338   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
339
340   GEOMImpl_ITranslate aTI (aFunction);
341   aTI.SetVector(aVF);
342   aTI.SetOriginal(aLastFunction);
343
344   //Compute the translation
345   try {
346 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
347     OCC_CATCH_SIGNALS;
348 #endif
349     if (!GetSolver()->ComputeFunction(aFunction)) {
350       SetErrorCode("Translation driver failed");
351       return NULL;
352     }
353   }
354   catch (Standard_Failure) {
355     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
356     SetErrorCode(aFail->GetMessageString());
357     return NULL;
358   }
359
360   //Make a Python command
361   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
362                                << theObject << ", " << theVector << ")";
363
364   SetErrorCode(OK);
365   return theObject;
366 }
367 //=============================================================================
368 /*!
369  *  TranslateVectorCopy
370  */
371 //=============================================================================
372 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
373        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
374 {
375   SetErrorCode(KO);
376
377   if (theObject.IsNull() || theVector.IsNull()) return NULL;
378
379   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
380   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
381
382   //Add a new Copy object
383   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
384
385   //Add a translate function
386   Handle(GEOM_Function) aFunction =
387     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
388
389   //Check if the function is set correctly
390   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
391
392   GEOMImpl_ITranslate aTI(aFunction);
393   aTI.SetVector(theVector->GetLastFunction());
394 //  aTI.SetShape(theObject->GetValue());
395   aTI.SetOriginal(aLastFunction);
396
397   //Compute the translation
398   try {
399 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
400     OCC_CATCH_SIGNALS;
401 #endif
402     if (!GetSolver()->ComputeFunction(aFunction)) {
403       SetErrorCode("Translation driver failed");
404       return NULL;
405     }
406   }
407   catch (Standard_Failure) {
408     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
409     SetErrorCode(aFail->GetMessageString());
410     return NULL;
411   }
412
413   //Make a Python command
414   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
415                                << theObject << ", " << theVector << ")";
416
417   SetErrorCode(OK);
418   return aCopy;
419 }
420
421 //=============================================================================
422 /*!
423  *  TranslateVectorDistance
424  */
425 //=============================================================================
426 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
427        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
428 {
429   SetErrorCode(KO);
430
431   if (theObject.IsNull() || theVector.IsNull()) return NULL;
432
433   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
434   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
435
436   Handle(GEOM_Object) aCopy;   //Add a new Copy object
437   Handle(GEOM_Function) aFunction;
438
439   //Add a translate function
440   if (theCopy) {
441     aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
442     aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
443   }
444   else {
445     aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
446   }
447   if (aFunction.IsNull()) return NULL;
448
449   //Check if the function is set correctly
450   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
451
452   GEOMImpl_ITranslate aTI(aFunction);
453   aTI.SetVector(theVector->GetLastFunction());
454   aTI.SetDistance(theDistance);
455 //  aTI.SetShape(theObject->GetValue());
456   aTI.SetOriginal(aLastFunction);
457
458   //Compute the translation
459   try {
460 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
461     OCC_CATCH_SIGNALS;
462 #endif
463     if (!GetSolver()->ComputeFunction(aFunction)) {
464       SetErrorCode("Translation driver failed");
465       return NULL;
466     }
467   }
468   catch (Standard_Failure) {
469     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
470     SetErrorCode(aFail->GetMessageString());
471     return NULL;
472   }
473
474   //Make a Python command
475   if (theCopy) {
476     GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
477                                  << theObject << ", " << theVector << ", " << theDistance << ")";
478     SetErrorCode(OK);
479     return aCopy;
480   }
481
482   GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
483                                << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
484   SetErrorCode(OK);
485   return theObject;
486 }
487
488 //=============================================================================
489 /*!
490  *  Translate1D
491  */
492 //=============================================================================
493 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
494        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
495         double theStep, Standard_Integer theNbTimes)
496 {
497   SetErrorCode(KO);
498
499   if (theObject.IsNull() || theVector.IsNull()) return NULL;
500
501   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
502   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
503
504   //Add a new Copy object
505   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
506
507   //Add a translate function
508   Handle(GEOM_Function) aFunction =
509     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
510
511   //Check if the function is set correctly
512   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
513
514   GEOMImpl_ITranslate aTI(aFunction);
515   aTI.SetVector(theVector->GetLastFunction());
516   aTI.SetOriginal(aLastFunction);
517   aTI.SetStep1(theStep);
518   aTI.SetNbIter1(theNbTimes);
519
520   //Compute the translation
521   try {
522 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
523     OCC_CATCH_SIGNALS;
524 #endif
525     if (!GetSolver()->ComputeFunction(aFunction)) {
526       SetErrorCode("Translation driver failed");
527       return NULL;
528     }
529   }
530   catch (Standard_Failure) {
531     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
532     SetErrorCode(aFail->GetMessageString());
533     return NULL;
534   }
535
536   //Make a Python command
537   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
538     << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
539
540   SetErrorCode(OK);
541   return aCopy;
542 }
543
544 //=============================================================================
545 /*!
546  *  Translate2D
547  */
548 //=============================================================================
549 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
550                                                                 Handle(GEOM_Object) theVector,
551                                                                 double theStep1,
552                                                                 Standard_Integer theNbTimes1,
553                                                                 Handle(GEOM_Object) theVector2,
554                                                                 double theStep2,
555                                                                 Standard_Integer theNbTimes2)
556 {
557   SetErrorCode(KO);
558
559   if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
560
561   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
562   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
563
564   //Add a new Copy object
565   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
566
567   //Add a translate function
568   Handle(GEOM_Function) aFunction =
569     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
570
571   //Check if the function is set correctly
572   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
573
574   GEOMImpl_ITranslate aTI (aFunction);
575   aTI.SetVector(theVector->GetLastFunction());
576   aTI.SetVector2(theVector2->GetLastFunction());
577   aTI.SetOriginal(aLastFunction);
578   aTI.SetStep1(theStep1);
579   aTI.SetNbIter1(theNbTimes1);
580   aTI.SetStep2(theStep2);
581   aTI.SetNbIter2(theNbTimes2);
582
583   //Compute the translation
584   try {
585 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
586     OCC_CATCH_SIGNALS;
587 #endif
588     if (!GetSolver()->ComputeFunction(aFunction)) {
589       SetErrorCode("Translation driver failed");
590       return NULL;
591     }
592   }
593   catch (Standard_Failure) {
594     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
595     SetErrorCode(aFail->GetMessageString());
596     return NULL;
597   }
598
599   //Make a Python command
600   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
601     << theObject << ", " << theVector  << ", " << theStep1 << ", " << theNbTimes1
602       << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
603
604   SetErrorCode(OK);
605   return aCopy;
606 }
607
608 //=============================================================================
609 /*!
610  *  TranslateShape1D
611  */
612 //=============================================================================
613 /*
614 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape1D (const TopoDS_Shape&  theShape,
615                                                               GEOMImpl_ITranslate* theTI)
616 {
617   TopoDS_Shape aRes;
618
619   // Vector
620   Handle(GEOM_Function) aVector = theTI->GetVector();
621   if (aVector.IsNull()) {
622     StdFail_NotDone::Raise("Invalid object is given for vector argument");
623   }
624   TopoDS_Shape aV = aVector->GetValue();
625   if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) {
626     StdFail_NotDone::Raise("Invalid object is given for vector argument");
627   }
628   TopoDS_Edge anEdge = TopoDS::Edge(aV);
629
630   gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
631   gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
632   if (aP1.Distance(aP2) < gp::Resolution()) {
633     StdFail_NotDone::Raise("Invalid object is given for vector argument");
634   }
635
636   // Step and Nb.times
637   Standard_Real step = theTI->GetStep1();
638   Standard_Integer nbtimes = theTI->GetNbIter1();
639
640   // Make multi-translation
641   gp_Trsf aTrsf;
642   gp_Vec aVec;
643   TopoDS_Compound aCompound;
644   BRep_Builder B;
645   B.MakeCompound(aCompound);
646
647   gp_Vec Vec (aP1, aP2);
648   Vec.Normalize();
649
650   TopLoc_Location aLocOrig = theShape.Location();
651   gp_Trsf aTrsfOrig = aLocOrig.Transformation();
652
653   for (int i = 0; i < nbtimes; i++) {
654     aVec = Vec * (i * step);
655     aTrsf.SetTranslation(aVec);
656     //NPAL18620: performance problem: multiple locations are accumulated
657     //           in shape and need a great time to process
658     //BRepBuilderAPI_Transform aTransformation(theShape, aTrsf, Standard_False);
659     //B.Add(aCompound, aTransformation.Shape());
660     TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
661     B.Add(aCompound, theShape.Located(aLocRes));
662   }
663   aRes = aCompound;
664
665   return aRes;
666 }
667 */
668
669 //=============================================================================
670 /*!
671  *  TranslateShape2D
672  */
673 //=============================================================================
674 /*
675 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape2D (const TopoDS_Shape&  theShape,
676                                                               GEOMImpl_ITranslate* theTI)
677 {
678   TopoDS_Shape aRes;
679
680   // Vectors
681   Handle(GEOM_Function) aVector1 = theTI->GetVector();
682   Handle(GEOM_Function) aVector2 = theTI->GetVector2();
683
684   if (aVector1.IsNull() || aVector2.IsNull()) {
685     StdFail_NotDone::Raise("Invalid object is given for vector argument");
686   }
687
688   TopoDS_Shape aV1 = aVector1->GetValue();
689   TopoDS_Shape aV2 = aVector2->GetValue();
690
691   if (aV1.IsNull() || aV1.ShapeType() != TopAbs_EDGE ||
692       aV2.IsNull() || aV2.ShapeType() != TopAbs_EDGE) {
693     StdFail_NotDone::Raise("Invalid object is given for vector argument");
694   }
695
696   TopoDS_Edge anEdge1 = TopoDS::Edge(aV1);
697   TopoDS_Edge anEdge2 = TopoDS::Edge(aV2);
698
699   gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
700   gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1));
701   gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
702   gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2));
703
704   if (aP11.Distance(aP12) < gp::Resolution() ||
705       aP21.Distance(aP22) < gp::Resolution()) {
706     StdFail_NotDone::Raise("Invalid object is given for vector argument");
707   }
708
709   gp_Vec Vec1 (aP11, aP12);
710   gp_Vec Vec2 (aP21, aP22);
711
712   Vec1.Normalize();
713   Vec2.Normalize();
714
715   // Step and Nb.times
716   Standard_Real step1 = theTI->GetStep1(), step2 = theTI->GetStep2();
717   Standard_Integer nbtimes1 = theTI->GetNbIter1(), nbtimes2 = theTI->GetNbIter2();
718
719   // Make multi-translation
720   gp_Trsf aTrsf;
721   gp_Vec aVec;
722   Standard_Real DX, DY, DZ;
723   TopoDS_Compound aCompound;
724   BRep_Builder B;
725   B.MakeCompound(aCompound);
726
727   TopLoc_Location aLocOrig = theShape.Location();
728   gp_Trsf aTrsfOrig = aLocOrig.Transformation();
729
730   for (int i = 0; i < nbtimes1; i++) {
731     for (int j = 0; j < nbtimes2; j++) {
732       DX = i * step1 * Vec1.X() + j * step2 * Vec2.X();
733       DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y();
734       DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z();
735       aVec.SetCoord(DX, DY, DZ);
736       aTrsf.SetTranslation(aVec);
737       //NPAL18620: performance problem: multiple locations are accumulated
738       //           in shape and need a great time to process
739       //BRepBuilderAPI_Transform aBRepTransformation(theShape, aTrsf, Standard_False);
740       //B.Add(aCompound, aBRepTransformation.Shape());
741       TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
742       B.Add(aCompound, theShape.Located(aLocRes));
743     }
744   }
745   aRes = aCompound;
746
747   return aRes;
748 }
749 */
750
751 //=============================================================================
752 /*!
753  *  MirrorPlane
754  */
755 //=============================================================================
756 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
757        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
758 {
759   SetErrorCode(KO);
760
761   if (theObject.IsNull() || thePlane.IsNull()) return NULL;
762
763   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
764   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
765
766   // Get last functions of the arguments
767   Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
768
769   //Add a mirror function
770   Handle(GEOM_Function) aFunction =
771     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
772   if (aFunction.IsNull()) return NULL;
773
774   //Check if the function is set correctly
775   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
776
777   GEOMImpl_IMirror aTI (aFunction);
778   aTI.SetPlane(aPF);
779   aTI.SetOriginal(aLastFunction);
780
781   //Compute the mirror
782   try {
783 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
784     OCC_CATCH_SIGNALS;
785 #endif
786     if (!GetSolver()->ComputeFunction(aFunction)) {
787       SetErrorCode("Mirror driver failed");
788       return NULL;
789     }
790   }
791   catch (Standard_Failure) {
792     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
793     SetErrorCode(aFail->GetMessageString());
794     return NULL;
795   }
796
797   //Make a Python command
798   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
799                                << theObject << ", " << thePlane << ")";
800
801   SetErrorCode(OK);
802   return theObject;
803 }
804
805 //=============================================================================
806 /*!
807  *  MirrorPlaneCopy
808  */
809 //=============================================================================
810 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
811        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
812 {
813   SetErrorCode(KO);
814
815   if (theObject.IsNull() || thePlane.IsNull()) return NULL;
816
817   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
818   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
819
820   //Add a new Copy object
821   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
822
823   //Add a mirror function
824   Handle(GEOM_Function) aFunction =
825     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
826
827   //Check if the function is set correctly
828   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
829
830   GEOMImpl_IMirror aTI (aFunction);
831   aTI.SetPlane(thePlane->GetLastFunction());
832   aTI.SetOriginal(aLastFunction);
833
834   //Compute the mirror
835   try {
836 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
837     OCC_CATCH_SIGNALS;
838 #endif
839     if (!GetSolver()->ComputeFunction(aFunction)) {
840       SetErrorCode("Mirror driver failed");
841       return NULL;
842     }
843   }
844   catch (Standard_Failure) {
845     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
846     SetErrorCode(aFail->GetMessageString());
847     return NULL;
848   }
849
850   //Make a Python command
851   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
852                                << theObject << ", " << thePlane << ")";
853
854   SetErrorCode(OK);
855   return aCopy;
856 }
857
858 //=============================================================================
859 /*!
860  *  MirrorPoint
861  */
862 //=============================================================================
863 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
864        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
865 {
866   SetErrorCode(KO);
867
868   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
869
870   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
871   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
872
873   // Get last functions of the arguments
874   Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
875
876   //Add a mirror function
877   Handle(GEOM_Function) aFunction =
878     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
879   if (aFunction.IsNull()) return NULL;
880
881   //Check if the function is set correctly
882   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
883
884   GEOMImpl_IMirror aTI (aFunction);
885   aTI.SetPoint(aPF);
886   aTI.SetOriginal(aLastFunction);
887
888   //Compute the mirror
889   try {
890 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
891     OCC_CATCH_SIGNALS;
892 #endif
893     if (!GetSolver()->ComputeFunction(aFunction)) {
894       SetErrorCode("Mirror driver failed");
895       return NULL;
896     }
897   }
898   catch (Standard_Failure) {
899     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
900     SetErrorCode(aFail->GetMessageString());
901     return NULL;
902   }
903
904   //Make a Python command
905   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
906                                << theObject << ", " << thePoint << ")";
907
908   SetErrorCode(OK);
909   return NULL;
910 }
911
912 //=============================================================================
913 /*!
914  *  MirrorPointCopy
915  */
916 //=============================================================================
917 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
918        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
919 {
920   SetErrorCode(KO);
921
922   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
923
924   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
925   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
926
927   //Add a new Copy object
928   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
929
930   //Add a mirror function
931   Handle(GEOM_Function) aFunction =
932     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
933
934   //Check if the function is set correctly
935   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
936
937   GEOMImpl_IMirror aTI (aFunction);
938   aTI.SetPoint(thePoint->GetLastFunction());
939   aTI.SetOriginal(aLastFunction);
940
941   //Compute the mirror
942   try {
943 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
944     OCC_CATCH_SIGNALS;
945 #endif
946     if (!GetSolver()->ComputeFunction(aFunction)) {
947       SetErrorCode("Mirror driver failed");
948       return NULL;
949     }
950   }
951   catch (Standard_Failure) {
952     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
953     SetErrorCode(aFail->GetMessageString());
954     return NULL;
955   }
956
957   //Make a Python command
958   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
959                                << theObject << ", " << thePoint << ")";
960
961   SetErrorCode(OK);
962   return aCopy;
963 }
964
965 //=============================================================================
966 /*!
967  *  MirrorAxis
968  */
969 //=============================================================================
970 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
971        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
972 {
973   SetErrorCode(KO);
974
975   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
976
977   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
978   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
979
980   // Get last functions of the arguments
981   Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
982
983   //Add a mirror function
984   Handle(GEOM_Function) aFunction =
985     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
986   if (aFunction.IsNull()) return NULL;
987
988   //Check if the function is set correctly
989   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
990
991   GEOMImpl_IMirror aTI (aFunction);
992   aTI.SetAxis(anAF);
993   aTI.SetOriginal(aLastFunction);
994
995   //Compute the mirror
996   try {
997 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
998     OCC_CATCH_SIGNALS;
999 #endif
1000     if (!GetSolver()->ComputeFunction(aFunction)) {
1001       SetErrorCode("Mirror driver failed");
1002       return NULL;
1003     }
1004   }
1005   catch (Standard_Failure) {
1006     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1007     SetErrorCode(aFail->GetMessageString());
1008     return NULL;
1009   }
1010
1011   //Make a Python command
1012   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
1013                                << theObject << ", " << theAxis << ")";
1014
1015   SetErrorCode(OK);
1016   return NULL;
1017 }
1018
1019 //=============================================================================
1020 /*!
1021  *  MirrorAxisCopy
1022  */
1023 //=============================================================================
1024 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
1025        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
1026 {
1027   SetErrorCode(KO);
1028
1029   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1030
1031   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
1032   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
1033
1034   //Add a new Copy object
1035   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1036
1037   //Add a mirror function
1038   Handle(GEOM_Function) aFunction =
1039     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
1040
1041   //Check if the function is set correctly
1042   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
1043
1044   GEOMImpl_IMirror aTI (aFunction);
1045   aTI.SetAxis(theAxis->GetLastFunction());
1046   aTI.SetOriginal(aLastFunction);
1047
1048   //Compute the mirror
1049   try {
1050 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1051     OCC_CATCH_SIGNALS;
1052 #endif
1053     if (!GetSolver()->ComputeFunction(aFunction)) {
1054       SetErrorCode("Mirror driver failed");
1055       return NULL;
1056     }
1057   }
1058   catch (Standard_Failure) {
1059     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1060     SetErrorCode(aFail->GetMessageString());
1061     return NULL;
1062   }
1063
1064   //Make a Python command
1065   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
1066                                << theObject << ", " << theAxis << ")";
1067
1068   SetErrorCode(OK);
1069   return aCopy;
1070 }
1071
1072
1073 //=============================================================================
1074 /*!
1075  *  OffsetShape
1076  */
1077 //=============================================================================
1078 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
1079                               (Handle(GEOM_Object) theObject, double theOffset)
1080 {
1081   SetErrorCode(KO);
1082
1083   if (theObject.IsNull()) return NULL;
1084
1085   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1086   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1087
1088   //Add a new Offset function
1089   Handle(GEOM_Function) aFunction =
1090     theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
1091   if (aFunction.IsNull()) return NULL;
1092
1093   //Check if the function is set correctly
1094   if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1095
1096   GEOMImpl_IOffset aTI (aFunction);
1097   aTI.SetShape(anOriginal);
1098   aTI.SetValue(theOffset);
1099
1100   //Compute the offset
1101   try {
1102 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1103     OCC_CATCH_SIGNALS;
1104 #endif
1105     if (!GetSolver()->ComputeFunction(aFunction)) {
1106       SetErrorCode("Offset driver failed");
1107       return NULL;
1108     }
1109   }
1110   catch (Standard_Failure) {
1111     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1112     SetErrorCode(aFail->GetMessageString());
1113     return NULL;
1114   }
1115
1116   //Make a Python command
1117   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
1118                                << theObject << ", " << theOffset << ")";
1119
1120   SetErrorCode(OK);
1121   return theObject;
1122 }
1123
1124 //=============================================================================
1125 /*!
1126  *  OffsetShapeCopy
1127  */
1128 //=============================================================================
1129 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
1130                               (Handle(GEOM_Object) theObject, double theOffset)
1131 {
1132   SetErrorCode(KO);
1133
1134   if (theObject.IsNull()) return NULL;
1135
1136   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1137   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1138
1139   //Add a new Copy object
1140   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1141
1142   //Add a new Offset function
1143   Handle(GEOM_Function) aFunction =
1144     aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
1145   if (aFunction.IsNull()) return NULL;
1146
1147   //Check if the function is set correctly
1148   if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1149
1150   GEOMImpl_IOffset aTI (aFunction);
1151   aTI.SetShape(anOriginal);
1152   aTI.SetValue(theOffset);
1153
1154   //Compute the offset
1155   try {
1156 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1157     OCC_CATCH_SIGNALS;
1158 #endif
1159     if (!GetSolver()->ComputeFunction(aFunction)) {
1160       SetErrorCode("Offset driver failed");
1161       return NULL;
1162     }
1163   }
1164   catch (Standard_Failure) {
1165     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1166     SetErrorCode(aFail->GetMessageString());
1167     return NULL;
1168   }
1169
1170   //Make a Python command
1171   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1172                                << theObject << ", " << theOffset << ")";
1173
1174   SetErrorCode(OK);
1175   return aCopy;
1176 }
1177
1178
1179 //=============================================================================
1180 /*!
1181  *  ScaleShape
1182  */
1183 //=============================================================================
1184 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1185        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1186 {
1187   SetErrorCode(KO);
1188
1189   if (theObject.IsNull()) return NULL;
1190
1191   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1192   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1193
1194   //Add a scale function
1195   Handle(GEOM_Function) aFunction =
1196     theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1197   if (aFunction.IsNull()) return NULL;
1198
1199   //Check if the function is set correctly
1200   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1201
1202   // Set arguments
1203   GEOMImpl_IScale aTI (aFunction);
1204   aTI.SetShape(anOriginal);
1205   aTI.SetFactor(theFactor);
1206
1207   // Set point argument
1208   if (!thePoint.IsNull()) {
1209     Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1210     aTI.SetPoint(aPF);
1211   }
1212
1213   //Compute the scale
1214   try {
1215 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1216     OCC_CATCH_SIGNALS;
1217 #endif
1218     if (!GetSolver()->ComputeFunction(aFunction)) {
1219       SetErrorCode("Scale driver failed");
1220       return NULL;
1221     }
1222   }
1223   catch (Standard_Failure) {
1224     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1225     SetErrorCode(aFail->GetMessageString());
1226     return NULL;
1227   }
1228
1229   //Make a Python command
1230   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
1231     << theObject << ", " << thePoint << ", " << theFactor << ")";
1232
1233   SetErrorCode(OK);
1234   return theObject;
1235 }
1236
1237 //=============================================================================
1238 /*!
1239  *  ScaleShapeCopy
1240  */
1241 //=============================================================================
1242 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1243        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1244 {
1245   SetErrorCode(KO);
1246
1247   if (theObject.IsNull()) return NULL;
1248
1249   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1250   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1251
1252   //Add a new Copy object
1253   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1254
1255   //Add a scale function
1256   Handle(GEOM_Function) aFunction =
1257     aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1258   if (aFunction.IsNull()) return NULL;
1259
1260   //Check if the function is set correctly
1261   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1262
1263   // Set arguments
1264   GEOMImpl_IScale aTI (aFunction);
1265   aTI.SetShape(anOriginal);
1266   aTI.SetFactor(theFactor);
1267
1268   // Set point argument
1269   if (!thePoint.IsNull()) {
1270     Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1271     aTI.SetPoint(aPF);
1272   }
1273
1274   //Compute the scale
1275   try {
1276 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1277     OCC_CATCH_SIGNALS;
1278 #endif
1279     if (!GetSolver()->ComputeFunction(aFunction)) {
1280       SetErrorCode("Scale driver failed");
1281       return NULL;
1282     }
1283   }
1284   catch (Standard_Failure) {
1285     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1286     SetErrorCode(aFail->GetMessageString());
1287     return NULL;
1288   }
1289
1290   //Make a Python command
1291   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1292     << theObject << ", " << thePoint << ", " << theFactor << ")";
1293
1294   SetErrorCode(OK);
1295   return aCopy;
1296 }
1297
1298 //=============================================================================
1299 /*!
1300  *  ScaleShapeAlongAxes
1301  */
1302 //=============================================================================
1303 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1304                                                                         Handle(GEOM_Object) thePoint,
1305                                                                         double theFactorX,
1306                                                                         double theFactorY,
1307                                                                         double theFactorZ,
1308                                                                         bool   doCopy)
1309 {
1310   SetErrorCode(KO);
1311
1312   if (theObject.IsNull()) return NULL;
1313
1314   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1315   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1316
1317   //Add a scale function
1318   Handle(GEOM_Object) aCopy;   //Add a new Copy object
1319   Handle(GEOM_Function) aFunction;
1320   if (doCopy) {
1321     aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1322     aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1323   }
1324   else {
1325     aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1326   }
1327   if (aFunction.IsNull()) return NULL;
1328
1329   //Check if the function is set correctly
1330   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1331
1332   // Set arguments
1333   GEOMImpl_IScale aTI (aFunction);
1334   aTI.SetShape(anOriginal);
1335   aTI.SetFactorX(theFactorX);
1336   aTI.SetFactorY(theFactorY);
1337   aTI.SetFactorZ(theFactorZ);
1338
1339   // Set point (optional argument)
1340   if (!thePoint.IsNull()) {
1341     Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1342     aTI.SetPoint(aPF);
1343   }
1344
1345   //Compute the scale
1346   try {
1347 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1348     OCC_CATCH_SIGNALS;
1349 #endif
1350     if (!GetSolver()->ComputeFunction(aFunction)) {
1351       SetErrorCode("Scale driver failed");
1352       return NULL;
1353     }
1354   }
1355   catch (Standard_Failure) {
1356     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1357     SetErrorCode(aFail->GetMessageString());
1358     return NULL;
1359   }
1360
1361   SetErrorCode(OK);
1362
1363   //Make a Python command
1364   if (doCopy) {
1365     GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
1366                                  << theObject << ", " << thePoint << ", "
1367                                  << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1368     return aCopy;
1369   }
1370
1371   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes("
1372                                << theObject << ", " << thePoint << ", "
1373                                << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1374   return theObject;
1375 }
1376
1377 //=============================================================================
1378 /*!
1379  *  PositionShape
1380  */
1381 //=============================================================================
1382 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1383         (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1384 {
1385   SetErrorCode(KO);
1386
1387   if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1388
1389   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1390   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1391
1392   //Add a Position function
1393   Standard_Integer aType = POSITION_SHAPE;
1394   if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1395
1396   Handle(GEOM_Function) aFunction =
1397     theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1398   if (aFunction.IsNull()) return NULL;
1399
1400   //Check if the function is set correctly
1401   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1402
1403   //Set operation arguments
1404   GEOMImpl_IPosition aTI (aFunction);
1405   aTI.SetShape(anOriginal);
1406   aTI.SetEndLCS(theEndLCS->GetLastFunction());
1407   if (!theStartLCS.IsNull())
1408     aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction());
1409
1410   //Compute the Position
1411   try {
1412 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1413     OCC_CATCH_SIGNALS;
1414 #endif
1415     if (!GetSolver()->ComputeFunction(aFunction)) {
1416       SetErrorCode("Position driver failed");
1417       return NULL;
1418     }
1419   }
1420   catch (Standard_Failure) {
1421     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1422     SetErrorCode(aFail->GetMessageString());
1423     return NULL;
1424   }
1425
1426   //Make a Python command
1427   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1428     << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1429
1430   SetErrorCode(OK);
1431   return theObject;
1432 }
1433
1434 //=============================================================================
1435 /*!
1436  *  PositionShapeCopy
1437  */
1438 //=============================================================================
1439 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1440        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1441 {
1442   SetErrorCode(KO);
1443
1444   if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1445
1446   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1447   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1448
1449   //Add a new Copy object
1450   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1451
1452   //Add a position function
1453   Standard_Integer aType = POSITION_SHAPE_COPY;
1454   if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1455
1456   Handle(GEOM_Function) aFunction =
1457     aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1458   if (aFunction.IsNull()) return NULL;
1459
1460   //Check if the function is set correctly
1461   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1462
1463   GEOMImpl_IPosition aTI (aFunction);
1464   aTI.SetShape(anOriginal);
1465   aTI.SetEndLCS(theEndLCS->GetLastFunction());
1466   if (!theStartLCS.IsNull())
1467     aTI.SetStartLCS(theStartLCS->GetLastFunction());
1468
1469   //Compute the position
1470   try {
1471 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1472     OCC_CATCH_SIGNALS;
1473 #endif
1474     if (!GetSolver()->ComputeFunction(aFunction)) {
1475       SetErrorCode("Position driver failed");
1476       return NULL;
1477     }
1478   }
1479   catch (Standard_Failure) {
1480     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1481     SetErrorCode(aFail->GetMessageString());
1482     return NULL;
1483   }
1484
1485   //Make a Python command
1486   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1487     << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1488
1489   SetErrorCode(OK);
1490   return aCopy;
1491 }
1492
1493 //=============================================================================
1494 /*!
1495  *  PositionAlongPath
1496  */
1497 //=============================================================================
1498 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1499        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath, 
1500         double theDistance, bool theCopy, bool theReverse)
1501 {
1502   SetErrorCode(KO);
1503
1504   if (theObject.IsNull() || thePath.IsNull()) return NULL;
1505
1506   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1507   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1508
1509   //Add a position function
1510   Handle(GEOM_Function) aFunction;
1511   Handle(GEOM_Object) aCopy;
1512
1513   if (theCopy) {
1514     aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1515     aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1516   }
1517   else
1518     aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1519
1520   if (aFunction.IsNull()) return NULL;
1521
1522   //Check if the function is set correctly
1523   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1524
1525   GEOMImpl_IPosition aTI (aFunction);
1526   aTI.SetShape(anOriginal);
1527   aTI.SetPath(thePath->GetLastFunction());
1528   aTI.SetDistance(theDistance);
1529   aTI.SetReverse(theReverse);
1530
1531   //Compute the position
1532   try {
1533 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1534     OCC_CATCH_SIGNALS;
1535 #endif
1536     if (!GetSolver()->ComputeFunction(aFunction)) {
1537       SetErrorCode("Position driver failed");
1538       return NULL;
1539     }
1540   }
1541   catch (Standard_Failure) {
1542     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1543     SetErrorCode(aFail->GetMessageString());
1544     return NULL;
1545   }
1546
1547   //Make a Python command
1548   if (theCopy) {
1549     GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath("
1550                                  << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1551     SetErrorCode(OK);
1552     return aCopy;
1553   }
1554
1555   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath("
1556     << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1557
1558   SetErrorCode(OK);
1559   return theObject;
1560 }
1561
1562 //=============================================================================
1563 /*!
1564  *  Rotate
1565  */
1566 //=============================================================================
1567 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1568                                                            Handle(GEOM_Object) theAxis,
1569                                                            double theAngle)
1570 {
1571   SetErrorCode(KO);
1572
1573   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1574
1575   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1576   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1577
1578   // Get last functions of the arguments
1579   Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1580
1581   //Add a rotate function
1582   aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1583
1584   if (aFunction.IsNull()) return NULL;
1585
1586   //Check if the function is set correctly
1587   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1588
1589   GEOMImpl_IRotate aRI(aFunction);
1590   aRI.SetAxis(anAF);
1591   aRI.SetOriginal(aLastFunction);
1592   aRI.SetAngle(theAngle);
1593
1594   //Compute the translation
1595   try {
1596 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1597     OCC_CATCH_SIGNALS;
1598 #endif
1599     if (!GetSolver()->ComputeFunction(aFunction)) {
1600       SetErrorCode("Rotate driver failed");
1601       return NULL;
1602     }
1603   }
1604   catch (Standard_Failure) {
1605     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1606     SetErrorCode(aFail->GetMessageString());
1607     return NULL;
1608   }
1609
1610   //Make a Python command
1611   GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1612     << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1613
1614   SetErrorCode(OK);
1615   return theObject;
1616 }
1617
1618 //=============================================================================
1619 /*!
1620  *  Rotate
1621  */
1622 //=============================================================================
1623 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1624 {
1625   SetErrorCode(KO);
1626
1627   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1628
1629   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1630   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1631
1632   //Add a new Copy object
1633   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1634
1635   //Add a rotate function
1636   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1637   if (aFunction.IsNull()) return NULL;
1638
1639     //Check if the function is set correctly
1640   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1641
1642   GEOMImpl_IRotate aRI(aFunction);
1643   aRI.SetAxis(theAxis->GetLastFunction());
1644   aRI.SetOriginal(aLastFunction);
1645   aRI.SetAngle(theAngle);
1646
1647   //Compute the translation
1648   try {
1649 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1650     OCC_CATCH_SIGNALS;
1651 #endif
1652     if (!GetSolver()->ComputeFunction(aFunction)) {
1653       SetErrorCode("Rotate driver failed");
1654       return NULL;
1655     }
1656   }
1657   catch (Standard_Failure) {
1658     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1659     SetErrorCode(aFail->GetMessageString());
1660     return NULL;
1661   }
1662
1663   //Make a Python command
1664   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1665     << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1666
1667   SetErrorCode(OK);
1668   return aCopy;
1669 }
1670
1671 //=============================================================================
1672 /*!
1673  *  Rotate1D
1674  */
1675 //=============================================================================
1676 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1677                                                              Handle(GEOM_Object) theAxis,
1678                                                              Standard_Integer theNbTimes)
1679 {
1680   SetErrorCode(KO);
1681
1682   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1683
1684   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1685   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1686
1687   //Add a new Copy object
1688   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1689
1690   //Add a rotate function
1691   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1692   if (aFunction.IsNull()) return NULL;
1693
1694   //Check if the function is set correctly
1695   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1696
1697   GEOMImpl_IRotate aRI(aFunction);
1698   aRI.SetOriginal(aLastFunction);
1699   aRI.SetAxis(theAxis->GetLastFunction());
1700   aRI.SetNbIter1(theNbTimes);
1701
1702   //Compute the translation
1703   try {
1704 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1705     OCC_CATCH_SIGNALS;
1706 #endif
1707     if (!GetSolver()->ComputeFunction(aFunction)) {
1708       SetErrorCode("Rotate driver failed");
1709       return NULL;
1710     }
1711   }
1712   catch (Standard_Failure) {
1713     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1714     SetErrorCode(aFail->GetMessageString());
1715     return NULL;
1716   }
1717
1718   //Make a Python command
1719   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1720     << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1721
1722   SetErrorCode(OK);
1723   return aCopy;
1724 }
1725
1726 //=============================================================================
1727 /*!
1728  *  Rotate2D
1729  */
1730 //=============================================================================
1731 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1732                                                              Handle(GEOM_Object) theAxis,
1733                                                              double theAngle,
1734                                                              Standard_Integer theNbTimes1,
1735                                                              double theStep,
1736                                                              Standard_Integer theNbTimes2)
1737 {
1738   SetErrorCode(KO);
1739
1740   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1741
1742   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1743   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1744
1745   //Add a new Copy object
1746   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1747
1748   //Add a rotate function
1749   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1750   if (aFunction.IsNull()) return NULL;
1751
1752     //Check if the function is set correctly
1753   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1754
1755   GEOMImpl_IRotate aRI(aFunction);
1756   aRI.SetAxis(theAxis->GetLastFunction());
1757   aRI.SetOriginal(aLastFunction);
1758   aRI.SetNbIter1(theNbTimes1);
1759   aRI.SetNbIter2(theNbTimes2);
1760   aRI.SetAngle(theAngle);
1761   aRI.SetStep(theStep);
1762
1763   //Compute the translation
1764   try {
1765 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1766     OCC_CATCH_SIGNALS;
1767 #endif
1768     if (!GetSolver()->ComputeFunction(aFunction)) {
1769       SetErrorCode("Rotate driver failed");
1770       return NULL;
1771     }
1772   }
1773   catch (Standard_Failure) {
1774     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1775     SetErrorCode(aFail->GetMessageString());
1776     return NULL;
1777   }
1778
1779   //Make a Python command
1780   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1781     << theObject << ", " << theAxis << ", " << theAngle << ", "
1782       << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1783
1784   SetErrorCode(OK);
1785   return aCopy;
1786 }
1787
1788 //=============================================================================
1789 /*!
1790  *  RotateThreePoints
1791  */
1792 //=============================================================================
1793 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1794                                                                       Handle(GEOM_Object) theCentPoint, 
1795                                                                       Handle(GEOM_Object) thePoint1,
1796                                                                       Handle(GEOM_Object) thePoint2)
1797 {
1798   SetErrorCode(KO);
1799
1800   if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1801
1802   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1803   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1804
1805   // Get last functions of the arguments
1806   Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1807   Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1808   Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1809
1810
1811   //Add a rotate function
1812   aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1813
1814   if (aFunction.IsNull()) return NULL;
1815
1816   //Check if the function is set correctly
1817   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1818
1819   GEOMImpl_IRotate aRI(aFunction);
1820   aRI.SetCentPoint(aCPF);
1821   aRI.SetPoint1(aP1F);
1822   aRI.SetPoint2(aP2F);
1823   aRI.SetOriginal(aLastFunction);
1824
1825   //Compute the translation
1826   try {
1827 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1828     OCC_CATCH_SIGNALS;
1829 #endif
1830     if (!GetSolver()->ComputeFunction(aFunction)) {
1831       SetErrorCode("Rotate driver failed");
1832       return NULL;
1833     }
1834   }
1835   catch (Standard_Failure) {
1836     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1837     SetErrorCode(aFail->GetMessageString());
1838     return NULL;
1839   }
1840
1841   //Make a Python command
1842   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1843                                << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1844
1845   SetErrorCode(OK);
1846   return theObject;
1847 }
1848
1849 //=============================================================================
1850 /*!
1851  *  RotateThreePointsCopy
1852  */
1853 //=============================================================================
1854 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject, 
1855                                                          Handle(GEOM_Object) theCentPoint, 
1856                                                          Handle(GEOM_Object) thePoint1,
1857                                                          Handle(GEOM_Object) thePoint2)
1858 {
1859   SetErrorCode(KO);
1860
1861   if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1862
1863   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1864   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1865
1866   //Add a new Copy object
1867   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1868
1869   //Add a rotate function
1870   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1871   if (aFunction.IsNull()) return NULL;
1872
1873     //Check if the function is set correctly
1874   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1875
1876   GEOMImpl_IRotate aRI(aFunction);
1877   aRI.SetCentPoint(theCentPoint->GetLastFunction());
1878   aRI.SetPoint1(thePoint1->GetLastFunction());
1879   aRI.SetPoint2(thePoint2->GetLastFunction());
1880   aRI.SetOriginal(aLastFunction);
1881
1882   //Compute the translation
1883   try {
1884 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1885     OCC_CATCH_SIGNALS;
1886 #endif
1887     if (!GetSolver()->ComputeFunction(aFunction)) {
1888       SetErrorCode("Rotate driver failed");
1889       return NULL;
1890     }
1891   }
1892   catch (Standard_Failure) {
1893     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1894     SetErrorCode(aFail->GetMessageString());
1895     return NULL;
1896   }
1897
1898   //Make a Python command
1899   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1900                                << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1901
1902   SetErrorCode(OK);
1903   return aCopy;
1904 }
1905
1906 //=============================================================================
1907 /*!
1908  *  TransformLikeOtherCopy
1909  */
1910 //=============================================================================
1911 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
1912                                                 (Handle(GEOM_Object) theObject, 
1913                                                  Handle(GEOM_Object) theSample)
1914 {
1915   SetErrorCode(KO);
1916
1917   if (theObject.IsNull() || theSample.IsNull()) return NULL;
1918
1919   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
1920   if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
1921
1922   Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
1923   if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
1924
1925   // Add a new Copy object
1926   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1927
1928   // Add a transform function (depends on theSample function)
1929   Handle(GEOM_Function) aFunction =
1930     aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
1931   if (aFunction.IsNull()) return NULL;
1932
1933   // Check if the function is set correctly
1934   if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
1935
1936   if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
1937     switch (aSampleFunc->GetType()) {
1938     case TRANSLATE_1D:
1939       {
1940         GEOMImpl_ITranslate aRI_sample (aSampleFunc);
1941         GEOMImpl_ITranslate aRI_target (aFunction);
1942
1943         aRI_target.SetVector(aRI_sample.GetVector());
1944         aRI_target.SetStep1(aRI_sample.GetStep1());
1945         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
1946
1947         aRI_target.SetOriginal(aLastFunction);
1948       }
1949       break;
1950     case TRANSLATE_2D:
1951       {
1952         GEOMImpl_ITranslate aRI_sample (aSampleFunc);
1953         GEOMImpl_ITranslate aRI_target (aFunction);
1954
1955         aRI_target.SetVector(aRI_sample.GetVector());
1956         aRI_target.SetStep1(aRI_sample.GetStep1());
1957         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
1958
1959         aRI_target.SetVector2(aRI_sample.GetVector2());
1960         aRI_target.SetStep2(aRI_sample.GetStep2());
1961         aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
1962
1963         aRI_target.SetOriginal(aLastFunction);
1964       }
1965       break;
1966     default:
1967       {
1968         SetErrorCode("Not implemented case of TransformLikeOtherCopy");
1969         return NULL;
1970       }
1971     }
1972   }
1973   else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
1974     switch (aSampleFunc->GetType()) {
1975     case ROTATE_1D:
1976       {
1977         GEOMImpl_IRotate aRI_sample (aSampleFunc);
1978         GEOMImpl_IRotate aRI_target (aFunction);
1979
1980         aRI_target.SetAxis(aRI_sample.GetAxis());
1981         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
1982
1983         aRI_target.SetOriginal(aLastFunction);
1984       }
1985       break;
1986     case ROTATE_2D:
1987       {
1988         GEOMImpl_IRotate aRI_sample (aSampleFunc);
1989         GEOMImpl_IRotate aRI_target (aFunction);
1990
1991         aRI_target.SetAxis(aRI_sample.GetAxis());
1992
1993         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
1994         aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
1995
1996         aRI_target.SetAngle(aRI_sample.GetAngle());
1997         aRI_target.SetStep(aRI_sample.GetStep());
1998
1999         aRI_target.SetDir2(aRI_sample.GetDir2());
2000
2001         aRI_target.SetOriginal(aLastFunction);
2002       }
2003       break;
2004     case ROTATE_THREE_POINTS_COPY:
2005       {
2006         GEOMImpl_IRotate aRI_sample (aSampleFunc);
2007         GEOMImpl_IRotate aRI_target (aFunction);
2008
2009         aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
2010         aRI_target.SetPoint1(aRI_sample.GetPoint1());
2011         aRI_target.SetPoint2(aRI_sample.GetPoint2());
2012
2013         aRI_target.SetOriginal(aLastFunction);
2014       }
2015       break;
2016     default:
2017       {
2018         SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2019         return NULL;
2020       }
2021     }
2022   }
2023   else {
2024     SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2025     return NULL;
2026   }
2027
2028   // Compute the transformation
2029   try {
2030 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2031     OCC_CATCH_SIGNALS;
2032 #endif
2033     if (!GetSolver()->ComputeFunction(aFunction)) {
2034       SetErrorCode("Driver failed");
2035       return NULL;
2036     }
2037   }
2038   catch (Standard_Failure) {
2039     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2040     SetErrorCode(aFail->GetMessageString());
2041     return NULL;
2042   }
2043
2044   //Make a Python command
2045   //GEOM::TPythonDump(aFunction) << aCopy << " = geompy.TransformLikeOtherCopy("
2046   //                             << theObject << ", " << theSample << ")";
2047
2048   SetErrorCode(OK);
2049   return aCopy;
2050 }