Small change of the interface for MakeVertexOnCurveByLength function: use boolean flag for the direction parameter instead of double

This commit is contained in:
vsr 2011-01-06 21:40:34 +00:00
parent bbebe02fd0
commit bf697caef8
15 changed files with 37 additions and 46 deletions

View File

@ -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 <b>TUI Command:</b> <em>geompy.MakeVertexOnCurveByLength(Edge,Length,Direction).</em>
\n <b>TUI Command:</b> <em>geompy.MakeVertexOnCurveByLength(Edge,Length,Reverse).</em>
\n <b>Arguments:</b> 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

View File

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

View File

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

View File

@ -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<<GroupOnCurve->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<<myCheckFlag;
std::string flag = out.str();
aParameters<<GroupOnCurve->SpinBox_DX->text();
aParameters<<flag.c_str();
aParameters<<QString::number( reversed );
}
else if ( myParamCoord->checkedId() == COORD_VALUE ) {
double x = GroupXYZ->SpinBox_DX->value();

View File

@ -84,8 +84,6 @@ private:
bool myBusy;
int myCheckFlag;
DlgRef_3Spin* GroupXYZ;
DlgRef_1Sel3Spin* GroupRefPoint;
DlgRef_1Sel1Spin1Check* GroupOnCurve;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -57,7 +57,7 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve,
CORBA::Double theLength,
CORBA::Double theDirection);
CORBA::Boolean theReverse);
GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theCurve,
CORBA::Double theXParameter,

View File

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

View File

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

View File

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

View File

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