RNC: EDF 1542: Take into account orientation in newly created MakeVertexOnCurveByLength function

This commit is contained in:
gdd 2011-01-05 17:33:52 +00:00
parent d02241355e
commit 643c92eb8f
12 changed files with 86 additions and 35 deletions

View File

@ -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

View File

@ -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<<GroupOnCurve->SpinBox_DX->text();
}
else if ( myParamCoord->checkedId() == LENGTH_VALUE ) {
anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter() );
anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), myCheckFlag );
std::stringstream out;
out<<myCheckFlag;
std::string flag = out.str();
aParameters<<GroupOnCurve->SpinBox_DX->text();
aParameters<<flag.c_str();
}
else if ( myParamCoord->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 ) {

View File

@ -30,7 +30,7 @@
#include <GEOMBase_Skeleton.h>
#include <QMap>
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();
};

View File

@ -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);
}

View File

@ -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);
};

View File

@ -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:

View File

@ -33,11 +33,13 @@
#include <BRep_Builder.hxx>
#include <Precision.hxx>
#include <TopAbs.hxx>
//#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
//#include <TopExp_Explorer.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
@ -48,6 +50,8 @@
#include <GCPnts_AbscissaPoint.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Tool.hxx>
//=======================================================================
//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<<std::endl;
if (theLength > 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 = "<<result_length<<std::endl;
aPnt = AdapCurve.Value(aParam);
}
else if (aType == POINT_SURFACE_PAR) {

View File

@ -161,7 +161,9 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
(GEOM::GEOM_Object_ptr theCurve, CORBA::Double theLength)
(GEOM::GEOM_Object_ptr theCurve,
CORBA::Double theLength,
CORBA::Double theDirection)
{
GEOM::GEOM_Object_var aGEOMObject;
@ -174,7 +176,8 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
//Create the point
Handle(GEOM_Object) anObject =
GetOperations()->MakePointOnCurveByLength(aReference, theLength);
GetOperations()->MakePointOnCurveByLength(aReference, theLength,
theDirection);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();

View File

@ -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,

View File

@ -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;
}

View File

@ -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,

View File

@ -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