+ if( a>b )
+ return a;
+ else
+ return b;
+}
+
+HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
+ ( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
+ const Handle_HYDROData_Profile& theProfileA,
+ double theXCurvA,
+ const Handle_HYDROData_Profile& theProfileB,
+ double theXCurvB,
+ double theDDZ, int theNbSteps, bool isAddSecond )
+{
+ double zminA, zmaxA, zminB, zmaxB;
+ gp_Pnt lowestA, lowestB;
+ gp_Vec2d dirA, dirB;
+
+ GetProperties( theProfileA, lowestA, dirA, false, zminA, zmaxA );
+ GetProperties( theProfileB, lowestB, dirB, false, zminB, zmaxB );
+
+ double zmin = max( zminA, zminB );
+ double zmax = max( zmaxA, zmaxB );
+
+ CurveUZ midA(0), midB(0);
+ CurveUZ widA(0), widB(0);
+
+ ProfileDiscretization( theProfileA, theXCurvA, zmin, zmax, theDDZ, midA, widA );
+ ProfileDiscretization( theProfileB, theXCurvB, zmin, zmax, theDDZ, midB, widB );
+
+ std::vector<CurveUZ> mid, wid;
+ Interpolate( midA, midB, theNbSteps, mid, isAddSecond );
+ Interpolate( widA, widB, theNbSteps, wid, isAddSecond );
+
+ size_t p = mid.size();
+ size_t q = p>0 ? 2*mid[0].size() : 1;
+ AltitudePoints points;
+ points.reserve( p*q );
+ for( size_t i=0; i<p; i++ )
+ CurveTo3D( theHydraulicAxis, mid[i], wid[i], points );
+ return points;
+}
+
+HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
+ ( const std::vector<Handle_HYDROData_Profile>& theProfiles,
+ double theDDZ, double theSpatialStep )
+{
+ AltitudePoints points;
+ size_t n = theProfiles.size();
+ if( n<=1 )
+ return points;
+
+ std::vector<double> distances;
+ Handle_Geom2d_BSplineCurve aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances );
+ if( aHydraulicAxis.IsNull() )
+ return points;
+
+ for( size_t i=0, n1=n-1; i<n1; i++ )
+ {
+ double aDistance = distances[i+1]-distances[i];
+ int aNbSteps = int(aDistance/theSpatialStep) + 1;
+ bool isAddSecond = i==n1-1;
+ AltitudePoints local_points = Interpolate( aHydraulicAxis, theProfiles[i], distances[i],
+ theProfiles[i+1], distances[i+1], theDDZ, aNbSteps, isAddSecond );
+ if( i==0 )
+ points.reserve( local_points.size() * ( n-1 ) );
+ for( size_t j=0, m=local_points.size(); j<m; j++ )
+ points.push_back( local_points[j] );
+ }
+ return points;