mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-18 23:50:36 +05:00
RNC: IMP EDF 1542: Added the functionnality MakeVertexOnCurveByLength that allows creating a point at a given curvilinear abscissa on a curve
This commit is contained in:
parent
2b23fe11ea
commit
9c7d624fdc
@ -404,6 +404,16 @@ module GEOM
|
||||
GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve,
|
||||
in double theParameter);
|
||||
|
||||
/*!
|
||||
* Create a point, corresponding to the given length on the given curve.
|
||||
* \param theRefCurve The referenced curve.
|
||||
* \param theLength Length on the referenced curve.
|
||||
* \return New GEOM_Object, containing the created point.
|
||||
*/
|
||||
GEOM_Object MakePointOnCurveByLength (in GEOM_Object theRefCurve,
|
||||
in double theLength);
|
||||
|
||||
|
||||
/*!
|
||||
* Create a point on the given curve, projecting given point
|
||||
* \param theRefCurve The referenced curve.
|
||||
|
@ -57,6 +57,7 @@
|
||||
|
||||
#define PARAM_VALUE 0
|
||||
#define COORD_VALUE 1
|
||||
#define LENGTH_VALUE 2
|
||||
|
||||
#define GEOM_POINT_XYZ 0
|
||||
#define GEOM_POINT_REF 1
|
||||
@ -107,6 +108,9 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
|
||||
QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), myParamGroup );
|
||||
myParamCoord->addButton( btn, PARAM_VALUE );
|
||||
boxLayout->addWidget( btn );
|
||||
btn = new QRadioButton( tr( "GEOM_LENGTH_VALUE" ), myParamGroup );
|
||||
myParamCoord->addButton( btn, LENGTH_VALUE );
|
||||
boxLayout->addWidget( btn );
|
||||
btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), myParamGroup );
|
||||
myParamCoord->addButton( btn, COORD_VALUE );
|
||||
boxLayout->addWidget( btn );
|
||||
@ -367,6 +371,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
|
||||
GroupLineIntersection->hide();
|
||||
GroupOnSurface->hide();
|
||||
myParamGroup->show();
|
||||
myParamCoord->button( LENGTH_VALUE )->show();
|
||||
myParamCoord->button( PARAM_VALUE )->setChecked( true );
|
||||
GroupOnCurve->show();
|
||||
myCoordGrp->show();
|
||||
updateParamCoord( false );
|
||||
@ -409,6 +415,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
|
||||
GroupOnCurve->hide();
|
||||
GroupLineIntersection->hide();
|
||||
myParamGroup->show();
|
||||
myParamCoord->button( LENGTH_VALUE )->hide();
|
||||
myParamCoord->button( PARAM_VALUE )->setChecked(true);
|
||||
GroupOnSurface->show();
|
||||
myCoordGrp->show();
|
||||
updateParamCoord( false );
|
||||
@ -772,7 +780,7 @@ bool BasicGUI_PointDlg::isValid( QString& msg )
|
||||
}
|
||||
else if ( id == GEOM_POINT_EDGE ) {
|
||||
bool ok = true;
|
||||
if ( myParamCoord->checkedId() == PARAM_VALUE )
|
||||
if ( myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE )
|
||||
ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
|
||||
else {
|
||||
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
|
||||
@ -846,7 +854,12 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
|
||||
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
|
||||
anObj = anOper->MakePointOnCurve( myEdge, getParameter() );
|
||||
aParameters<<GroupOnCurve->SpinBox_DX->text();
|
||||
} else {
|
||||
}
|
||||
else if ( myParamCoord->checkedId() == LENGTH_VALUE ) {
|
||||
anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter() );
|
||||
aParameters<<GroupOnCurve->SpinBox_DX->text();
|
||||
}
|
||||
else if ( myParamCoord->checkedId() == COORD_VALUE ) {
|
||||
double x = GroupXYZ->SpinBox_DX->value();
|
||||
double y = GroupXYZ->SpinBox_DY->value();
|
||||
double z = GroupXYZ->SpinBox_DZ->value();
|
||||
@ -971,11 +984,25 @@ void BasicGUI_PointDlg::ClickParamCoord( int id )
|
||||
void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
|
||||
{
|
||||
bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
|
||||
bool isLength = myParamCoord->checkedId() == LENGTH_VALUE;
|
||||
|
||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
|
||||
|
||||
const int id = getConstructorId();
|
||||
if ( id == GEOM_POINT_EDGE ) {
|
||||
GroupOnCurve->TextLabel2->setShown( isParam );
|
||||
GroupOnCurve->SpinBox_DX->setShown( isParam );
|
||||
GroupOnCurve->TextLabel2->setShown( isParam || isLength );
|
||||
GroupOnCurve->SpinBox_DX->setShown( 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" ));
|
||||
}
|
||||
else if ( isLength ){
|
||||
initSpinBox( GroupOnCurve->SpinBox_DX, 0.0, COORD_MAX, 0.1 * step, "length_precision" );
|
||||
GroupOnCurve->SpinBox_DX->setValue( 0.0 );
|
||||
GroupOnCurve->TextLabel2->setText(tr( "GEOM_LENGTH" ));
|
||||
}
|
||||
}
|
||||
else if ( id == GEOM_POINT_SURF ) {
|
||||
GroupOnSurface->TextLabel2->setShown( isParam );
|
||||
@ -984,7 +1011,7 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
|
||||
GroupOnSurface->SpinBox_DY->setShown( isParam );
|
||||
}
|
||||
|
||||
GroupXYZ->setShown( !isParam );
|
||||
GroupXYZ->setShown( !isParam && !isLength );
|
||||
|
||||
if ( theIsUpdate )
|
||||
QTimer::singleShot(50, this, SLOT(updateSize()));
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>297</width>
|
||||
<width>496</width>
|
||||
<height>148</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -1102,6 +1102,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>GEOM_COORD_VALUE</source>
|
||||
<translation>By coordinate</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_LENGTH_VALUE</source>
|
||||
<translation>By length</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PARTITION</source>
|
||||
<translation>Partition</translation>
|
||||
|
@ -1100,6 +1100,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
|
||||
<message>
|
||||
<source>GEOM_COORD_VALUE</source>
|
||||
<translation>Par coordonnée</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_LENGTH_VALUE</source>
|
||||
<translation>Par longueur</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_PARTITION</source>
|
||||
|
@ -205,6 +205,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
|
||||
switch( theLocation )
|
||||
{
|
||||
case PointOn_CurveByParam: fType = POINT_CURVE_PAR; break;
|
||||
case PointOn_CurveByLength: fType = POINT_CURVE_LENGTH; break;
|
||||
case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
|
||||
case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
|
||||
case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
|
||||
@ -226,6 +227,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
|
||||
aPI.SetCurve(aRefFunction);
|
||||
aPI.SetParameter(theParam1);
|
||||
break;
|
||||
case PointOn_CurveByLength:
|
||||
aPI.SetCurve(aRefFunction);
|
||||
aPI.SetLength(theParam1);
|
||||
break;
|
||||
case PointOn_CurveByCoord:
|
||||
aPI.SetCurve(aRefFunction);
|
||||
aPI.SetX(theParam1);
|
||||
@ -268,6 +273,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
|
||||
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurve("
|
||||
<< theGeomObj << ", " << theParam1 << ")";
|
||||
break;
|
||||
case PointOn_CurveByLength:
|
||||
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByLength("
|
||||
<< theGeomObj << ", " << theParam1 << ")";
|
||||
break;
|
||||
case PointOn_CurveByCoord:
|
||||
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
|
||||
<< theGeomObj << ", " << theParam1
|
||||
@ -314,6 +323,17 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByCoord
|
||||
return makePointOnGeom(theCurve, theXParam, theYParam, theZParam, PointOn_CurveByCoord);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* MakePointOnCurveByLength
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurveByLength
|
||||
(Handle(GEOM_Object) theCurve, double theLength)
|
||||
{
|
||||
return makePointOnGeom(theCurve, theLength, 0.0, 0.0, PointOn_CurveByLength);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* MakePointOnSurface
|
||||
|
@ -43,6 +43,9 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
|
||||
Standard_EXPORT Handle(GEOM_Object) MakePointOnCurve (Handle(GEOM_Object) theCurve,
|
||||
double theParameter);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByLength (Handle(GEOM_Object) theCurve,
|
||||
double theLength);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MakePointOnCurveByCoord (Handle(GEOM_Object) theCurve,
|
||||
double theXParam,
|
||||
double theYParam,
|
||||
@ -122,6 +125,7 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
|
||||
{
|
||||
PointOn_CurveByParam,
|
||||
PointOn_CurveByCoord,
|
||||
PointOn_CurveByLength,
|
||||
PointOn_SurfaceByParam,
|
||||
PointOn_SurfaceByCoord
|
||||
};
|
||||
|
@ -38,6 +38,8 @@
|
||||
#define ARG_SURFACE 9
|
||||
#define ARG_PARAM2 10
|
||||
|
||||
#define ARG_LENGTH 11
|
||||
|
||||
class GEOMImpl_IPoint
|
||||
{
|
||||
public:
|
||||
@ -72,6 +74,10 @@ class GEOMImpl_IPoint
|
||||
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); }
|
||||
|
||||
private:
|
||||
|
||||
Handle(GEOM_Function) _func;
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <ShapeAnalysis.hxx>
|
||||
|
||||
#include <GCPnts_AbscissaPoint.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
@ -150,6 +152,28 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
|
||||
("Point On Curve creation aborted : cannot project point");
|
||||
}
|
||||
}
|
||||
else if (aType == POINT_CURVE_LENGTH) {
|
||||
Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
|
||||
Standard_Real theLength = aPI.GetLength();
|
||||
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 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);
|
||||
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) {
|
||||
Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
|
||||
TopoDS_Shape aRefShape = aRefCurve->GetValue();
|
||||
|
@ -109,6 +109,7 @@
|
||||
#define POINT_SURFACE_PAR 5
|
||||
#define POINT_CURVE_COORD 6
|
||||
#define POINT_SURFACE_COORD 7
|
||||
#define POINT_CURVE_LENGTH 8
|
||||
|
||||
#define VECTOR_TWO_PNT 1
|
||||
#define VECTOR_DX_DY_DZ 2
|
||||
|
@ -155,6 +155,32 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* MakePointOnCurveByLength
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
|
||||
(GEOM::GEOM_Object_ptr theCurve, CORBA::Double theLength)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject;
|
||||
|
||||
//Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
//Get the reference curve
|
||||
Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
|
||||
if (aReference.IsNull()) return aGEOMObject._retn();
|
||||
|
||||
//Create the point
|
||||
Handle(GEOM_Object) anObject =
|
||||
GetOperations()->MakePointOnCurveByLength(aReference, theLength);
|
||||
if (!GetOperations()->IsDone() || anObject.IsNull())
|
||||
return aGEOMObject._retn();
|
||||
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* MakePointOnCurveByCoord
|
||||
|
@ -55,6 +55,9 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
|
||||
GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theCurve,
|
||||
CORBA::Double theParameter);
|
||||
|
||||
GEOM::GEOM_Object_ptr MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theCurve,
|
||||
CORBA::Double theLength);
|
||||
|
||||
GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theCurve,
|
||||
CORBA::Double theXParameter,
|
||||
CORBA::Double theYParameter,
|
||||
|
@ -587,6 +587,20 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the
|
||||
return anObj;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// MakePointOnCurveByLength:
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurveByLength (GEOM::GEOM_Object_ptr theRefCurve,
|
||||
CORBA::Double theLength)
|
||||
{
|
||||
beginService( " GEOM_Superv_i::MakePointOnCurveByLength" );
|
||||
MESSAGE("GEOM_Superv_i::MakePointOnCurveByLength");
|
||||
getBasicOp();
|
||||
GEOM::GEOM_Object_ptr anObj = myBasicOp->MakePointOnCurveByLength(theRefCurve, theLength);
|
||||
endService( " GEOM_Superv_i::MakePointOnCurveByLength" );
|
||||
return anObj;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// MakePointOnCurveByCoord
|
||||
//=============================================================================
|
||||
|
@ -150,6 +150,8 @@ public:
|
||||
CORBA::Double theZ);
|
||||
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);
|
||||
GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve,
|
||||
CORBA::Double theXParameter,
|
||||
CORBA::Double theYParameter,
|
||||
|
@ -504,6 +504,20 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
anObj.SetParameters(Parameters)
|
||||
return anObj
|
||||
|
||||
## Create a point, corresponding to the given length on the given curve.
|
||||
# @param theRefCurve The referenced curve.
|
||||
# @param theLength length on the referenced curve.
|
||||
# @return New GEOM_Object, containing the created point.
|
||||
#
|
||||
# @ref tui_creation_point "Example"
|
||||
def MakeVertexOnCurveByLength(self,theRefCurve, theLength):
|
||||
# Example: see GEOM_TestAll.py
|
||||
theLength, Parameters = ParseParameters(theLength)
|
||||
anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength)
|
||||
RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp)
|
||||
anObj.SetParameters(Parameters)
|
||||
return anObj
|
||||
|
||||
## Create a point, corresponding to the given parameters on the
|
||||
# given surface.
|
||||
# @param theRefSurf The referenced surface.
|
||||
|
Loading…
Reference in New Issue
Block a user