Back to index

salome-geom  6.5.0
GEOMImpl_ITransformOperations.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include <Standard_Stream.hxx>
00024 
00025 #include <GEOMImpl_ITransformOperations.hxx>
00026 
00027 #include <GEOMImpl_TranslateDriver.hxx>
00028 #include <GEOMImpl_MirrorDriver.hxx>
00029 #include <GEOMImpl_ProjectionDriver.hxx>
00030 #include <GEOMImpl_OffsetDriver.hxx>
00031 #include <GEOMImpl_ScaleDriver.hxx>
00032 #include <GEOMImpl_RotateDriver.hxx>
00033 #include <GEOMImpl_PositionDriver.hxx>
00034 
00035 #include <GEOMImpl_ITranslate.hxx>
00036 #include <GEOMImpl_IMirror.hxx>
00037 #include <GEOMImpl_IOffset.hxx>
00038 #include <GEOMImpl_IScale.hxx>
00039 #include <GEOMImpl_IRotate.hxx>
00040 #include <GEOMImpl_IPosition.hxx>
00041 
00042 #include <GEOMImpl_Types.hxx>
00043 
00044 #include <GEOM_Function.hxx>
00045 #include <GEOM_PythonDump.hxx>
00046 
00047 #include <Basics_OCCTVersion.hxx>
00048 
00049 #include "utilities.h"
00050 #include <OpUtil.hxx>
00051 #include <Utils_ExceptHandlers.hxx>
00052 
00053 #include <TFunction_DriverTable.hxx>
00054 #include <TFunction_Driver.hxx>
00055 #include <TFunction_Logbook.hxx>
00056 #include <TDF_Tool.hxx>
00057 
00058 #include <BRep_Tool.hxx>
00059 #include <BRep_Builder.hxx>
00060 #include <TopExp.hxx>
00061 #include <TopoDS.hxx>
00062 #include <TopoDS_Edge.hxx>
00063 #include <TopoDS_Vertex.hxx>
00064 #include <TopoDS_Compound.hxx>
00065 #include <gp_Pnt.hxx>
00066 #include <gp_Vec.hxx>
00067 #include <gp_Trsf.hxx>
00068 
00069 #include <StdFail_NotDone.hxx>
00070 #include <Standard_Failure.hxx>
00071 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
00072 
00073 //=============================================================================
00077 //=============================================================================
00078 
00079 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
00080 : GEOM_IOperations(theEngine, theDocID)
00081 {
00082   MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
00083 }
00084 
00085 //=============================================================================
00089 //=============================================================================
00090 
00091 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
00092 {
00093   MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
00094 }
00095 
00096 
00097 //=============================================================================
00101 //=============================================================================
00102 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
00103        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
00104 {
00105   SetErrorCode(KO);
00106 
00107   if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
00108 
00109   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
00110   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00111 
00112   // Get last functions of the arguments
00113   Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
00114   Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
00115 
00116   //Add a translate function
00117   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
00118 
00119   if (aFunction.IsNull()) return NULL;
00120 
00121   //Check if the function is set correctly
00122   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00123 
00124   GEOMImpl_ITranslate aTI (aFunction);
00125   aTI.SetPoint1(aP1F);
00126   aTI.SetPoint2(aP2F);
00127   aTI.SetOriginal(aLastFunction);
00128 
00129   //Compute the translation
00130   try {
00131 #if OCC_VERSION_LARGE > 0x06010000
00132     OCC_CATCH_SIGNALS;
00133 #endif
00134     if (!GetSolver()->ComputeFunction(aFunction)) {
00135       SetErrorCode("Translation driver failed");
00136       return NULL;
00137     }
00138   }
00139   catch (Standard_Failure) {
00140     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00141     SetErrorCode(aFail->GetMessageString());
00142     return NULL;
00143   }
00144 
00145   //Make a Python command
00146   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
00147     << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
00148 
00149   SetErrorCode(OK);
00150   return theObject;
00151 }
00152 
00153 //=============================================================================
00157 //=============================================================================
00158 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
00159        (Handle(GEOM_Object) theObject, double theX, double theY,  double theZ)
00160 {
00161   SetErrorCode(KO);
00162 
00163   if (theObject.IsNull()) return NULL;
00164 
00165   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
00166   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00167 
00168   //Add a translate function
00169   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
00170 
00171   if (aFunction.IsNull()) return NULL;
00172 
00173   //Check if the function is set correctly
00174   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00175 
00176   GEOMImpl_ITranslate aTI(aFunction);
00177   aTI.SetDX(theX);
00178   aTI.SetDY(theY);
00179   aTI.SetDZ(theZ);
00180   aTI.SetOriginal(aLastFunction);
00181 
00182   //Compute the translation
00183   try {
00184 #if OCC_VERSION_LARGE > 0x06010000
00185     OCC_CATCH_SIGNALS;
00186 #endif
00187     if (!GetSolver()->ComputeFunction(aFunction)) {
00188       SetErrorCode("Translation driver failed");
00189       return NULL;
00190     }
00191   }
00192   catch (Standard_Failure) {
00193     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00194     SetErrorCode(aFail->GetMessageString());
00195     return NULL;
00196   }
00197 
00198   //Make a Python command
00199   GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
00200     << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
00201 
00202   SetErrorCode(OK);
00203   return theObject;
00204 }
00205 
00206 
00207 //=============================================================================
00211 //=============================================================================
00212 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
00213        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
00214 {
00215   SetErrorCode(KO);
00216 
00217   if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
00218 
00219   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00220   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00221 
00222   //Add a new Copy object
00223   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00224 
00225   //Add a translate function
00226   Handle(GEOM_Function) aFunction =
00227     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
00228 
00229   //Check if the function is set correctly
00230   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00231 
00232   GEOMImpl_ITranslate aTI(aFunction);
00233   aTI.SetPoint1(thePoint1->GetLastFunction());
00234   aTI.SetPoint2(thePoint2->GetLastFunction());
00235   //aTI.SetShape(theObject->GetValue());
00236   aTI.SetOriginal(aLastFunction);
00237 
00238   //Compute the translation
00239   try {
00240 #if OCC_VERSION_LARGE > 0x06010000
00241     OCC_CATCH_SIGNALS;
00242 #endif
00243     if (!GetSolver()->ComputeFunction(aFunction)) {
00244       SetErrorCode("Translation driver failed");
00245       return NULL;
00246     }
00247   }
00248   catch (Standard_Failure) {
00249     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00250     SetErrorCode(aFail->GetMessageString());
00251     return NULL;
00252   }
00253 
00254   //Make a Python command
00255   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
00256     << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
00257 
00258   SetErrorCode(OK);
00259   return aCopy;
00260 }
00261 
00262 //=============================================================================
00266 //=============================================================================
00267 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
00268        (Handle(GEOM_Object) theObject, double theX, double theY,  double theZ)
00269 {
00270   SetErrorCode(KO);
00271 
00272   if (theObject.IsNull()) return NULL;
00273 
00274   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00275   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00276 
00277   //Add a new Copy object
00278   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00279 
00280   //Add a translate function
00281   Handle(GEOM_Function) aFunction =
00282     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
00283 
00284   //Check if the function is set correctly
00285   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00286 
00287   GEOMImpl_ITranslate aTI(aFunction);
00288   aTI.SetDX(theX);
00289   aTI.SetDY(theY);
00290   aTI.SetDZ(theZ);
00291   aTI.SetOriginal(aLastFunction);
00292 
00293   //Compute the translation
00294   try {
00295 #if OCC_VERSION_LARGE > 0x06010000
00296     OCC_CATCH_SIGNALS;
00297 #endif
00298     if (!GetSolver()->ComputeFunction(aFunction)) {
00299       SetErrorCode("Translation driver failed");
00300       return NULL;
00301     }
00302   }
00303   catch (Standard_Failure) {
00304     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00305     SetErrorCode(aFail->GetMessageString());
00306     return NULL;
00307   }
00308 
00309   //Make a Python command
00310   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
00311     << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
00312 
00313   SetErrorCode(OK);
00314   return aCopy;
00315 }
00316 
00317 
00318 //=============================================================================
00322 //=============================================================================
00323 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
00324        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
00325 {
00326   SetErrorCode(KO);
00327 
00328   if (theObject.IsNull() || theVector.IsNull()) return NULL;
00329 
00330   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
00331   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00332 
00333   // Get last functions of the arguments
00334   Handle(GEOM_Function) aVF = theVector->GetLastFunction();
00335 
00336   //Add a translate function
00337   aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
00338 
00339   if (aFunction.IsNull()) return NULL;
00340 
00341   //Check if the function is set correctly
00342   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00343 
00344   GEOMImpl_ITranslate aTI (aFunction);
00345   aTI.SetVector(aVF);
00346   aTI.SetOriginal(aLastFunction);
00347 
00348   //Compute the translation
00349   try {
00350 #if OCC_VERSION_LARGE > 0x06010000
00351     OCC_CATCH_SIGNALS;
00352 #endif
00353     if (!GetSolver()->ComputeFunction(aFunction)) {
00354       SetErrorCode("Translation driver failed");
00355       return NULL;
00356     }
00357   }
00358   catch (Standard_Failure) {
00359     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00360     SetErrorCode(aFail->GetMessageString());
00361     return NULL;
00362   }
00363 
00364   //Make a Python command
00365   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
00366                                << theObject << ", " << theVector << ")";
00367 
00368   SetErrorCode(OK);
00369   return theObject;
00370 }
00371 //=============================================================================
00375 //=============================================================================
00376 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
00377        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
00378 {
00379   SetErrorCode(KO);
00380 
00381   if (theObject.IsNull() || theVector.IsNull()) return NULL;
00382 
00383   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00384   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00385 
00386   //Add a new Copy object
00387   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00388 
00389   //Add a translate function
00390   Handle(GEOM_Function) aFunction =
00391     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
00392 
00393   //Check if the function is set correctly
00394   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00395 
00396   GEOMImpl_ITranslate aTI(aFunction);
00397   aTI.SetVector(theVector->GetLastFunction());
00398 //  aTI.SetShape(theObject->GetValue());
00399   aTI.SetOriginal(aLastFunction);
00400 
00401   //Compute the translation
00402   try {
00403 #if OCC_VERSION_LARGE > 0x06010000
00404     OCC_CATCH_SIGNALS;
00405 #endif
00406     if (!GetSolver()->ComputeFunction(aFunction)) {
00407       SetErrorCode("Translation driver failed");
00408       return NULL;
00409     }
00410   }
00411   catch (Standard_Failure) {
00412     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00413     SetErrorCode(aFail->GetMessageString());
00414     return NULL;
00415   }
00416 
00417   //Make a Python command
00418   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
00419                                << theObject << ", " << theVector << ")";
00420 
00421   SetErrorCode(OK);
00422   return aCopy;
00423 }
00424 
00425 //=============================================================================
00429 //=============================================================================
00430 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
00431        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
00432 {
00433   SetErrorCode(KO);
00434 
00435   if (theObject.IsNull() || theVector.IsNull()) return NULL;
00436 
00437   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00438   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00439 
00440   Handle(GEOM_Object) aCopy;   //Add a new Copy object
00441   Handle(GEOM_Function) aFunction;
00442 
00443   //Add a translate function
00444   if (theCopy) {
00445     aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00446     aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
00447   }
00448   else {
00449     aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
00450   }
00451   if (aFunction.IsNull()) return NULL;
00452 
00453   //Check if the function is set correctly
00454   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00455 
00456   GEOMImpl_ITranslate aTI(aFunction);
00457   aTI.SetVector(theVector->GetLastFunction());
00458   aTI.SetDistance(theDistance);
00459 //  aTI.SetShape(theObject->GetValue());
00460   aTI.SetOriginal(aLastFunction);
00461 
00462   //Compute the translation
00463   try {
00464 #if OCC_VERSION_LARGE > 0x06010000
00465     OCC_CATCH_SIGNALS;
00466 #endif
00467     if (!GetSolver()->ComputeFunction(aFunction)) {
00468       SetErrorCode("Translation driver failed");
00469       return NULL;
00470     }
00471   }
00472   catch (Standard_Failure) {
00473     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00474     SetErrorCode(aFail->GetMessageString());
00475     return NULL;
00476   }
00477 
00478   //Make a Python command
00479   if (theCopy) {
00480     GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
00481                                  << theObject << ", " << theVector << ", " << theDistance << ")";
00482     SetErrorCode(OK);
00483     return aCopy;
00484   }
00485 
00486   GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
00487                                << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
00488   SetErrorCode(OK);
00489   return theObject;
00490 }
00491 
00492 //=============================================================================
00496 //=============================================================================
00497 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
00498        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
00499         double theStep, Standard_Integer theNbTimes)
00500 {
00501   SetErrorCode(KO);
00502 
00503   if (theObject.IsNull() || theVector.IsNull()) return NULL;
00504 
00505   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00506   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00507 
00508   //Add a new Copy object
00509   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00510 
00511   //Add a translate function
00512   Handle(GEOM_Function) aFunction =
00513     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
00514 
00515   //Check if the function is set correctly
00516   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00517 
00518   GEOMImpl_ITranslate aTI(aFunction);
00519   aTI.SetVector(theVector->GetLastFunction());
00520   aTI.SetOriginal(aLastFunction);
00521   aTI.SetStep1(theStep);
00522   aTI.SetNbIter1(theNbTimes);
00523 
00524   //Compute the translation
00525   try {
00526 #if OCC_VERSION_LARGE > 0x06010000
00527     OCC_CATCH_SIGNALS;
00528 #endif
00529     if (!GetSolver()->ComputeFunction(aFunction)) {
00530       SetErrorCode("Translation driver failed");
00531       return NULL;
00532     }
00533   }
00534   catch (Standard_Failure) {
00535     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00536     SetErrorCode(aFail->GetMessageString());
00537     return NULL;
00538   }
00539 
00540   //Make a Python command
00541   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
00542     << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
00543 
00544   SetErrorCode(OK);
00545   return aCopy;
00546 }
00547 
00548 //=============================================================================
00552 //=============================================================================
00553 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
00554                                                                 Handle(GEOM_Object) theVector,
00555                                                                 double theStep1,
00556                                                                 Standard_Integer theNbTimes1,
00557                                                                 Handle(GEOM_Object) theVector2,
00558                                                                 double theStep2,
00559                                                                 Standard_Integer theNbTimes2)
00560 {
00561   SetErrorCode(KO);
00562 
00563   if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
00564 
00565   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00566   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
00567 
00568   //Add a new Copy object
00569   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00570 
00571   //Add a translate function
00572   Handle(GEOM_Function) aFunction =
00573     aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
00574 
00575   //Check if the function is set correctly
00576   if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
00577 
00578   GEOMImpl_ITranslate aTI (aFunction);
00579   aTI.SetVector(theVector->GetLastFunction());
00580   aTI.SetVector2(theVector2->GetLastFunction());
00581   aTI.SetOriginal(aLastFunction);
00582   aTI.SetStep1(theStep1);
00583   aTI.SetNbIter1(theNbTimes1);
00584   aTI.SetStep2(theStep2);
00585   aTI.SetNbIter2(theNbTimes2);
00586 
00587   //Compute the translation
00588   try {
00589 #if OCC_VERSION_LARGE > 0x06010000
00590     OCC_CATCH_SIGNALS;
00591 #endif
00592     if (!GetSolver()->ComputeFunction(aFunction)) {
00593       SetErrorCode("Translation driver failed");
00594       return NULL;
00595     }
00596   }
00597   catch (Standard_Failure) {
00598     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00599     SetErrorCode(aFail->GetMessageString());
00600     return NULL;
00601   }
00602 
00603   //Make a Python command
00604   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
00605     << theObject << ", " << theVector  << ", " << theStep1 << ", " << theNbTimes1
00606       << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
00607 
00608   SetErrorCode(OK);
00609   return aCopy;
00610 }
00611 
00612 //=============================================================================
00616 //=============================================================================
00617 /*
00618 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape1D (const TopoDS_Shape&  theShape,
00619                                                               GEOMImpl_ITranslate* theTI)
00620 {
00621   TopoDS_Shape aRes;
00622 
00623   // Vector
00624   Handle(GEOM_Function) aVector = theTI->GetVector();
00625   if (aVector.IsNull()) {
00626     StdFail_NotDone::Raise("Invalid object is given for vector argument");
00627   }
00628   TopoDS_Shape aV = aVector->GetValue();
00629   if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) {
00630     StdFail_NotDone::Raise("Invalid object is given for vector argument");
00631   }
00632   TopoDS_Edge anEdge = TopoDS::Edge(aV);
00633 
00634   gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
00635   gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
00636   if (aP1.Distance(aP2) < gp::Resolution()) {
00637     StdFail_NotDone::Raise("Invalid object is given for vector argument");
00638   }
00639 
00640   // Step and Nb.times
00641   Standard_Real step = theTI->GetStep1();
00642   Standard_Integer nbtimes = theTI->GetNbIter1();
00643 
00644   // Make multi-translation
00645   gp_Trsf aTrsf;
00646   gp_Vec aVec;
00647   TopoDS_Compound aCompound;
00648   BRep_Builder B;
00649   B.MakeCompound(aCompound);
00650 
00651   gp_Vec Vec (aP1, aP2);
00652   Vec.Normalize();
00653 
00654   TopLoc_Location aLocOrig = theShape.Location();
00655   gp_Trsf aTrsfOrig = aLocOrig.Transformation();
00656 
00657   for (int i = 0; i < nbtimes; i++) {
00658     aVec = Vec * (i * step);
00659     aTrsf.SetTranslation(aVec);
00660     //NPAL18620: performance problem: multiple locations are accumulated
00661     //           in shape and need a great time to process
00662     //BRepBuilderAPI_Transform aTransformation(theShape, aTrsf, Standard_False);
00663     //B.Add(aCompound, aTransformation.Shape());
00664     TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
00665     B.Add(aCompound, theShape.Located(aLocRes));
00666   }
00667   aRes = aCompound;
00668 
00669   return aRes;
00670 }
00671 */
00672 
00673 //=============================================================================
00677 //=============================================================================
00678 /*
00679 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape2D (const TopoDS_Shape&  theShape,
00680                                                               GEOMImpl_ITranslate* theTI)
00681 {
00682   TopoDS_Shape aRes;
00683 
00684   // Vectors
00685   Handle(GEOM_Function) aVector1 = theTI->GetVector();
00686   Handle(GEOM_Function) aVector2 = theTI->GetVector2();
00687 
00688   if (aVector1.IsNull() || aVector2.IsNull()) {
00689     StdFail_NotDone::Raise("Invalid object is given for vector argument");
00690   }
00691 
00692   TopoDS_Shape aV1 = aVector1->GetValue();
00693   TopoDS_Shape aV2 = aVector2->GetValue();
00694 
00695   if (aV1.IsNull() || aV1.ShapeType() != TopAbs_EDGE ||
00696       aV2.IsNull() || aV2.ShapeType() != TopAbs_EDGE) {
00697     StdFail_NotDone::Raise("Invalid object is given for vector argument");
00698   }
00699 
00700   TopoDS_Edge anEdge1 = TopoDS::Edge(aV1);
00701   TopoDS_Edge anEdge2 = TopoDS::Edge(aV2);
00702 
00703   gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
00704   gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1));
00705   gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
00706   gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2));
00707 
00708   if (aP11.Distance(aP12) < gp::Resolution() ||
00709       aP21.Distance(aP22) < gp::Resolution()) {
00710     StdFail_NotDone::Raise("Invalid object is given for vector argument");
00711   }
00712 
00713   gp_Vec Vec1 (aP11, aP12);
00714   gp_Vec Vec2 (aP21, aP22);
00715 
00716   Vec1.Normalize();
00717   Vec2.Normalize();
00718 
00719   // Step and Nb.times
00720   Standard_Real step1 = theTI->GetStep1(), step2 = theTI->GetStep2();
00721   Standard_Integer nbtimes1 = theTI->GetNbIter1(), nbtimes2 = theTI->GetNbIter2();
00722 
00723   // Make multi-translation
00724   gp_Trsf aTrsf;
00725   gp_Vec aVec;
00726   Standard_Real DX, DY, DZ;
00727   TopoDS_Compound aCompound;
00728   BRep_Builder B;
00729   B.MakeCompound(aCompound);
00730 
00731   TopLoc_Location aLocOrig = theShape.Location();
00732   gp_Trsf aTrsfOrig = aLocOrig.Transformation();
00733 
00734   for (int i = 0; i < nbtimes1; i++) {
00735     for (int j = 0; j < nbtimes2; j++) {
00736       DX = i * step1 * Vec1.X() + j * step2 * Vec2.X();
00737       DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y();
00738       DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z();
00739       aVec.SetCoord(DX, DY, DZ);
00740       aTrsf.SetTranslation(aVec);
00741       //NPAL18620: performance problem: multiple locations are accumulated
00742       //           in shape and need a great time to process
00743       //BRepBuilderAPI_Transform aBRepTransformation(theShape, aTrsf, Standard_False);
00744       //B.Add(aCompound, aBRepTransformation.Shape());
00745       TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
00746       B.Add(aCompound, theShape.Located(aLocRes));
00747     }
00748   }
00749   aRes = aCompound;
00750 
00751   return aRes;
00752 }
00753 */
00754 
00755 //=============================================================================
00759 //=============================================================================
00760 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
00761        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
00762 {
00763   SetErrorCode(KO);
00764 
00765   if (theObject.IsNull() || thePlane.IsNull()) return NULL;
00766 
00767   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00768   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
00769 
00770   // Get last functions of the arguments
00771   Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
00772 
00773   //Add a mirror function
00774   Handle(GEOM_Function) aFunction =
00775     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
00776   if (aFunction.IsNull()) return NULL;
00777 
00778   //Check if the function is set correctly
00779   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
00780 
00781   GEOMImpl_IMirror aTI (aFunction);
00782   aTI.SetPlane(aPF);
00783   aTI.SetOriginal(aLastFunction);
00784 
00785   //Compute the mirror
00786   try {
00787 #if OCC_VERSION_LARGE > 0x06010000
00788     OCC_CATCH_SIGNALS;
00789 #endif
00790     if (!GetSolver()->ComputeFunction(aFunction)) {
00791       SetErrorCode("Mirror driver failed");
00792       return NULL;
00793     }
00794   }
00795   catch (Standard_Failure) {
00796     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00797     SetErrorCode(aFail->GetMessageString());
00798     return NULL;
00799   }
00800 
00801   //Make a Python command
00802   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
00803                                << theObject << ", " << thePlane << ")";
00804 
00805   SetErrorCode(OK);
00806   return theObject;
00807 }
00808 
00809 //=============================================================================
00813 //=============================================================================
00814 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
00815        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
00816 {
00817   SetErrorCode(KO);
00818 
00819   if (theObject.IsNull() || thePlane.IsNull()) return NULL;
00820 
00821   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00822   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
00823 
00824   //Add a new Copy object
00825   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00826 
00827   //Add a mirror function
00828   Handle(GEOM_Function) aFunction =
00829     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
00830 
00831   //Check if the function is set correctly
00832   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
00833 
00834   GEOMImpl_IMirror aTI (aFunction);
00835   aTI.SetPlane(thePlane->GetLastFunction());
00836   aTI.SetOriginal(aLastFunction);
00837 
00838   //Compute the mirror
00839   try {
00840 #if OCC_VERSION_LARGE > 0x06010000
00841     OCC_CATCH_SIGNALS;
00842 #endif
00843     if (!GetSolver()->ComputeFunction(aFunction)) {
00844       SetErrorCode("Mirror driver failed");
00845       return NULL;
00846     }
00847   }
00848   catch (Standard_Failure) {
00849     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00850     SetErrorCode(aFail->GetMessageString());
00851     return NULL;
00852   }
00853 
00854   //Make a Python command
00855   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
00856                                << theObject << ", " << thePlane << ")";
00857 
00858   SetErrorCode(OK);
00859   return aCopy;
00860 }
00861 
00862 //=============================================================================
00866 //=============================================================================
00867 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
00868        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
00869 {
00870   SetErrorCode(KO);
00871 
00872   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
00873 
00874   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00875   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
00876 
00877   // Get last functions of the arguments
00878   Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
00879 
00880   //Add a mirror function
00881   Handle(GEOM_Function) aFunction =
00882     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
00883   if (aFunction.IsNull()) return NULL;
00884 
00885   //Check if the function is set correctly
00886   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
00887 
00888   GEOMImpl_IMirror aTI (aFunction);
00889   aTI.SetPoint(aPF);
00890   aTI.SetOriginal(aLastFunction);
00891 
00892   //Compute the mirror
00893   try {
00894 #if OCC_VERSION_LARGE > 0x06010000
00895     OCC_CATCH_SIGNALS;
00896 #endif
00897     if (!GetSolver()->ComputeFunction(aFunction)) {
00898       SetErrorCode("Mirror driver failed");
00899       return NULL;
00900     }
00901   }
00902   catch (Standard_Failure) {
00903     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00904     SetErrorCode(aFail->GetMessageString());
00905     return NULL;
00906   }
00907 
00908   //Make a Python command
00909   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
00910                                << theObject << ", " << thePoint << ")";
00911 
00912   SetErrorCode(OK);
00913   return NULL;
00914 }
00915 
00916 //=============================================================================
00920 //=============================================================================
00921 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
00922        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
00923 {
00924   SetErrorCode(KO);
00925 
00926   if (theObject.IsNull() || thePoint.IsNull()) return NULL;
00927 
00928   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00929   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
00930 
00931   //Add a new Copy object
00932   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
00933 
00934   //Add a mirror function
00935   Handle(GEOM_Function) aFunction =
00936     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
00937 
00938   //Check if the function is set correctly
00939   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
00940 
00941   GEOMImpl_IMirror aTI (aFunction);
00942   aTI.SetPoint(thePoint->GetLastFunction());
00943   aTI.SetOriginal(aLastFunction);
00944 
00945   //Compute the mirror
00946   try {
00947 #if OCC_VERSION_LARGE > 0x06010000
00948     OCC_CATCH_SIGNALS;
00949 #endif
00950     if (!GetSolver()->ComputeFunction(aFunction)) {
00951       SetErrorCode("Mirror driver failed");
00952       return NULL;
00953     }
00954   }
00955   catch (Standard_Failure) {
00956     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00957     SetErrorCode(aFail->GetMessageString());
00958     return NULL;
00959   }
00960 
00961   //Make a Python command
00962   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
00963                                << theObject << ", " << thePoint << ")";
00964 
00965   SetErrorCode(OK);
00966   return aCopy;
00967 }
00968 
00969 //=============================================================================
00973 //=============================================================================
00974 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
00975        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
00976 {
00977   SetErrorCode(KO);
00978 
00979   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
00980 
00981   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
00982   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
00983 
00984   // Get last functions of the arguments
00985   Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
00986 
00987   //Add a mirror function
00988   Handle(GEOM_Function) aFunction =
00989     theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
00990   if (aFunction.IsNull()) return NULL;
00991 
00992   //Check if the function is set correctly
00993   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
00994 
00995   GEOMImpl_IMirror aTI (aFunction);
00996   aTI.SetAxis(anAF);
00997   aTI.SetOriginal(aLastFunction);
00998 
00999   //Compute the mirror
01000   try {
01001 #if OCC_VERSION_LARGE > 0x06010000
01002     OCC_CATCH_SIGNALS;
01003 #endif
01004     if (!GetSolver()->ComputeFunction(aFunction)) {
01005       SetErrorCode("Mirror driver failed");
01006       return NULL;
01007     }
01008   }
01009   catch (Standard_Failure) {
01010     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01011     SetErrorCode(aFail->GetMessageString());
01012     return NULL;
01013   }
01014 
01015   //Make a Python command
01016   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
01017                                << theObject << ", " << theAxis << ")";
01018 
01019   SetErrorCode(OK);
01020   return NULL;
01021 }
01022 
01023 //=============================================================================
01027 //=============================================================================
01028 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
01029        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
01030 {
01031   SetErrorCode(KO);
01032 
01033   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
01034 
01035   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
01036   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
01037 
01038   //Add a new Copy object
01039   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01040 
01041   //Add a mirror function
01042   Handle(GEOM_Function) aFunction =
01043     aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
01044 
01045   //Check if the function is set correctly
01046   if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
01047 
01048   GEOMImpl_IMirror aTI (aFunction);
01049   aTI.SetAxis(theAxis->GetLastFunction());
01050   aTI.SetOriginal(aLastFunction);
01051 
01052   //Compute the mirror
01053   try {
01054 #if OCC_VERSION_LARGE > 0x06010000
01055     OCC_CATCH_SIGNALS;
01056 #endif
01057     if (!GetSolver()->ComputeFunction(aFunction)) {
01058       SetErrorCode("Mirror driver failed");
01059       return NULL;
01060     }
01061   }
01062   catch (Standard_Failure) {
01063     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01064     SetErrorCode(aFail->GetMessageString());
01065     return NULL;
01066   }
01067 
01068   //Make a Python command
01069   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
01070                                << theObject << ", " << theAxis << ")";
01071 
01072   SetErrorCode(OK);
01073   return aCopy;
01074 }
01075 
01076 
01077 //=============================================================================
01081 //=============================================================================
01082 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
01083                               (Handle(GEOM_Object) theObject, double theOffset)
01084 {
01085   SetErrorCode(KO);
01086 
01087   if (theObject.IsNull()) return NULL;
01088 
01089   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01090   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
01091 
01092   //Add a new Offset function
01093   Handle(GEOM_Function) aFunction =
01094     theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
01095   if (aFunction.IsNull()) return NULL;
01096 
01097   //Check if the function is set correctly
01098   if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
01099 
01100   GEOMImpl_IOffset aTI (aFunction);
01101   aTI.SetShape(anOriginal);
01102   aTI.SetValue(theOffset);
01103 
01104   //Compute the offset
01105   try {
01106 #if OCC_VERSION_LARGE > 0x06010000
01107     OCC_CATCH_SIGNALS;
01108 #endif
01109     if (!GetSolver()->ComputeFunction(aFunction)) {
01110       SetErrorCode("Offset driver failed");
01111       return NULL;
01112     }
01113   }
01114   catch (Standard_Failure) {
01115     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01116     SetErrorCode(aFail->GetMessageString());
01117     return NULL;
01118   }
01119 
01120   //Make a Python command
01121   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
01122                                << theObject << ", " << theOffset << ")";
01123 
01124   SetErrorCode(OK);
01125   return theObject;
01126 }
01127 
01128 //=============================================================================
01132 //=============================================================================
01133 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
01134                               (Handle(GEOM_Object) theObject, double theOffset)
01135 {
01136   SetErrorCode(KO);
01137 
01138   if (theObject.IsNull()) return NULL;
01139 
01140   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01141   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
01142 
01143   //Add a new Copy object
01144   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01145 
01146   //Add a new Offset function
01147   Handle(GEOM_Function) aFunction =
01148     aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
01149   if (aFunction.IsNull()) return NULL;
01150 
01151   //Check if the function is set correctly
01152   if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
01153 
01154   GEOMImpl_IOffset aTI (aFunction);
01155   aTI.SetShape(anOriginal);
01156   aTI.SetValue(theOffset);
01157 
01158   //Compute the offset
01159   try {
01160 #if OCC_VERSION_LARGE > 0x06010000
01161     OCC_CATCH_SIGNALS;
01162 #endif
01163     if (!GetSolver()->ComputeFunction(aFunction)) {
01164       SetErrorCode("Offset driver failed");
01165       return NULL;
01166     }
01167   }
01168   catch (Standard_Failure) {
01169     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01170     SetErrorCode(aFail->GetMessageString());
01171     return NULL;
01172   }
01173 
01174   //Make a Python command
01175   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
01176                                << theObject << ", " << theOffset << ")";
01177 
01178   SetErrorCode(OK);
01179   return aCopy;
01180 }
01181 
01182 
01183 //=============================================================================
01187 //=============================================================================
01188 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy
01189        (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget)
01190 {
01191   SetErrorCode(KO);
01192 
01193   if (theSource.IsNull() || theTarget.IsNull()) return NULL;
01194 
01195   Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
01196   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
01197 
01198   //Add a new Projection object
01199   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
01200 
01201   //Add a Projection function
01202   Handle(GEOM_Function) aFunction =
01203     aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
01204 
01205   //Check if the function is set correctly
01206   if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
01207 
01208   GEOMImpl_IMirror aTI (aFunction);
01209   aTI.SetPlane(theTarget->GetLastFunction());
01210   aTI.SetOriginal(aLastFunction);
01211 
01212   //Compute the Projection
01213   try {
01214 #if OCC_VERSION_LARGE > 0x06010000
01215     OCC_CATCH_SIGNALS;
01216 #endif
01217     if (!GetSolver()->ComputeFunction(aFunction)) {
01218       SetErrorCode("Projection driver failed");
01219       return NULL;
01220     }
01221   }
01222   catch (Standard_Failure) {
01223     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01224     SetErrorCode(aFail->GetMessageString());
01225     return NULL;
01226   }
01227 
01228   //Make a Python command
01229   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
01230                                << theSource << ", " << theTarget << ")";
01231 
01232   SetErrorCode(OK);
01233   return aCopy;
01234 }
01235 
01236 
01237 //=============================================================================
01241 //=============================================================================
01242 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
01243        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
01244 {
01245   SetErrorCode(KO);
01246 
01247   if (theObject.IsNull()) return NULL;
01248 
01249   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01250   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
01251 
01252   //Add a scale function
01253   Handle(GEOM_Function) aFunction =
01254     theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
01255   if (aFunction.IsNull()) return NULL;
01256 
01257   //Check if the function is set correctly
01258   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
01259 
01260   // Set arguments
01261   GEOMImpl_IScale aTI (aFunction);
01262   aTI.SetShape(anOriginal);
01263   aTI.SetFactor(theFactor);
01264 
01265   // Set point argument
01266   if (!thePoint.IsNull()) {
01267     Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
01268     aTI.SetPoint(aPF);
01269   }
01270 
01271   //Compute the scale
01272   try {
01273 #if OCC_VERSION_LARGE > 0x06010000
01274     OCC_CATCH_SIGNALS;
01275 #endif
01276     if (!GetSolver()->ComputeFunction(aFunction)) {
01277       SetErrorCode("Scale driver failed");
01278       return NULL;
01279     }
01280   }
01281   catch (Standard_Failure) {
01282     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01283     SetErrorCode(aFail->GetMessageString());
01284     return NULL;
01285   }
01286 
01287   //Make a Python command
01288   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
01289     << theObject << ", " << thePoint << ", " << theFactor << ")";
01290 
01291   SetErrorCode(OK);
01292   return theObject;
01293 }
01294 
01295 //=============================================================================
01299 //=============================================================================
01300 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
01301        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
01302 {
01303   SetErrorCode(KO);
01304 
01305   if (theObject.IsNull()) return NULL;
01306 
01307   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01308   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
01309 
01310   //Add a new Copy object
01311   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01312 
01313   //Add a scale function
01314   Handle(GEOM_Function) aFunction =
01315     aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
01316   if (aFunction.IsNull()) return NULL;
01317 
01318   //Check if the function is set correctly
01319   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
01320 
01321   // Set arguments
01322   GEOMImpl_IScale aTI (aFunction);
01323   aTI.SetShape(anOriginal);
01324   aTI.SetFactor(theFactor);
01325 
01326   // Set point argument
01327   if (!thePoint.IsNull()) {
01328     Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
01329     aTI.SetPoint(aPF);
01330   }
01331 
01332   //Compute the scale
01333   try {
01334 #if OCC_VERSION_LARGE > 0x06010000
01335     OCC_CATCH_SIGNALS;
01336 #endif
01337     if (!GetSolver()->ComputeFunction(aFunction)) {
01338       SetErrorCode("Scale driver failed");
01339       return NULL;
01340     }
01341   }
01342   catch (Standard_Failure) {
01343     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01344     SetErrorCode(aFail->GetMessageString());
01345     return NULL;
01346   }
01347 
01348   //Make a Python command
01349   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
01350     << theObject << ", " << thePoint << ", " << theFactor << ")";
01351 
01352   SetErrorCode(OK);
01353   return aCopy;
01354 }
01355 
01356 //=============================================================================
01360 //=============================================================================
01361 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
01362                                                                         Handle(GEOM_Object) thePoint,
01363                                                                         double theFactorX,
01364                                                                         double theFactorY,
01365                                                                         double theFactorZ,
01366                                                                         bool   doCopy)
01367 {
01368   SetErrorCode(KO);
01369 
01370   if (theObject.IsNull()) return NULL;
01371 
01372   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01373   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
01374 
01375   //Add a scale function
01376   Handle(GEOM_Object) aCopy;   //Add a new Copy object
01377   Handle(GEOM_Function) aFunction;
01378   if (doCopy) {
01379     aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01380     aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
01381   }
01382   else {
01383     aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
01384   }
01385   if (aFunction.IsNull()) return NULL;
01386 
01387   //Check if the function is set correctly
01388   if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
01389 
01390   // Set arguments
01391   GEOMImpl_IScale aTI (aFunction);
01392   aTI.SetShape(anOriginal);
01393   aTI.SetFactorX(theFactorX);
01394   aTI.SetFactorY(theFactorY);
01395   aTI.SetFactorZ(theFactorZ);
01396 
01397   // Set point (optional argument)
01398   if (!thePoint.IsNull()) {
01399     Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
01400     aTI.SetPoint(aPF);
01401   }
01402 
01403   //Compute the scale
01404   try {
01405 #if OCC_VERSION_LARGE > 0x06010000
01406     OCC_CATCH_SIGNALS;
01407 #endif
01408     if (!GetSolver()->ComputeFunction(aFunction)) {
01409       SetErrorCode("Scale driver failed");
01410       return NULL;
01411     }
01412   }
01413   catch (Standard_Failure) {
01414     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01415     SetErrorCode(aFail->GetMessageString());
01416     return NULL;
01417   }
01418 
01419   SetErrorCode(OK);
01420 
01421   //Make a Python command
01422   if (doCopy) {
01423     GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
01424                                  << theObject << ", " << thePoint << ", "
01425                                  << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
01426     return aCopy;
01427   }
01428 
01429   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes("
01430                                << theObject << ", " << thePoint << ", "
01431                                << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
01432   return theObject;
01433 }
01434 
01435 //=============================================================================
01439 //=============================================================================
01440 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
01441         (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
01442 {
01443   SetErrorCode(KO);
01444 
01445   if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
01446 
01447   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01448   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
01449 
01450   //Add a Position function
01451   Standard_Integer aType = POSITION_SHAPE;
01452   if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
01453 
01454   Handle(GEOM_Function) aFunction =
01455     theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
01456   if (aFunction.IsNull()) return NULL;
01457 
01458   //Check if the function is set correctly
01459   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
01460 
01461   //Set operation arguments
01462   GEOMImpl_IPosition aTI (aFunction);
01463   aTI.SetShape(anOriginal);
01464   aTI.SetEndLCS(theEndLCS->GetLastFunction());
01465   if (!theStartLCS.IsNull())
01466     aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction());
01467 
01468   //Compute the Position
01469   try {
01470 #if OCC_VERSION_LARGE > 0x06010000
01471     OCC_CATCH_SIGNALS;
01472 #endif
01473     if (!GetSolver()->ComputeFunction(aFunction)) {
01474       SetErrorCode("Position driver failed");
01475       return NULL;
01476     }
01477   }
01478   catch (Standard_Failure) {
01479     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01480     SetErrorCode(aFail->GetMessageString());
01481     return NULL;
01482   }
01483 
01484   //Make a Python command
01485   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
01486     << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
01487 
01488   SetErrorCode(OK);
01489   return theObject;
01490 }
01491 
01492 //=============================================================================
01496 //=============================================================================
01497 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
01498        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
01499 {
01500   SetErrorCode(KO);
01501 
01502   if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
01503 
01504   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01505   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
01506 
01507   //Add a new Copy object
01508   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01509 
01510   //Add a position function
01511   Standard_Integer aType = POSITION_SHAPE_COPY;
01512   if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
01513 
01514   Handle(GEOM_Function) aFunction =
01515     aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
01516   if (aFunction.IsNull()) return NULL;
01517 
01518   //Check if the function is set correctly
01519   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
01520 
01521   GEOMImpl_IPosition aTI (aFunction);
01522   aTI.SetShape(anOriginal);
01523   aTI.SetEndLCS(theEndLCS->GetLastFunction());
01524   if (!theStartLCS.IsNull())
01525     aTI.SetStartLCS(theStartLCS->GetLastFunction());
01526 
01527   //Compute the position
01528   try {
01529 #if OCC_VERSION_LARGE > 0x06010000
01530     OCC_CATCH_SIGNALS;
01531 #endif
01532     if (!GetSolver()->ComputeFunction(aFunction)) {
01533       SetErrorCode("Position driver failed");
01534       return NULL;
01535     }
01536   }
01537   catch (Standard_Failure) {
01538     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01539     SetErrorCode(aFail->GetMessageString());
01540     return NULL;
01541   }
01542 
01543   //Make a Python command
01544   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
01545     << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
01546 
01547   SetErrorCode(OK);
01548   return aCopy;
01549 }
01550 
01551 //=============================================================================
01555 //=============================================================================
01556 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
01557        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
01558         double theDistance, bool theCopy, bool theReverse)
01559 {
01560   SetErrorCode(KO);
01561 
01562   if (theObject.IsNull() || thePath.IsNull()) return NULL;
01563 
01564   Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
01565   if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
01566 
01567   //Add a position function
01568   Handle(GEOM_Function) aFunction;
01569   Handle(GEOM_Object) aCopy;
01570 
01571   if (theCopy) {
01572     aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01573     aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
01574   }
01575   else
01576     aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
01577 
01578   if (aFunction.IsNull()) return NULL;
01579 
01580   //Check if the function is set correctly
01581   if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
01582 
01583   GEOMImpl_IPosition aTI (aFunction);
01584   aTI.SetShape(anOriginal);
01585   aTI.SetPath(thePath->GetLastFunction());
01586   aTI.SetDistance(theDistance);
01587   aTI.SetReverse(theReverse);
01588 
01589   //Compute the position
01590   try {
01591 #if OCC_VERSION_LARGE > 0x06010000
01592     OCC_CATCH_SIGNALS;
01593 #endif
01594     if (!GetSolver()->ComputeFunction(aFunction)) {
01595       SetErrorCode("Position driver failed");
01596       return NULL;
01597     }
01598   }
01599   catch (Standard_Failure) {
01600     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01601     SetErrorCode(aFail->GetMessageString());
01602     return NULL;
01603   }
01604 
01605   //Make a Python command
01606   if (theCopy) {
01607     GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath("
01608                                  << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
01609     SetErrorCode(OK);
01610     return aCopy;
01611   }
01612 
01613   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath("
01614     << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
01615 
01616   SetErrorCode(OK);
01617   return theObject;
01618 }
01619 
01620 //=============================================================================
01624 //=============================================================================
01625 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
01626                                                            Handle(GEOM_Object) theAxis,
01627                                                            double theAngle)
01628 {
01629   SetErrorCode(KO);
01630 
01631   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
01632 
01633   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
01634   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
01635 
01636   // Get last functions of the arguments
01637   Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
01638 
01639   //Add a rotate function
01640   aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
01641 
01642   if (aFunction.IsNull()) return NULL;
01643 
01644   //Check if the function is set correctly
01645   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
01646 
01647   GEOMImpl_IRotate aRI(aFunction);
01648   aRI.SetAxis(anAF);
01649   aRI.SetOriginal(aLastFunction);
01650   aRI.SetAngle(theAngle);
01651 
01652   //Compute the translation
01653   try {
01654 #if OCC_VERSION_LARGE > 0x06010000
01655     OCC_CATCH_SIGNALS;
01656 #endif
01657     if (!GetSolver()->ComputeFunction(aFunction)) {
01658       SetErrorCode("Rotate driver failed");
01659       return NULL;
01660     }
01661   }
01662   catch (Standard_Failure) {
01663     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01664     SetErrorCode(aFail->GetMessageString());
01665     return NULL;
01666   }
01667 
01668   //Make a Python command
01669   GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
01670     << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
01671 
01672   SetErrorCode(OK);
01673   return theObject;
01674 }
01675 
01676 //=============================================================================
01680 //=============================================================================
01681 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
01682 {
01683   SetErrorCode(KO);
01684 
01685   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
01686 
01687   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
01688   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
01689 
01690   //Add a new Copy object
01691   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01692 
01693   //Add a rotate function
01694   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
01695   if (aFunction.IsNull()) return NULL;
01696 
01697     //Check if the function is set correctly
01698   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
01699 
01700   GEOMImpl_IRotate aRI(aFunction);
01701   aRI.SetAxis(theAxis->GetLastFunction());
01702   aRI.SetOriginal(aLastFunction);
01703   aRI.SetAngle(theAngle);
01704 
01705   //Compute the translation
01706   try {
01707 #if OCC_VERSION_LARGE > 0x06010000
01708     OCC_CATCH_SIGNALS;
01709 #endif
01710     if (!GetSolver()->ComputeFunction(aFunction)) {
01711       SetErrorCode("Rotate driver failed");
01712       return NULL;
01713     }
01714   }
01715   catch (Standard_Failure) {
01716     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01717     SetErrorCode(aFail->GetMessageString());
01718     return NULL;
01719   }
01720 
01721   //Make a Python command
01722   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
01723     << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
01724 
01725   SetErrorCode(OK);
01726   return aCopy;
01727 }
01728 
01729 //=============================================================================
01733 //=============================================================================
01734 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
01735                                                              Handle(GEOM_Object) theAxis,
01736                                                              Standard_Integer theNbTimes)
01737 {
01738   SetErrorCode(KO);
01739 
01740   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
01741 
01742   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
01743   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
01744 
01745   //Add a new Copy object
01746   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01747 
01748   //Add a rotate function
01749   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
01750   if (aFunction.IsNull()) return NULL;
01751 
01752   //Check if the function is set correctly
01753   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
01754 
01755   GEOMImpl_IRotate aRI(aFunction);
01756   aRI.SetOriginal(aLastFunction);
01757   aRI.SetAxis(theAxis->GetLastFunction());
01758   aRI.SetNbIter1(theNbTimes);
01759 
01760   //Compute the translation
01761   try {
01762 #if OCC_VERSION_LARGE > 0x06010000
01763     OCC_CATCH_SIGNALS;
01764 #endif
01765     if (!GetSolver()->ComputeFunction(aFunction)) {
01766       SetErrorCode("Rotate driver failed");
01767       return NULL;
01768     }
01769   }
01770   catch (Standard_Failure) {
01771     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01772     SetErrorCode(aFail->GetMessageString());
01773     return NULL;
01774   }
01775 
01776   //Make a Python command
01777   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
01778     << theObject << ", " << theAxis << ", " << theNbTimes << ")";
01779 
01780   SetErrorCode(OK);
01781   return aCopy;
01782 }
01783 
01784 //=============================================================================
01788 //=============================================================================
01789 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
01790                                                              Handle(GEOM_Object) theAxis,
01791                                                              double theAngle,
01792                                                              Standard_Integer theNbTimes1,
01793                                                              double theStep,
01794                                                              Standard_Integer theNbTimes2)
01795 {
01796   SetErrorCode(KO);
01797 
01798   if (theObject.IsNull() || theAxis.IsNull()) return NULL;
01799 
01800   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
01801   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
01802 
01803   //Add a new Copy object
01804   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01805 
01806   //Add a rotate function
01807   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
01808   if (aFunction.IsNull()) return NULL;
01809 
01810     //Check if the function is set correctly
01811   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
01812 
01813   GEOMImpl_IRotate aRI(aFunction);
01814   aRI.SetAxis(theAxis->GetLastFunction());
01815   aRI.SetOriginal(aLastFunction);
01816   aRI.SetNbIter1(theNbTimes1);
01817   aRI.SetNbIter2(theNbTimes2);
01818   aRI.SetAngle(theAngle);
01819   aRI.SetStep(theStep);
01820 
01821   //Compute the translation
01822   try {
01823 #if OCC_VERSION_LARGE > 0x06010000
01824     OCC_CATCH_SIGNALS;
01825 #endif
01826     if (!GetSolver()->ComputeFunction(aFunction)) {
01827       SetErrorCode("Rotate driver failed");
01828       return NULL;
01829     }
01830   }
01831   catch (Standard_Failure) {
01832     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01833     SetErrorCode(aFail->GetMessageString());
01834     return NULL;
01835   }
01836 
01837   //Make a Python command
01838   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
01839     << theObject << ", " << theAxis << ", " << theAngle << ", "
01840       << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
01841 
01842   SetErrorCode(OK);
01843   return aCopy;
01844 }
01845 
01846 //=============================================================================
01850 //=============================================================================
01851 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
01852                                                                       Handle(GEOM_Object) theCentPoint,
01853                                                                       Handle(GEOM_Object) thePoint1,
01854                                                                       Handle(GEOM_Object) thePoint2)
01855 {
01856   SetErrorCode(KO);
01857 
01858   if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
01859 
01860   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
01861   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
01862 
01863   // Get last functions of the arguments
01864   Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
01865   Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
01866   Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
01867 
01868 
01869   //Add a rotate function
01870   aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
01871 
01872   if (aFunction.IsNull()) return NULL;
01873 
01874   //Check if the function is set correctly
01875   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
01876 
01877   GEOMImpl_IRotate aRI(aFunction);
01878   aRI.SetCentPoint(aCPF);
01879   aRI.SetPoint1(aP1F);
01880   aRI.SetPoint2(aP2F);
01881   aRI.SetOriginal(aLastFunction);
01882 
01883   //Compute the translation
01884   try {
01885 #if OCC_VERSION_LARGE > 0x06010000
01886     OCC_CATCH_SIGNALS;
01887 #endif
01888     if (!GetSolver()->ComputeFunction(aFunction)) {
01889       SetErrorCode("Rotate driver failed");
01890       return NULL;
01891     }
01892   }
01893   catch (Standard_Failure) {
01894     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01895     SetErrorCode(aFail->GetMessageString());
01896     return NULL;
01897   }
01898 
01899   //Make a Python command
01900   GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
01901                                << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
01902 
01903   SetErrorCode(OK);
01904   return theObject;
01905 }
01906 
01907 //=============================================================================
01911 //=============================================================================
01912 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
01913                                                          Handle(GEOM_Object) theCentPoint,
01914                                                          Handle(GEOM_Object) thePoint1,
01915                                                          Handle(GEOM_Object) thePoint2)
01916 {
01917   SetErrorCode(KO);
01918 
01919   if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
01920 
01921   Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
01922   if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
01923 
01924   //Add a new Copy object
01925   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01926 
01927   //Add a rotate function
01928   aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
01929   if (aFunction.IsNull()) return NULL;
01930 
01931     //Check if the function is set correctly
01932   if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
01933 
01934   GEOMImpl_IRotate aRI(aFunction);
01935   aRI.SetCentPoint(theCentPoint->GetLastFunction());
01936   aRI.SetPoint1(thePoint1->GetLastFunction());
01937   aRI.SetPoint2(thePoint2->GetLastFunction());
01938   aRI.SetOriginal(aLastFunction);
01939 
01940   //Compute the translation
01941   try {
01942 #if OCC_VERSION_LARGE > 0x06010000
01943     OCC_CATCH_SIGNALS;
01944 #endif
01945     if (!GetSolver()->ComputeFunction(aFunction)) {
01946       SetErrorCode("Rotate driver failed");
01947       return NULL;
01948     }
01949   }
01950   catch (Standard_Failure) {
01951     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01952     SetErrorCode(aFail->GetMessageString());
01953     return NULL;
01954   }
01955 
01956   //Make a Python command
01957   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
01958                                << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
01959 
01960   SetErrorCode(OK);
01961   return aCopy;
01962 }
01963 
01964 //=============================================================================
01968 //=============================================================================
01969 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
01970                                                 (Handle(GEOM_Object) theObject,
01971                                                  Handle(GEOM_Object) theSample)
01972 {
01973   SetErrorCode(KO);
01974 
01975   if (theObject.IsNull() || theSample.IsNull()) return NULL;
01976 
01977   Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
01978   if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
01979 
01980   Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
01981   if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
01982 
01983   // Add a new Copy object
01984   Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
01985 
01986   // Add a transform function (depends on theSample function)
01987   Handle(GEOM_Function) aFunction =
01988     aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
01989   if (aFunction.IsNull()) return NULL;
01990 
01991   // Check if the function is set correctly
01992   if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
01993 
01994   if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
01995     switch (aSampleFunc->GetType()) {
01996     case TRANSLATE_1D:
01997       {
01998         GEOMImpl_ITranslate aRI_sample (aSampleFunc);
01999         GEOMImpl_ITranslate aRI_target (aFunction);
02000 
02001         aRI_target.SetVector(aRI_sample.GetVector());
02002         aRI_target.SetStep1(aRI_sample.GetStep1());
02003         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
02004 
02005         aRI_target.SetOriginal(aLastFunction);
02006       }
02007       break;
02008     case TRANSLATE_2D:
02009       {
02010         GEOMImpl_ITranslate aRI_sample (aSampleFunc);
02011         GEOMImpl_ITranslate aRI_target (aFunction);
02012 
02013         aRI_target.SetVector(aRI_sample.GetVector());
02014         aRI_target.SetStep1(aRI_sample.GetStep1());
02015         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
02016 
02017         aRI_target.SetVector2(aRI_sample.GetVector2());
02018         aRI_target.SetStep2(aRI_sample.GetStep2());
02019         aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
02020 
02021         aRI_target.SetOriginal(aLastFunction);
02022       }
02023       break;
02024     default:
02025       {
02026         SetErrorCode("Not implemented case of TransformLikeOtherCopy");
02027         return NULL;
02028       }
02029     }
02030   }
02031   else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
02032     switch (aSampleFunc->GetType()) {
02033     case ROTATE_1D:
02034       {
02035         GEOMImpl_IRotate aRI_sample (aSampleFunc);
02036         GEOMImpl_IRotate aRI_target (aFunction);
02037 
02038         aRI_target.SetAxis(aRI_sample.GetAxis());
02039         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
02040 
02041         aRI_target.SetOriginal(aLastFunction);
02042       }
02043       break;
02044     case ROTATE_2D:
02045       {
02046         GEOMImpl_IRotate aRI_sample (aSampleFunc);
02047         GEOMImpl_IRotate aRI_target (aFunction);
02048 
02049         aRI_target.SetAxis(aRI_sample.GetAxis());
02050 
02051         aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
02052         aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
02053 
02054         aRI_target.SetAngle(aRI_sample.GetAngle());
02055         aRI_target.SetStep(aRI_sample.GetStep());
02056 
02057         aRI_target.SetDir2(aRI_sample.GetDir2());
02058 
02059         aRI_target.SetOriginal(aLastFunction);
02060       }
02061       break;
02062     case ROTATE_THREE_POINTS_COPY:
02063       {
02064         GEOMImpl_IRotate aRI_sample (aSampleFunc);
02065         GEOMImpl_IRotate aRI_target (aFunction);
02066 
02067         aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
02068         aRI_target.SetPoint1(aRI_sample.GetPoint1());
02069         aRI_target.SetPoint2(aRI_sample.GetPoint2());
02070 
02071         aRI_target.SetOriginal(aLastFunction);
02072       }
02073       break;
02074     default:
02075       {
02076         SetErrorCode("Not implemented case of TransformLikeOtherCopy");
02077         return NULL;
02078       }
02079     }
02080   }
02081   else {
02082     SetErrorCode("Not implemented case of TransformLikeOtherCopy");
02083     return NULL;
02084   }
02085 
02086   // Compute the transformation
02087   try {
02088 #if OCC_VERSION_LARGE > 0x06010000
02089     OCC_CATCH_SIGNALS;
02090 #endif
02091     if (!GetSolver()->ComputeFunction(aFunction)) {
02092       SetErrorCode("Driver failed");
02093       return NULL;
02094     }
02095   }
02096   catch (Standard_Failure) {
02097     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
02098     SetErrorCode(aFail->GetMessageString());
02099     return NULL;
02100   }
02101 
02102   //Make a Python command
02103   //GEOM::TPythonDump(aFunction) << aCopy << " = geompy.TransformLikeOtherCopy("
02104   //                             << theObject << ", " << theSample << ")";
02105 
02106   SetErrorCode(OK);
02107   return aCopy;
02108 }