From bf697caef875e7942d04ab93e4558c6e3b56b12c Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 6 Jan 2011 21:40:34 +0000 Subject: [PATCH] Small change of the interface for MakeVertexOnCurveByLength function: use boolean flag for the direction parameter instead of double --- doc/salome/gui/GEOM/input/creating_point.doc | 5 +++-- .../gui/GEOM/input/tui_basic_geom_objs.doc | 2 +- idl/GEOM_Gen.idl | 4 ++-- src/BasicGUI/BasicGUI_PointDlg.cxx | 10 +++------- src/BasicGUI/BasicGUI_PointDlg.h | 2 -- src/GEOMImpl/GEOMImpl_IBasicOperations.cxx | 20 +++++++++---------- src/GEOMImpl/GEOMImpl_IBasicOperations.hxx | 6 +++--- src/GEOMImpl/GEOMImpl_IPoint.hxx | 4 ++-- src/GEOMImpl/GEOMImpl_PointDriver.cxx | 8 ++------ src/GEOM_I/GEOM_IBasicOperations_i.cc | 4 ++-- src/GEOM_I/GEOM_IBasicOperations_i.hh | 4 ++-- src/GEOM_I_Superv/GEOM_Superv_i.cc | 4 ++-- src/GEOM_I_Superv/GEOM_Superv_i.hh | 2 +- src/GEOM_SWIG/GEOM_TestAll.py | 2 +- src/GEOM_SWIG/geompyDC.py | 6 +++--- 15 files changed, 37 insertions(+), 46 deletions(-) diff --git a/doc/salome/gui/GEOM/input/creating_point.doc b/doc/salome/gui/GEOM/input/creating_point.doc index 2ae82dc92..295e3ede1 100644 --- a/doc/salome/gui/GEOM/input/creating_point.doc +++ b/doc/salome/gui/GEOM/input/creating_point.doc @@ -35,9 +35,10 @@ position of the point on the given edge. Alternatively, it is possible to define the point by \b Edge and \b Length, the given length must not exceed the length of the edge. The orientation of the edge can be reversed. -\n TUI Command: geompy.MakeVertexOnCurveByLength(Edge,Length,Direction). +\n TUI Command: geompy.MakeVertexOnCurveByLength(Edge,Length,Reverse). \n Arguments: Name + 1 edge + 1 Length defining the -position of the point on the given edge + 1 Direction for the calculation of the length (0 = forward, 2 = reversed). +position of the point on the given edge + 1 Reverse flag defining the direction for the +calculation of the length (False = forward, True = reversed). \image html point3_3.png It is also possible to define 3D coordinates of the point diff --git a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc index b4c537d43..631c3c77b 100644 --- a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc @@ -23,7 +23,7 @@ Arc = geompy.MakeArc(py, pz, px) # create a vertex by parameter p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) # create a vertex by length -p_on_arc2 = geompy.MakeVertexOnCurveByLength(Arc, 50., 0) +p_on_arc2 = geompy.MakeVertexOnCurveByLength(Arc, 50., False) #create a vertex by point projection p_on_arc3 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 2f8019d3f..21ed9b2f8 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -422,12 +422,12 @@ module GEOM * Create a point, corresponding to the given length on the given curve. * \param theRefCurve The referenced curve. * \param theLength Length on the referenced curve. - * \param theDirection Direction for the calculation of the length (0 = forward or 2 = reversed). + * \param theReverse Direction for the calculation of the length (false = forward or true = reversed). * \return New GEOM_Object, containing the created point. */ GEOM_Object MakePointOnCurveByLength (in GEOM_Object theRefCurve, in double theLength, - in double theDirection); + in boolean theReverse); /*! * Create a point on the given curve, projecting given point diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index 9a039e9ba..f1f65dfb6 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -233,7 +233,6 @@ void BasicGUI_PointDlg::Init() myNeedType = TopAbs_VERTEX; myEditCurrentArgument = 0; - myCheckFlag = 0; /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -712,7 +711,6 @@ void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue) //================================================================================= void BasicGUI_PointDlg::CheckBoxClicked( int State ) { - myCheckFlag = State; displayPreview(); } @@ -871,13 +869,11 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters<SpinBox_DX->text(); } else if ( myParamCoord->checkedId() == LENGTH_VALUE ) { - anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), myCheckFlag ); + bool reversed = GroupOnCurve->CheckButton1->isChecked(); + anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), reversed ); - std::stringstream out; - out<SpinBox_DX->text(); - aParameters<checkedId() == COORD_VALUE ) { double x = GroupXYZ->SpinBox_DX->value(); diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h index 206111d8e..fad9a1591 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.h +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -84,8 +84,6 @@ private: bool myBusy; - int myCheckFlag; - DlgRef_3Spin* GroupXYZ; DlgRef_1Sel3Spin* GroupRefPoint; DlgRef_1Sel1Spin1Check* GroupOnCurve; diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index 7e7d53bf9..07b40dc68 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -191,8 +191,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom double theParam1, double theParam2, double theParam3, - int theFlag1, - const PointLocation theLocation) + const PointLocation theLocation, + bool theReverse) { SetErrorCode(KO); @@ -231,7 +231,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom case PointOn_CurveByLength: aPI.SetCurve(aRefFunction); aPI.SetLength(theParam1); - aPI.SetFlag(theFlag1); + aPI.SetReversed(theReverse); break; case PointOn_CurveByCoord: aPI.SetCurve(aRefFunction); @@ -277,7 +277,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom break; case PointOn_CurveByLength: GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength(" - << theGeomObj << ", " << theParam1 << ", " << theFlag1 << ")"; + << theGeomObj << ", " << theParam1 << ", " << theReverse << ")"; break; case PointOn_CurveByCoord: GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord(" @@ -308,7 +308,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve (Handle(GEOM_Object) theCurve, double theParameter) { - return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, 1, PointOn_CurveByParam); + return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, PointOn_CurveByParam); } //============================================================================= @@ -322,7 +322,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord double theYParam, double theZParam) { - return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, 1, PointOn_CurveByCoord); + return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord); } //============================================================================= @@ -333,9 +333,9 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength (Handle(GEOM_Object) theCurve, double theLength, - int theDirection) + bool theReverse) { - return makePointOnGeom(theCurve, theLength, 0.0, 0.0, theDirection, PointOn_CurveByLength); + return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength, theReverse); } //============================================================================= @@ -348,7 +348,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface double theUParameter, double theVParameter) { - return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., 1, PointOn_SurfaceByParam); + return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam); } //============================================================================= @@ -362,7 +362,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord double theYParam, double theZParam) { - return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, 1, PointOn_SurfaceByCoord); + return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord); } diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx index 2066e14a0..64d65f552 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx @@ -45,7 +45,7 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByLength (Handle(GEOM_Object) theCurve, double theLength, - int theDirection); + bool theReverse); Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByCoord (Handle(GEOM_Object) theCurve, double theXParam, @@ -135,8 +135,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { double theParam1, double theParam2, double theParam3, - int theFlag1, - const PointLocation theLocation); + const PointLocation theLocation, + bool theReverse = false); }; #endif diff --git a/src/GEOMImpl/GEOMImpl_IPoint.hxx b/src/GEOMImpl/GEOMImpl_IPoint.hxx index 36ce68cac..c11569533 100755 --- a/src/GEOMImpl/GEOMImpl_IPoint.hxx +++ b/src/GEOMImpl/GEOMImpl_IPoint.hxx @@ -73,12 +73,12 @@ class GEOMImpl_IPoint void SetParameter(double theParam) { _func->SetReal(ARG_PARAM, theParam); } void SetParameter2(double theParam) { _func->SetReal(ARG_PARAM2, theParam); } void SetLength(double theLength) { _func->SetReal(ARG_LENGTH, theLength); } - void SetFlag(int theFlag) { _func->SetInteger(ARG_FLAG, theFlag); } + void SetReversed(bool theReversed) { _func->SetInteger(ARG_FLAG, theReversed); } double GetParameter() { return _func->GetReal(ARG_PARAM); } double GetParameter2() { return _func->GetReal(ARG_PARAM2); } double GetLength() { return _func->GetReal(ARG_LENGTH); } - int GetFlag() { return _func->GetInteger(ARG_FLAG); } + bool GetReversed() { return _func->GetInteger(ARG_FLAG); } private: diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx index 4ea8d4981..8aed2e4be 100644 --- a/src/GEOMImpl/GEOMImpl_PointDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -156,7 +156,7 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const else if (aType == POINT_CURVE_LENGTH) { Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); Standard_Real theLength = aPI.GetLength(); - Standard_Integer theDirection = aPI.GetFlag(); + Standard_Integer theReversed = aPI.GetReversed(); TopoDS_Shape aRefShape = aRefCurve->GetValue(); Standard_Real UFirst = 0; Standard_Real ULast = 0; @@ -171,14 +171,10 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const } Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), UFirst, ULast); Handle(Geom_Curve) ReOrientedCurve = EdgeCurve; - if ( theDirection == 2 ) { + if ( theReversed ) { ReOrientedCurve = EdgeCurve -> Reversed(); UFirst=ULast; } - else if ( theDirection != 0 ){ - Standard_TypeMismatch::Raise - ("Point On Curve creation aborted : direction parameter must be 0 or 2"); - } GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve); GCPnts_AbscissaPoint anAbsPnt(AdapCurve, theLength, UFirst); Standard_Real aParam = anAbsPnt.Parameter(); diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc index fd462fa83..d11abf3db 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.cc +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -163,7 +163,7 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theLength, - CORBA::Double theDirection) + CORBA::Boolean theReverse) { GEOM::GEOM_Object_var aGEOMObject; @@ -177,7 +177,7 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength //Create the point Handle(GEOM_Object) anObject = GetOperations()->MakePointOnCurveByLength(aReference, theLength, - theDirection); + theReverse); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh index a559062d6..7fa357065 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -56,8 +56,8 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i : CORBA::Double theParameter); GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve, - CORBA::Double theLength, - CORBA::Double theDirection); + CORBA::Double theLength, + CORBA::Boolean theReverse); GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theXParameter, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index bcfb2485a..3d0c6154f 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -592,12 +592,12 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the //============================================================================= GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theLength, - CORBA::Double theDirection) + CORBA::Boolean theReverse) { beginService( " GEOM_Superv_i::MakePointOnCurveByLength" ); MESSAGE("GEOM_Superv_i::MakePointOnCurveByLength"); getBasicOp(); - GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength, theDirection); + GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength, theReverse); endService( " GEOM_Superv_i::MakePointOnCurveByLength" ); return anObj; } diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index c97e931d3..dcef36414 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -152,7 +152,7 @@ public: CORBA::Double theParameter); GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theLength, - CORBA::Double theDirection); + CORBA::Boolean theReverse); GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theXParameter, CORBA::Double theYParameter, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 2b22e3f7a..3a69656dd 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -114,7 +114,7 @@ def TestAll (geompy, math): #Test point on curve creation p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr p_on_arc2 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10 ) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr - p_on_arc3 = geompy.MakeVertexOnCurveByLength(Arc, 50, 2) #(GEOM_Object_ptr, Double, Double)->GEOM_Object_ptr + p_on_arc3 = geompy.MakeVertexOnCurveByLength(Arc, 50, True) #(GEOM_Object_ptr, Double, Boolean)->GEOM_Object_ptr #Test point on lines intersection p_on_l1l2 = geompy.MakeVertexOnLinesIntersection(Line1, Line2) #(2 GEOM_Object_ptr)->GEOM_Object_ptr diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 54e6a2c77..5f84eb89b 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -515,14 +515,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a point, corresponding to the given length on the given curve. # @param theRefCurve The referenced curve. # @param theLength Length on the referenced curve. - # @param theDirection Flag allowing to choose the direction for the calculation of the length (0 = forward or 2 = reversed). + # @param theReverse Flag allowing to choose the direction for the calculation of the length (False = forward or True = reversed). # @return New GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertexOnCurveByLength(self,theRefCurve, theLength, theDirection): + def MakeVertexOnCurveByLength(self,theRefCurve, theLength, theReverse = False): # Example: see GEOM_TestAll.py theLength, Parameters = ParseParameters(theLength) - anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theDirection) + anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theReverse) RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp) anObj.SetParameters(Parameters) return anObj -- 2.39.2