Salome HOME
debug of tests for DTM
[modules/hydro.git] / src / HYDROData / HYDROData_DTM.cxx
index 036936fcc10d1dadc69330289cd498bce1e23284..544dd2e53184269221fe352cacc1f099c5b7fb0f 100644 (file)
@@ -35,8 +35,8 @@ IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
 IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
 
 
-HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv )
-  : myXcurv( theXCurv )
+HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir )
+  : myXcurv( theXCurv ), myProfileDir( theProfileDir )
 {
 }
 
@@ -49,9 +49,14 @@ double HYDROData_DTM::CurveUZ::Xcurv() const
   return myXcurv;
 }
 
+gp_Vec2d HYDROData_DTM::CurveUZ::ProfileDir() const
+{
+  return myProfileDir;
+}
+
 HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator + ( const CurveUZ& c ) const
 {
-  HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv() );
+  HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir() );
   size_t n = size();
   res.reserve( n );
   for( int i=0; i<n; i++ )
@@ -66,7 +71,7 @@ HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator + ( const CurveUZ& c ) c
 
 HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator * ( double d ) const
 {
-  HYDROData_DTM::CurveUZ res( Xcurv()*d );
+  HYDROData_DTM::CurveUZ res( Xcurv()*d, ProfileDir()*d );
   size_t n = size();
   res.reserve( n );
   for( int i=0; i<n; i++ )
@@ -351,18 +356,17 @@ Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis(
 
 std::vector<Handle_Geom2d_Curve> HYDROData_DTM::ProfileToParametric( 
   const Handle_HYDROData_Profile& theProfile,
-  double& theUMin, double& theUMax )
+  double& theUMin, double& theUMax, gp_Vec2d& theDir )
 {
   std::vector<Handle_Geom2d_Curve> curves;
   
   // Transformation of the coordinate systems
   gp_Pnt aLowest;
-  gp_Vec2d aDir;
   double zmin, zmax;
-  GetProperties( theProfile, aLowest, aDir, false, zmin, zmax );
+  GetProperties( theProfile, aLowest, theDir, false, zmin, zmax );
 
   gp_Ax3 aStd3d( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( 1, 0, 0 ) );
-  gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( aDir.X(), aDir.Y(), 0 ) );
+  gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( theDir.X(), theDir.Y(), 0 ) );
 
   gp_Trsf aTransf;
   aTransf.SetTransformation( aStd3d, aLocal );
@@ -422,7 +426,8 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr
          aUMax = -aUMin,
          aVMax = 1000000;
   
-  std::vector<Handle_Geom2d_Curve> curves = ProfileToParametric( theProfile, aUMin, aUMax );
+  gp_Vec2d aProfileDir;
+  std::vector<Handle_Geom2d_Curve> curves = ProfileToParametric( theProfile, aUMin, aUMax, aProfileDir );
   size_t n = curves.size();
 
   if( n==0 )
@@ -442,9 +447,9 @@ void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& thePr
   curves.push_back( aT2 );
   
   int psize = ( int )( ( theMaxZ-theMinZ ) / theDDZ + 1 );
-  theMidPointCurve = CurveUZ( theXCurv );
+  theMidPointCurve = CurveUZ( theXCurv, aProfileDir );
   theMidPointCurve.reserve( psize );
-  theWidthCurve = CurveUZ( theXCurv );
+  theWidthCurve = CurveUZ( theXCurv, aProfileDir );
   theWidthCurve.reserve( psize );
 
   n = curves.size();
@@ -510,12 +515,11 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi
   double aParam = ap.Parameter();
 
   gp_Pnt2d point;
-  gp_Vec2d tangent, profile_dir;
-  anAdaptor.D1( aParam, point, tangent );
-  profile_dir.SetCoord( tangent.Y(), -tangent.X() );
+  anAdaptor.D0( aParam, point );
+  gp_Vec2d profile_dir = theMidCurve.ProfileDir();
+  gp_Dir tangent_n( -profile_dir.Y(), profile_dir.X(), dz );
   profile_dir.Normalize();
-  gp_Dir tangent_n( tangent.X(), tangent.Y(), -dz );
-  //gp_Dir tangent_n( 0, 0, 1 );
+  
   size_t n = theMidCurve.size();
   double min_param = 1E+15;
   double max_param = -1E+15;
@@ -558,7 +562,7 @@ void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxi
 
   if( theLeft )
   {
-    gp_Pnt2d left2d = point/*.Translated( min_param * profile_dir )*/;
+    gp_Pnt2d left2d = point.Translated( min_param * profile_dir );
     gp_Pnt left( left2d.X(), left2d.Y(), z1 );
     theLeft->push_back( left, tangent_n );
   }
@@ -601,8 +605,8 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
   double zmin = max( zminA, zminB );
   double zmax = max( zmaxA, zmaxB );
 
-  CurveUZ midA(0), midB(0);
-  CurveUZ widA(0), widB(0);
+  CurveUZ midA(0, gp_Vec2d()), midB(0, gp_Vec2d());
+  CurveUZ widA(0, gp_Vec2d()), widB(0, gp_Vec2d());
 
   ProfileDiscretization( theProfileA, theXCurvA, zmin, zmax, theDDZ, midA, widA ); 
   ProfileDiscretization( theProfileB, theXCurvB, zmin, zmax, theDDZ, midB, widB );