X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_ITransformOperations.cxx;h=42ab3f44fd3d07f68be91a2b5279a34f585cab95;hb=3059f9d5521dd7c91c35c50afbd6beb18b8826fd;hp=16885bcc36efc03f0a3af45301baa4968cf9e7fc;hpb=a62a321c849518376e3aa4d24a0b902a24167c64;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 16885bcc3..42ab3f44f 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -1,22 +1,25 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// See http://www.salome-platform.org/ +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + #include #include @@ -49,6 +52,7 @@ #include +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -109,6 +113,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -159,6 +166,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -171,7 +181,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateDXDYDZ(" + GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ(" << theObject << ", " << theX << ", " << theY << ", " << theZ << ")"; SetErrorCode(OK); @@ -212,6 +222,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -264,6 +277,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -316,6 +332,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -334,7 +353,6 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector SetErrorCode(OK); return theObject; } - //============================================================================= /*! * TranslateVectorCopy @@ -367,6 +385,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -386,6 +407,73 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy return aCopy; } +//============================================================================= +/*! + * TranslateVectorDistance + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theVector.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + Handle(GEOM_Object) aCopy; //Add a new Copy object + Handle(GEOM_Function) aFunction; + + //Add a translate function + if (theCopy) { + aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE); + } + else { + aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE); + } + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI(aFunction); + aTI.SetVector(theVector->GetLastFunction()); + aTI.SetDistance(theDistance); +// aTI.SetShape(theObject->GetValue()); + aTI.SetOriginal(aLastFunction); + + //Compute the translation + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + if (theCopy) { + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance(" + << theObject << ", " << theVector << ", " << theDistance << ")"; + SetErrorCode(OK); + return aCopy; + } + + GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance(" + << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")"; + SetErrorCode(OK); + return theObject; +} + //============================================================================= /*! * Translate1D @@ -420,6 +508,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -445,12 +536,12 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject, - Handle(GEOM_Object) theVector, - double theStep1, - Standard_Integer theNbTimes1, - Handle(GEOM_Object) theVector2, - double theStep2, - Standard_Integer theNbTimes2) + Handle(GEOM_Object) theVector, + double theStep1, + Standard_Integer theNbTimes1, + Handle(GEOM_Object) theVector2, + double theStep2, + Standard_Integer theNbTimes2) { SetErrorCode(KO); @@ -480,6 +571,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Obje //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -533,6 +627,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane //Compute the mirror try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -583,6 +680,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy //Compute the mirror try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -634,6 +734,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint //Compute the mirror try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -684,6 +787,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy //Compute the mirror try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -735,6 +841,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis //Compute the mirror try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -785,6 +894,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy //Compute the mirror try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -834,6 +946,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape //Compute the offset try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Offset driver failed"); return NULL; @@ -885,6 +1000,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy //Compute the offset try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Offset driver failed"); return NULL; @@ -915,14 +1033,11 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape { SetErrorCode(KO); - if (theObject.IsNull() || thePoint.IsNull()) return NULL; + if (theObject.IsNull()) return NULL; Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled - // Get last functions of the arguments - Handle(GEOM_Function) aPF = thePoint->GetLastFunction(); - //Add a scale function Handle(GEOM_Function) aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE); @@ -931,13 +1046,22 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL; + // Set arguments GEOMImpl_IScale aTI (aFunction); aTI.SetShape(anOriginal); - aTI.SetPoint(aPF); aTI.SetFactor(theFactor); + // Set point argument + if (!thePoint.IsNull()) { + Handle(GEOM_Function) aPF = thePoint->GetLastFunction(); + aTI.SetPoint(aPF); + } + //Compute the scale try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -967,7 +1091,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy { SetErrorCode(KO); - if (theObject.IsNull() || thePoint.IsNull()) return NULL; + if (theObject.IsNull()) return NULL; Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled @@ -983,13 +1107,22 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL; + // Set arguments GEOMImpl_IScale aTI (aFunction); aTI.SetShape(anOriginal); - aTI.SetPoint(thePoint->GetLastFunction()); aTI.SetFactor(theFactor); + // Set point argument + if (!thePoint.IsNull()) { + Handle(GEOM_Function) aPF = thePoint->GetLastFunction(); + aTI.SetPoint(aPF); + } + //Compute the scale try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -1009,6 +1142,85 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy return aCopy; } +//============================================================================= +/*! + * ScaleShapeAlongAxes + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePoint, + double theFactorX, + double theFactorY, + double theFactorZ, + bool doCopy) +{ + SetErrorCode(KO); + + if (theObject.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled + + //Add a scale function + Handle(GEOM_Object) aCopy; //Add a new Copy object + Handle(GEOM_Function) aFunction; + if (doCopy) { + aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY); + } + else { + aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES); + } + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL; + + // Set arguments + GEOMImpl_IScale aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetFactorX(theFactorX); + aTI.SetFactorY(theFactorY); + aTI.SetFactorZ(theFactorZ); + + // Set point (optional argument) + if (!thePoint.IsNull()) { + Handle(GEOM_Function) aPF = thePoint->GetLastFunction(); + aTI.SetPoint(aPF); + } + + //Compute the scale + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Scale driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + SetErrorCode(OK); + + //Make a Python command + if (doCopy) { + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes(" + << theObject << ", " << thePoint << ", " + << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")"; + return aCopy; + } + + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes(" + << theObject << ", " << thePoint << ", " + << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")"; + return theObject; +} + //============================================================================= /*! * PositionShape @@ -1019,30 +1231,34 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape { SetErrorCode(KO); - if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL; + if (theObject.IsNull() || theEndLCS.IsNull()) return NULL; Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position - // Get last functions of the arguments - Handle(GEOM_Function) aStartLCS = theStartLCS->GetLastFunction(); - Handle(GEOM_Function) aEndLCS = theEndLCS->GetLastFunction(); - //Add a Position function + Standard_Integer aType = POSITION_SHAPE; + if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL; + Handle(GEOM_Function) aFunction = - theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE); + theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL; + //Set operation arguments GEOMImpl_IPosition aTI (aFunction); aTI.SetShape(anOriginal); - aTI.SetStartLCS(aStartLCS); - aTI.SetEndLCS(aEndLCS); + aTI.SetEndLCS(theEndLCS->GetLastFunction()); + if (!theStartLCS.IsNull()) + aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction()); //Compute the Position try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1072,7 +1288,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy { SetErrorCode(KO); - if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL; + if (theObject.IsNull() || theEndLCS.IsNull()) return NULL; Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position @@ -1081,8 +1297,11 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); //Add a position function + Standard_Integer aType = POSITION_SHAPE_COPY; + if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY; + Handle(GEOM_Function) aFunction = - aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE_COPY); + aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly @@ -1090,11 +1309,15 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy GEOMImpl_IPosition aTI (aFunction); aTI.SetShape(anOriginal); - aTI.SetStartLCS(theStartLCS->GetLastFunction()); aTI.SetEndLCS(theEndLCS->GetLastFunction()); + if (!theStartLCS.IsNull()) + aTI.SetStartLCS(theStartLCS->GetLastFunction()); //Compute the position try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1114,6 +1337,75 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy return aCopy; } +//============================================================================= +/*! + * PositionAlongPath + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath, + double theDistance, bool theCopy, bool theReverse) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePath.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position + + //Add a position function + Handle(GEOM_Function) aFunction; + Handle(GEOM_Object) aCopy; + + if (theCopy) { + aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH); + } + else + aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL; + + GEOMImpl_IPosition aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetPath(thePath->GetLastFunction()); + aTI.SetDistance(theDistance); + aTI.SetReverse(theReverse); + + //Compute the position + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Position driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + if (theCopy) { + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath(" + << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")"; + SetErrorCode(OK); + return aCopy; + } + + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath(" + << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")"; + + SetErrorCode(OK); + return theObject; +} + //============================================================================= /*! * Rotate @@ -1148,6 +1440,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1160,7 +1455,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject + GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; SetErrorCode(OK); @@ -1198,6 +1493,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Objec //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1250,6 +1548,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1275,11 +1576,11 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject, - Handle(GEOM_Object) theAxis, - double theAngle, - Standard_Integer theNbTimes1, - double theStep, - Standard_Integer theNbTimes2) + Handle(GEOM_Object) theAxis, + double theAngle, + Standard_Integer theNbTimes1, + double theStep, + Standard_Integer theNbTimes2) { SetErrorCode(KO); @@ -1308,6 +1609,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) //Compute the translation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1327,3 +1631,122 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) SetErrorCode(OK); return aCopy; } + +//============================================================================= +/*! + * RotateThreePoints + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theCentPoint, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated + + // Get last functions of the arguments + Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction(); + Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction(); + Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction(); + + + //Add a rotate function + aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; + + GEOMImpl_IRotate aRI(aFunction); + aRI.SetCentPoint(aCPF); + aRI.SetPoint1(aP1F); + aRI.SetPoint2(aP2F); + aRI.SetOriginal(aLastFunction); + + //Compute the translation + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Rotate driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject + << ", " << theCentPoint << ", "<GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a rotate function + aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; + + GEOMImpl_IRotate aRI(aFunction); + aRI.SetCentPoint(theCentPoint->GetLastFunction()); + aRI.SetPoint1(thePoint1->GetLastFunction()); + aRI.SetPoint2(thePoint2->GetLastFunction()); + aRI.SetOriginal(aLastFunction); + + //Compute the translation + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Rotate driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject + << ", " << theCentPoint << ", "<