int aNbPoints = aPolylinePoints.Length();
*/
- HYDROData_Polyline3D::Polyline3DPoints aPolylinePoints3D = theGuideLine->GetPoints();
+ double aEqDistance = 1; // TODO: to pass via properties and OCAF
+ HYDROData_Polyline3D::Polyline3DPoints aPolylinePoints3D = theGuideLine->GetPoints( aEqDistance );
int aNbPoints = aPolylinePoints3D.Length();
- if ( aNbPoints < 2 ) {
+ if ( aNbPoints < 2 )
return false;
- }
// Get tangent in each point of the guide line ( 2D )
TColgp_Array1OfDir aTangents( 1, aNbPoints );
HYDROData_IPolyline::SectionType aSectionType = aPolylineXY->GetSectionType( 0 );
- if ( aSectionType == HYDROData_IPolyline::SECTION_POLYLINE ) {
+ if( aSectionType == HYDROData_IPolyline::SECTION_POLYLINE )
+ {
for ( int i = 1; i <= aNbPoints; ++i ) {
gp_XYZ aPnt = aPolylinePoints3D.Value( i );
aPnt.SetZ( 0. );
#include <BRep_Tool.hxx>
#include <Geom_BSplineCurve.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GCPnts_QuasiUniformAbscissa.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_XY.hxx>
*/
}
-HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints() const
+HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints( double theEqDistance ) const
{
Polyline3DPoints aPoints;
} else {
// Get points from spline curve
Standard_Real aStart, anEnd;
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve( TopoDS::Edge( anEdges.First() ), aStart, anEnd );
+ TopoDS_Edge anEdge = TopoDS::Edge( anEdges.First() );
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aStart, anEnd );
+
+ if( theEqDistance > 0 )
+ {
+ GeomAdaptor_Curve anAdaptorCurve( aCurve );
+ double aLength = GCPnts_AbscissaPoint::Length( anAdaptorCurve );
+ int aNbPoints = ceil( aLength / theEqDistance );
+ GCPnts_QuasiUniformAbscissa aDist( anAdaptorCurve, aNbPoints );
+ if( aDist.IsDone() )
+ {
+ aNbPoints = aDist.NbPoints();
+ for( int i=1; i<=aNbPoints; i++ )
+ {
+ double p = aDist.Parameter( i );
+ gp_Pnt aPnt;
+ aCurve->D0( p, aPnt );
+ aPoints.Append( aPnt.XYZ() );
+ }
+ return aPoints;
+ }
+ }
+
Handle(Geom_BSplineCurve) aGeomSpline = Handle(Geom_BSplineCurve)::DownCast( aCurve );
if ( !aGeomSpline.IsNull() ) {