From: asl Date: Mon, 7 Dec 2015 06:31:19 +0000 (+0300) Subject: refs #751: more dense points distribution for the channel/digue creation on spline X-Git-Tag: SALOME_HYDRO_V1.0~57^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=273437351f93566ed85a8e5bd05164a9e6ada407;p=modules%2Fhydro.git refs #751: more dense points distribution for the channel/digue creation on spline --- diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index cd4800b4..3d18e28d 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -146,18 +146,19 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& 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. ); diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index 564f4f2c..70673480 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -29,6 +29,9 @@ #include #include +#include +#include +#include #include #include @@ -417,7 +420,7 @@ void HYDROData_Polyline3D::removeChildProfileUZ() */ } -HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints() const +HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints( double theEqDistance ) const { Polyline3DPoints aPoints; @@ -468,7 +471,29 @@ HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetPoints() const } 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() ) { diff --git a/src/HYDROData/HYDROData_Polyline3D.h b/src/HYDROData/HYDROData_Polyline3D.h index 1705f29a..e90b1cec 100644 --- a/src/HYDROData/HYDROData_Polyline3D.h +++ b/src/HYDROData/HYDROData_Polyline3D.h @@ -149,7 +149,7 @@ public: * Returns list of polyline points. * \return list of 3D points */ - HYDRODATA_EXPORT Polyline3DPoints GetPoints() const; + HYDRODATA_EXPORT Polyline3DPoints GetPoints( double theEqDistance = -1 ) const; protected: /** diff --git a/src/HYDRO_tests/reference_data/Channel.png b/src/HYDRO_tests/reference_data/Channel.png new file mode 100644 index 00000000..60f17399 Binary files /dev/null and b/src/HYDRO_tests/reference_data/Channel.png differ