X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_ILocalOperations.cxx;h=2ec4e5e397e89baef23af36cabb8831a5d4ea966;hb=e7e908bf4c7c8bec141fe2d3b4a9924ddaea6c04;hp=483979d7e00fb740a52c1895730c6bd4dd93f785;hpb=e180c20f73ffa96c2d039106f2a2a868c8bc0df1;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx index 483979d7e..2ec4e5e39 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -15,8 +15,11 @@ // 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/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +using namespace std; + #include #include @@ -51,6 +54,7 @@ #include #include +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -106,6 +110,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll //Compute the Fillet value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -164,6 +171,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges //Compute the Fillet value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -191,6 +201,77 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges return aFillet; } +//============================================================================= +/*! + * MakeFilletEdges R1 R2 + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2 + (Handle(GEOM_Object) theShape, double theR1, double theR2, list theEdges) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL; + + GEOMImpl_IFillet aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR1(theR1); + aCI.SetR2(theR2); + int aLen = theEdges.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theEdges.begin(); + for (; it != theEdges.end(); it++, ind++) { + aCI.SetEdge(ind, (*it)); + } + + //Compute the Fillet value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fillet 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 pd (aFunction); + pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape + << ", " << theR1 << ", " < 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Fillet driver failed"); return NULL; @@ -257,6 +341,76 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces return aFillet; } +//============================================================================= +/*! + * MakeFilletFaces R1 R2 + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2 + (Handle(GEOM_Object) theShape, double theR1, double theR2, list theFaces) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL; + + GEOMImpl_IFillet aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR1(theR1); + aCI.SetR2(theR2); + int aLen = theFaces.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theFaces.begin(); + for (; it != theFaces.end(); it++, ind++) { + aCI.SetFace(ind, (*it)); + } + + //Compute the Fillet value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fillet 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 pd (aFunction); + pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape + << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], ["; + + it = theFaces.begin(); + pd << (*it++); + while (it != theFaces.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aFillet; +} + //============================================================================= /*! * MakeChamferAll @@ -287,6 +441,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Objec //Compute the Chamfer value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -341,6 +498,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge //Compute the Chamfer value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -361,6 +521,63 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge return aChamfer; } +//============================================================================= +/*! + * MakeChamferEdgeAD + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD + (Handle(GEOM_Object) theShape, double theD, double theAngle, + int theFace1, int theFace2) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL; + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetD(theD); + aCI.SetAngle(theAngle); + aCI.SetFace1(theFace1); + aCI.SetFace2(theFace2); + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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) << aChamfer + << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD + << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")"; + SetErrorCode(OK); + return aChamfer; +} + //============================================================================= /*! * MakeChamferFaces @@ -402,6 +619,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces //Compute the Chamfer value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Chamfer driver failed"); return NULL; @@ -429,6 +649,221 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces return aChamfer; } +//============================================================================= +/*! + * MakeChamferFacesAD + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD + (Handle(GEOM_Object) theShape, double theD, double theAngle, + list theFaces) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL; + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetD(theD); + aCI.SetAngle(theAngle); + int aLen = theFaces.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theFaces.begin(); + for (; it != theFaces.end(); it++, ind++) { + aCI.SetFace(ind, (*it)); + } + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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 pd (aFunction); + pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape + << ", " << theD << ", " << theAngle << ", ["; + + it = theFaces.begin(); + pd << (*it++); + while (it != theFaces.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * MakeChamferEdges + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges + (Handle(GEOM_Object) theShape, double theD1, double theD2, + list theEdges) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES); + if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; } + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) + { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; } + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; } + + aCI.SetShape(aRefShape); + aCI.SetD1(theD1); + aCI.SetD2(theD2); + int aLen = theEdges.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theEdges.begin(); + for (; it != theEdges.end(); it++, ind++) { + aCI.SetEdge(ind, (*it)); + } + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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 pd (aFunction); + pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape + << ", " << theD1 << ", " << theD2 << ", ["; + + it = theEdges.begin(); + pd << (*it++); + while (it != theEdges.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * MakeChamferEdgesAD + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD + (Handle(GEOM_Object) theShape, double theD, double theAngle, + list theEdges) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD); + if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; } + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) + { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; } + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; } + + aCI.SetShape(aRefShape); + aCI.SetD(theD); + aCI.SetAngle(theAngle); + int aLen = theEdges.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theEdges.begin(); + for (; it != theEdges.end(); it++, ind++) { + aCI.SetEdge(ind, (*it)); + } + + //Compute the Chamfer value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer 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 pd (aFunction); + pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape + << ", " << theD << ", " << theAngle << ", ["; + + it = theEdges.begin(); + pd << (*it++); + while (it != theEdges.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aChamfer; +} + //============================================================================= /*! * Archimede @@ -463,6 +898,9 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object //Compute the Archimede value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Archimede driver failed"); return NULL;