]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #751: more dense points distribution for the channel/digue creation on spline
authorasl <asl@opencascade.com>
Mon, 7 Dec 2015 06:31:19 +0000 (09:31 +0300)
committerasl <asl@opencascade.com>
Mon, 7 Dec 2015 06:31:19 +0000 (09:31 +0300)
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Polyline3D.cxx
src/HYDROData/HYDROData_Polyline3D.h
src/HYDRO_tests/reference_data/Channel.png [new file with mode: 0644]

index cd4800b425a3ae9a488280cd910d9659eaf9b5f5..3d18e28d7a47f132750fdb242effd9fe188fe248 100644 (file)
@@ -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. );
index 564f4f2cd4f2f18f1a878bc15d279fb7d43e2451..7067348006ac05e783f19761fffc906d62532084 100644 (file)
@@ -29,6 +29,9 @@
 #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>
@@ -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() ) {
index 1705f29aeeacc777f1a4715db012c1dac4eea3b1..e90b1cec8180916f9b00659a9207da21e74252de 100644 (file)
@@ -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 (file)
index 0000000..60f1739
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Channel.png differ