X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_ICurvesOperations.cxx;h=3d53948c382bdace1eaa0ba7e56eb43e4810d7af;hb=c86487eae575fa5d5253fea29197e5741e180aff;hp=364c16c2354f96bdffafd861494840ae68ed9d80;hpb=0b6826bc5f36b5420f41af1475e1a79371a25323;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 364c16c23..3d53948c3 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// 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 @@ -18,7 +18,7 @@ // 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 @@ -75,73 +75,6 @@ GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations() } -//============================================================================= -/*! - * MakePolyline - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list thePoints) -{ - SetErrorCode(KO); - - //Add a new Polyline object - Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE); - - //Add a new Polyline function for creation a polyline relatively to points set - Handle(GEOM_Function) aFunction = - aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL; - - GEOMImpl_IPolyline aCI (aFunction); - - int aLen = thePoints.size(); - aCI.SetLength(aLen); - - int ind = 1; - list::iterator it = thePoints.begin(); - for (; it != thePoints.end(); it++, ind++) { - Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); - if (aRefPnt.IsNull()) { - SetErrorCode("NULL point for Polyline"); - return NULL; - } - aCI.SetPoint(ind, aRefPnt); - } - - //Compute the Polyline value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Polyline 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 << aPolyline << " = geompy.MakePolyline(["; - - it = thePoints.begin(); - pd << (*it++); - while (it != thePoints.end()) { - pd << ", " << (*it++); - } - pd << "])"; - - SetErrorCode(OK); - return aPolyline; -} - //============================================================================= /*! * MakeCircleThreePnt @@ -591,13 +524,84 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArcOfEllipse (Handle(GEOM_Ob return anArc; } +//============================================================================= +/*! + * MakePolyline + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (std::list thePoints, + bool theIsClosed) +{ + SetErrorCode(KO); + + //Add a new Polyline object + Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE); + + //Add a new Polyline function for creation a polyline relatively to points set + Handle(GEOM_Function) aFunction = + aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL; + + GEOMImpl_IPolyline aCI (aFunction); + + int aLen = thePoints.size(); + aCI.SetLength(aLen); + + int ind = 1; + std::list::iterator it = thePoints.begin(); + for (; it != thePoints.end(); it++, ind++) { + Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); + if (aRefPnt.IsNull()) { + SetErrorCode("NULL point for Polyline"); + return NULL; + } + aCI.SetPoint(ind, aRefPnt); + } + + aCI.SetIsClosed(theIsClosed); + + //Compute the Polyline value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Polyline 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 << aPolyline << " = geompy.MakePolyline(["; + + it = thePoints.begin(); + pd << (*it++); + while (it != thePoints.end()) { + pd << ", " << (*it++); + } + pd << "], " << theIsClosed << ")"; + + SetErrorCode(OK); + return aPolyline; +} + //============================================================================= /*! * MakeSplineBezier */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier - (list thePoints) + (std::list thePoints, + bool theIsClosed) { SetErrorCode(KO); @@ -618,7 +622,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(); @@ -627,6 +631,8 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier 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 @@ -652,7 +658,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier while (it != thePoints.end()) { pd << ", " << (*it++); } - pd << "])"; + pd << "], " << theIsClosed << ")"; SetErrorCode(OK); return aSpline; @@ -664,8 +670,9 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation - (list thePoints, - bool theIsClosed) + (std::list thePoints, + bool theIsClosed, + bool theDoReordering) { SetErrorCode(KO); @@ -686,7 +693,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(); @@ -696,6 +703,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation } aCI.SetIsClosed(theIsClosed); + aCI.SetDoReordering(theDoReordering); //Compute the Spline value try { @@ -722,7 +730,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation while (it != thePoints.end()) { pd << ", " << (*it++); } - pd << "])"; + pd << "], " << theIsClosed << ", " << theDoReordering << ")"; SetErrorCode(OK); return aSpline; @@ -734,7 +742,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand, - list theWorkingPlane) + std::list theWorkingPlane) { SetErrorCode(KO); @@ -757,7 +765,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom 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); @@ -797,7 +805,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom * Make3DSketcher */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list theCoordinates) +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list theCoordinates) { SetErrorCode(KO); @@ -815,7 +823,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (list the GEOMImpl_I3DSketcher aCI (aFunction); int nbOfCoords = 0; - list::iterator it = theCoordinates.begin(); + std::list::iterator it = theCoordinates.begin(); for (; it != theCoordinates.end(); it++) nbOfCoords++;