X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_ICurvesOperations.cxx;h=463af06e3fa0364dd257c3a9334dba63bc152d52;hb=3059f9d5521dd7c91c35c50afbd6beb18b8826fd;hp=b977e80b906789289d56ec2c4390a0085910780a;hpb=e2dcf4323c7d7c36e8e1a4fda4dd6cf86c99be81;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index b977e80b9..463af06e3 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -1,7 +1,31 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 +#include + #include #include @@ -13,6 +37,7 @@ #include #include #include +#include #include #include @@ -20,11 +45,13 @@ #include #include #include +#include #include "utilities.h" #include +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -54,7 +81,7 @@ GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations() * MakePolyline */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list thePoints) +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list thePoints) { SetErrorCode(KO); @@ -75,7 +102,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list::iterator it = thePoints.begin(); + std::list::iterator it = thePoints.begin(); for (; it != thePoints.end(); it++, ind++) { Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); if (aRefPnt.IsNull()) { @@ -87,6 +114,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Polyline driver failed"); return NULL; @@ -151,6 +181,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_ //Compute the Circle value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Circle driver failed"); return NULL; @@ -170,6 +203,66 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_ return aCircle; } +//============================================================================= +/*! + * MakeCircleCenter2Pnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleCenter2Pnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle object + Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE); + + //Add a new Circle function for creation a circle relatively to center and 2 points + Handle(GEOM_Function) aFunction = + aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_CENTER_TWO_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL; + + GEOMImpl_ICircle aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Circle value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Circle 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) << aCircle << " = geompy.MakeCircleCenter2Pnt(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; + + SetErrorCode(OK); + return aCircle; +} + //============================================================================= /*! * MakeCirclePntVecR @@ -180,7 +273,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR { SetErrorCode(KO); - if (thePnt.IsNull() || theVec.IsNull()) return NULL; + // Not set thePnt means origin of global CS, + // Not set theVec means Z axis of global CS + //if (thePnt.IsNull() || theVec.IsNull()) return NULL; //Add a new Circle object Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE); @@ -195,17 +290,25 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR GEOMImpl_ICircle aCI (aFunction); - Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); - Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + if (!thePnt.IsNull()) { + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + if (aRefPnt.IsNull()) return NULL; + aCI.SetCenter(aRefPnt); + } - if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + if (!theVec.IsNull()) { + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + if (aRefVec.IsNull()) return NULL; + aCI.SetVector(aRefVec); + } - aCI.SetCenter(aRefPnt); - aCI.SetVector(aRefVec); aCI.SetRadius(theR); //Compute the Circle value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Circle driver failed"); return NULL; @@ -232,11 +335,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR //============================================================================= Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, - double theRMajor, double theRMinor) + double theRMajor, double theRMinor, + Handle(GEOM_Object) theVecMaj) { SetErrorCode(KO); - if (thePnt.IsNull() || theVec.IsNull()) return NULL; + // Not set thePnt means origin of global CS, + // Not set theVec means Z axis of global CS + // Not set theVecMaj means X axis of global CS + //if (thePnt.IsNull() || theVec.IsNull()) return NULL; //Add a new Ellipse object Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE); @@ -251,18 +358,32 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse GEOMImpl_IEllipse aCI (aFunction); - Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); - Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + if (!thePnt.IsNull()) { + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + if (aRefPnt.IsNull()) return NULL; + aCI.SetCenter(aRefPnt); + } - if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + if (!theVec.IsNull()) { + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + if (aRefVec.IsNull()) return NULL; + aCI.SetVector(aRefVec); + } - aCI.SetCenter(aRefPnt); - aCI.SetVector(aRefVec); aCI.SetRMajor(theRMajor); aCI.SetRMinor(theRMinor); + if (!theVecMaj.IsNull()) { + Handle(GEOM_Function) aRefVecMaj = theVecMaj->GetLastFunction(); + if (aRefVecMaj.IsNull()) return NULL; + aCI.SetVectorMajor(aRefVecMaj); + } + //Compute the Ellipse value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Ellipse driver failed"); return NULL; @@ -275,8 +396,15 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse } //Make a Python command - GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse(" - << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")"; + if (!theVecMaj.IsNull()) { + GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse(" + << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor + << ", " << theVecMaj << ")"; + } + else { + GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeEllipse(" + << thePnt << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")"; + } SetErrorCode(OK); return anEll; @@ -300,7 +428,68 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the //Add a new Circle Arc function Handle(GEOM_Function) aFunction = - anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT); + anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL; + GEOMImpl_IArc aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Arc value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Arc 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) << anArc << " = geompy.MakeArc(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; + + SetErrorCode(OK); + return anArc; +} + +//============================================================================= +/*! + * MakeArcCenter + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcCenter (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3, + bool theSense) +{ + SetErrorCode(KO); + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle Arc object + Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC); + + //Add a new Circle Arc function + Handle(GEOM_Function) aFunction = + anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_CENTER); if (aFunction.IsNull()) return NULL; //Check if the function is set correctly @@ -317,9 +506,73 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the aCI.SetPoint1(aRefPnt1); aCI.SetPoint2(aRefPnt2); aCI.SetPoint3(aRefPnt3); + aCI.SetSense(theSense); + + //Compute the Arc value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Arc 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) << anArc << " = geompy.MakeArcCenter(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << "," << theSense << ")"; + + SetErrorCode(OK); + return anArc; +} + +//============================================================================= +/*! + * MakeArcOfEllipse + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle Arc object + Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE_ARC); + + //Add a new Circle Arc function + Handle(GEOM_Function) aFunction = + anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), ELLIPSE_ARC_CENTER_TWO_PNT); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL; + GEOMImpl_IArc aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + //Compute the Arc value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Arc driver failed"); return NULL; @@ -332,7 +585,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the } //Make a Python command - GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArc(" + GEOM::TPythonDump(aFunction) << anArc << " = geompy.MakeArcOfEllipse(" << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; SetErrorCode(OK); @@ -345,7 +598,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) the */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier - (list thePoints) + (std::list thePoints) { SetErrorCode(KO); @@ -366,7 +619,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier aCI.SetLength(aLen); int ind = 1; - list::iterator it = thePoints.begin(); + std::list::iterator it = thePoints.begin(); for (; it != thePoints.end(); it++, ind++) { Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); @@ -377,6 +630,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier //Compute the Spline value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Spline driver failed"); return NULL; @@ -409,7 +665,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation - (list thePoints) + (std::list thePoints, + bool theIsClosed) { SetErrorCode(KO); @@ -430,7 +687,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation aCI.SetLength(aLen); int ind = 1; - list::iterator it = thePoints.begin(); + std::list::iterator it = thePoints.begin(); for (; it != thePoints.end(); it++, ind++) { Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); @@ -439,8 +696,13 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation aCI.SetPoint(ind, aRefPnt); } + aCI.SetIsClosed(theIsClosed); + //Compute the Spline value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Spline driver failed"); return NULL; @@ -461,7 +723,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation while (it != thePoints.end()) { pd << ", " << (*it++); } - pd << "])"; + pd << "]"; + if ( theIsClosed ) pd << ", True"; + pd << ")"; SetErrorCode(OK); return aSpline; @@ -473,12 +737,11 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand, - list theWorkingPlane) + std::list theWorkingPlane) { SetErrorCode(KO); - if (!theCommand) return NULL; - if (strcmp(theCommand, "") == 0) return NULL; + if (!theCommand || strcmp(theCommand, "") == 0) return NULL; //Add a new Sketcher object Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); @@ -493,16 +756,19 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom GEOMImpl_ISketcher aCI (aFunction); - TCollection_AsciiString aCommand ((char*) theCommand); + TCollection_AsciiString aCommand((char*) theCommand); aCI.SetCommand(aCommand); int ind = 1; - list::iterator it = theWorkingPlane.begin(); + std::list::iterator it = theWorkingPlane.begin(); for (; it != theWorkingPlane.end(); it++, ind++) aCI.SetWorkingPlane(ind, *it); //Compute the Sketcher value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Sketcher driver failed"); return NULL; @@ -516,7 +782,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom //Make a Python command GEOM::TPythonDump pd (aFunction); - pd << aSketcher << " = geompy.MakeSketcher(\"" << theCommand << "\", ["; + pd << aSketcher << " = geompy.MakeSketcher(\"" << aCommand.ToCString() << "\", ["; it = theWorkingPlane.begin(); pd << (*it++); @@ -529,18 +795,85 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom return aSketcher; } +//============================================================================= +/*! + * Make3DSketcher + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list theCoordinates) +{ + SetErrorCode(KO); + + //Add a new Sketcher object + Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER); + + //Add a new Sketcher function + Handle(GEOM_Function) aFunction = + a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL; + + GEOMImpl_I3DSketcher aCI (aFunction); + + int nbOfCoords = 0; + std::list::iterator it = theCoordinates.begin(); + for (; it != theCoordinates.end(); it++) + nbOfCoords++; + + Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords); + + it = theCoordinates.begin(); + int ind = 1; + for (; it != theCoordinates.end(); it++, ind++) + aCoordsArray->SetValue(ind, *it); + + aCI.SetCoordinates(aCoordsArray); + + //Compute the Sketcher value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("3D Sketcher 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 << a3DSketcher << " = geompy.Make3DSketcher(["; + + it = theCoordinates.begin(); + pd << (*it++); + while (it != theCoordinates.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return a3DSketcher; +} + //============================================================================= /*! * MakeSketcherOnPlane */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* theCommand, - Handle(GEOM_Object) theWorkingPlane) +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane + (const char* theCommand, + Handle(GEOM_Object) theWorkingPlane) { SetErrorCode(KO); - if (!theCommand) return NULL; - if (strcmp(theCommand, "") == 0) return NULL; + if (!theCommand || strcmp(theCommand, "") == 0) return NULL; //Add a new Sketcher object Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); @@ -555,7 +888,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* GEOMImpl_ISketcher aCI (aFunction); - TCollection_AsciiString aCommand ((char*) theCommand); + TCollection_AsciiString aCommand((char*) theCommand); aCI.SetCommand(aCommand); Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction(); @@ -564,6 +897,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* //Compute the Sketcher value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Sketcher driver failed"); return NULL; @@ -577,7 +913,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane (const char* //Make a Python command GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\"" - << theCommand << "\", " << theWorkingPlane << " )"; + << aCommand.ToCString() << "\", " << theWorkingPlane << " )"; SetErrorCode(OK); return aSketcher;