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.
#define PARAM_VALUE 0
#define COORD_VALUE 1
+#define LENGTH_VALUE 2
#define GEOM_POINT_XYZ 0
#define GEOM_POINT_REF 1
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 );
GroupLineIntersection->hide();
GroupOnSurface->hide();
myParamGroup->show();
+ myParamCoord->button( LENGTH_VALUE )->show();
+ myParamCoord->button( PARAM_VALUE )->setChecked( true );
GroupOnCurve->show();
myCoordGrp->show();
updateParamCoord( false );
GroupOnCurve->hide();
GroupLineIntersection->hide();
myParamGroup->show();
+ myParamCoord->button( LENGTH_VALUE )->hide();
+ myParamCoord->button( PARAM_VALUE )->setChecked(true);
GroupOnSurface->show();
myCoordGrp->show();
updateParamCoord( false );
}
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;
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();
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 );
GroupOnSurface->TextLabel3->setShown( isParam );
GroupOnSurface->SpinBox_DX->setShown( isParam );
GroupOnSurface->SpinBox_DY->setShown( isParam );
}
-
- GroupXYZ->setShown( !isParam );
+
+ GroupXYZ->setShown( !isParam && !isLength );
if ( theIsUpdate )
QTimer::singleShot(50, this, SLOT(updateSize()));
<rect>
<x>0</x>
<y>0</y>
- <width>297</width>
+ <width>496</width>
<height>148</height>
</rect>
</property>
<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>
<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>
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;
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);
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
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
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,
{
PointOn_CurveByParam,
PointOn_CurveByCoord,
+ PointOn_CurveByLength,
PointOn_SurfaceByParam,
PointOn_SurfaceByCoord
};
#define ARG_SURFACE 9
#define ARG_PARAM2 10
+#define ARG_LENGTH 11
+
class GEOMImpl_IPoint
{
public:
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;
#include <TopoDS_Face.hxx>
#include <ShapeAnalysis.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <BRepAdaptor_Curve.hxx>
//=======================================================================
//function : GetID
("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();
#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
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
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,
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
//=============================================================================
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,
RaiseIfFailed("MakeVertexOnCurveByCoord", self.BasicOp)
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.