From 643c92eb8f6e84b5643ba9c3bc990110d166f96b Mon Sep 17 00:00:00 2001 From: gdd Date: Wed, 5 Jan 2011 17:33:52 +0000 Subject: [PATCH] RNC: EDF 1542: Take into account orientation in newly created MakeVertexOnCurveByLength function --- idl/GEOM_Gen.idl | 5 ++-- src/BasicGUI/BasicGUI_PointDlg.cxx | 33 ++++++++++++++++++---- src/BasicGUI/BasicGUI_PointDlg.h | 7 +++-- src/GEOMImpl/GEOMImpl_IBasicOperations.cxx | 20 +++++++------ src/GEOMImpl/GEOMImpl_IBasicOperations.hxx | 4 ++- src/GEOMImpl/GEOMImpl_IPoint.hxx | 8 ++++-- src/GEOMImpl/GEOMImpl_PointDriver.cxx | 21 ++++++++++---- src/GEOM_I/GEOM_IBasicOperations_i.cc | 7 +++-- src/GEOM_I/GEOM_IBasicOperations_i.hh | 3 +- src/GEOM_I_Superv/GEOM_Superv_i.cc | 5 ++-- src/GEOM_I_Superv/GEOM_Superv_i.hh | 3 +- src/GEOM_SWIG/geompyDC.py | 5 ++-- 12 files changed, 86 insertions(+), 35 deletions(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 18efa2a0c..2f8019d3f 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -422,11 +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). * \return New GEOM_Object, containing the created point. */ GEOM_Object MakePointOnCurveByLength (in GEOM_Object theRefCurve, - in double theLength); - + in double theLength, + in double theDirection); /*! * 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 e5db36d90..9a039e9ba 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -123,11 +123,13 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) ); GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) ); - GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() ); + GroupOnCurve = new DlgRef_1Sel1Spin1Check( centralWidget() ); GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_POINT_ON_EDGE" ) ); GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) ); GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) ); + GroupOnCurve->CheckButton1->setText( tr( "GEOM_REVERSE" ) ); GroupOnCurve->PushButton1->setIcon( image2 ); + GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() ); GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) ); @@ -231,6 +233,7 @@ 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(); @@ -293,6 +296,8 @@ void BasicGUI_PointDlg::Init() connect( GroupRefPoint->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupRefPoint->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( GroupOnCurve->CheckButton1, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) ); + connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ), @@ -701,6 +706,17 @@ void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue) displayPreview(); } +//================================================================================= +// function : CheckBoxClicked() +// purpose : Check Boxes Management +//================================================================================= +void BasicGUI_PointDlg::CheckBoxClicked( int State ) +{ + myCheckFlag = State; + displayPreview(); +} + + //================================================================================= // funcion : getParameter() // purpose : @@ -855,8 +871,13 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects ) aParameters<SpinBox_DX->text(); } else if ( myParamCoord->checkedId() == LENGTH_VALUE ) { - anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter() ); + anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), myCheckFlag ); + + std::stringstream out; + out<SpinBox_DX->text(); + aParameters<checkedId() == COORD_VALUE ) { double x = GroupXYZ->SpinBox_DX->value(); @@ -990,17 +1011,19 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate) const int id = getConstructorId(); if ( id == GEOM_POINT_EDGE ) { - GroupOnCurve->TextLabel2->setShown( isParam || isLength ); - GroupOnCurve->SpinBox_DX->setShown( isParam || isLength ); + GroupOnCurve->TextLabel2->setVisible( isParam || isLength ); + GroupOnCurve->SpinBox_DX->setVisible( isParam || isLength ); if ( isParam ){ initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision" ); GroupOnCurve->SpinBox_DX->setValue( 0.5 ); GroupOnCurve->TextLabel2->setText(tr( "GEOM_PARAMETER" )); + GroupOnCurve->CheckButton1->setVisible(false); } else if ( isLength ){ - initSpinBox( GroupOnCurve->SpinBox_DX, 0.0, COORD_MAX, 0.1 * step, "length_precision" ); + initSpinBox( GroupOnCurve->SpinBox_DX, 0.0, COORD_MAX, step, "length_precision" ); GroupOnCurve->SpinBox_DX->setValue( 0.0 ); GroupOnCurve->TextLabel2->setText(tr( "GEOM_LENGTH" )); + GroupOnCurve->CheckButton1->setVisible(true); } } else if ( id == GEOM_POINT_SURF ) { diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h index 0e6973fc4..206111d8e 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.h +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -30,7 +30,7 @@ #include #include -class DlgRef_1Sel1Spin; +class DlgRef_1Sel1Spin1Check; class DlgRef_3Spin; class DlgRef_2Sel; class DlgRef_1Sel3Spin; @@ -84,9 +84,11 @@ private: bool myBusy; + int myCheckFlag; + DlgRef_3Spin* GroupXYZ; DlgRef_1Sel3Spin* GroupRefPoint; - DlgRef_1Sel1Spin* GroupOnCurve; + DlgRef_1Sel1Spin1Check* GroupOnCurve; DlgRef_2Sel* GroupLineIntersection; DlgRef_1Sel2Spin* GroupOnSurface; @@ -115,6 +117,7 @@ private slots: void ValueChangedInSpinBox( double ); void SetDoubleSpinBoxStep( double ); void ClickParamCoord( int ); + void CheckBoxClicked( int ); void onBtnPopup( QAction* ); void updateSize(); }; diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index ee4899f8e..7e7d53bf9 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -191,6 +191,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom double theParam1, double theParam2, double theParam3, + int theFlag1, const PointLocation theLocation) { SetErrorCode(KO); @@ -229,7 +230,8 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom break; case PointOn_CurveByLength: aPI.SetCurve(aRefFunction); - aPI.SetLength(theParam1); + aPI.SetLength(theParam1); + aPI.SetFlag(theFlag1); break; case PointOn_CurveByCoord: aPI.SetCurve(aRefFunction); @@ -275,7 +277,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom break; case PointOn_CurveByLength: GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength(" - << theGeomObj << ", " << theParam1 << ")"; + << theGeomObj << ", " << theParam1 << ", " << theFlag1 << ")"; break; case PointOn_CurveByCoord: GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord(" @@ -306,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, PointOn_CurveByParam); + return makePointOnGeom(theCurve, theParameter, 0.0, 0.0, 1, PointOn_CurveByParam); } //============================================================================= @@ -320,7 +322,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord double theYParam, double theZParam) { - return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord); + return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, 1, PointOn_CurveByCoord); } //============================================================================= @@ -329,9 +331,11 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord */ //============================================================================= Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength - (Handle(GEOM_Object) theCurve, double theLength) + (Handle(GEOM_Object) theCurve, + double theLength, + int theDirection) { - return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength); + return makePointOnGeom(theCurve, theLength, 0.0, 0.0, theDirection, PointOn_CurveByLength); } //============================================================================= @@ -344,7 +348,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurface double theUParameter, double theVParameter) { - return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., PointOn_SurfaceByParam); + return makePointOnGeom(theSurface, theUParameter, theVParameter, 0., 1, PointOn_SurfaceByParam); } //============================================================================= @@ -358,7 +362,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord double theYParam, double theZParam) { - return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord); + return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, 1, PointOn_SurfaceByCoord); } diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx index 6a42fdf95..2066e14a0 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx @@ -44,7 +44,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { double theParameter); Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByLength (Handle(GEOM_Object) theCurve, - double theLength); + double theLength, + int theDirection); Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByCoord (Handle(GEOM_Object) theCurve, double theXParam, @@ -134,6 +135,7 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { double theParam1, double theParam2, double theParam3, + int theFlag1, const PointLocation theLocation); }; diff --git a/src/GEOMImpl/GEOMImpl_IPoint.hxx b/src/GEOMImpl/GEOMImpl_IPoint.hxx index 5c65005d0..36ce68cac 100755 --- a/src/GEOMImpl/GEOMImpl_IPoint.hxx +++ b/src/GEOMImpl/GEOMImpl_IPoint.hxx @@ -40,6 +40,8 @@ #define ARG_LENGTH 11 +#define ARG_FLAG 12 + class GEOMImpl_IPoint { public: @@ -70,13 +72,13 @@ 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); } double GetParameter() { return _func->GetReal(ARG_PARAM); } double GetParameter2() { return _func->GetReal(ARG_PARAM2); } - - void SetLength(double theLength) { _func->SetReal(ARG_LENGTH, theLength); } - double GetLength() { return _func->GetReal(ARG_LENGTH); } + int GetFlag() { return _func->GetInteger(ARG_FLAG); } private: diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx index 38411ee68..49b709f5e 100644 --- a/src/GEOMImpl/GEOMImpl_PointDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -33,11 +33,13 @@ #include #include #include +//#include #include #include #include #include #include +//#include #include #include @@ -48,6 +50,8 @@ #include #include +#include + //======================================================================= //function : GetID //purpose : @@ -155,23 +159,28 @@ 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(); TopoDS_Shape aRefShape = aRefCurve->GetValue(); if (aRefShape.ShapeType() != TopAbs_EDGE) { Standard_TypeMismatch::Raise ("Point On Curve creation aborted : curve shape is not an edge"); } - BRepAdaptor_Curve AdapCurve = BRepAdaptor_Curve(TopoDS::Edge(aRefShape)); + Standard_Real UFirst = 0; + Standard_Real ULast = 0; + Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), UFirst, ULast); + Handle(Geom_Curve) ReOrientedCurve = EdgeCurve; + if ( theDirection == 2 ) + ReOrientedCurve = EdgeCurve->Reversed(); + else if ( theDirection == 0 ) + ReOrientedCurve = EdgeCurve; + GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve); Standard_Real theCurveLength = GCPnts_AbscissaPoint::Length(AdapCurve); - //std::cout<<"theCurveLength = "< theCurveLength) { Standard_ConstructionError::Raise ("Point On Curve creation aborted : given length is greater than edges length"); } - - GCPnts_AbscissaPoint anAbsPnt(AdapCurve, aPI.GetLength(), 0); + GCPnts_AbscissaPoint anAbsPnt(AdapCurve, theLength, UFirst); Standard_Real aParam = anAbsPnt.Parameter(); - Standard_Real result_length = GCPnts_AbscissaPoint::Length(AdapCurve, 0, aParam); - std::cout<<"calculated Length of the result = "<MakePointOnCurveByLength(aReference, theLength); + GetOperations()->MakePointOnCurveByLength(aReference, theLength, + theDirection); 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 6f26cee6c..a559062d6 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -56,7 +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 theLength, + CORBA::Double theDirection); 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 3ca3c9e48..bcfb2485a 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -591,12 +591,13 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the // MakePointOnCurveByLength: //============================================================================= GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, - CORBA::Double theLength) + CORBA::Double theLength, + CORBA::Double theDirection) { beginService( " GEOM_Superv_i::MakePointOnCurveByLength" ); MESSAGE("GEOM_Superv_i::MakePointOnCurveByLength"); getBasicOp(); - GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength); + GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength, theDirection); 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 c3608f0a1..c97e931d3 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -151,7 +151,8 @@ public: GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theParameter); GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve, - CORBA::Double theLength); + CORBA::Double theLength, + CORBA::Double theDirection); GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theXParameter, CORBA::Double theYParameter, diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index cb32ac012..bbb62b463 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -515,13 +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 theFirstParameter flag allowing to choose the direction for the calculation of the length (0 = forward or 2 = reversed). # @return New GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertexOnCurveByLength(self,theRefCurve, theLength): + def MakeVertexOnCurveByLength(self,theRefCurve, theLength, theDirection): # Example: see GEOM_TestAll.py theLength, Parameters = ParseParameters(theLength) - anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength) + anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theDirection) RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp) anObj.SetParameters(Parameters) return anObj -- 2.39.2