- TopoDS_Shape aProj = BRepBuilderAPI_MakeVertex(aPntProj).Shape();
- DEBTRACE("projection: (" << aPntProj.X() << ", " << aPntProj.Y() << ", " << aPntProj.Z() << ")");
- return aPntProj.Z() + 2.;
+ //DEBTRACE("projection: (" << aPntProj.X() << ", " << aPntProj.Y() << ", " << aPntProj.Z() << ")");
+ gp_XY aProjXY = gp_XY(aPntProj.X(), aPntProj.Y());
+ aProjXY.Subtract(thePoint);
+ double distance = aProjXY.Modulus();
+ //DEBTRACE("distance to guideline " << distance);
+
+ // get delta altitude on section (supposed symmetric) from guideline distance (aParam)
+ double delta = 0;
+ int i1 = 0;
+ gp_XY pt1 = gp_XY();
+ gp_XY pt2 = gp_XY();
+ HYDROData_ProfileUZ::PointsList aSectionPoints = aProfile->GetParametricPoints();
+ for ( int i = 1, aNbPoints = aSectionPoints.Size(); i <= aNbPoints; ++i )
+ {
+ const HYDROData_IPolyline::Point& aPolylinePoint = aSectionPoints.Value( i );
+ //DEBTRACE(" profile point: " << aPolylinePoint.X() << " " << aPolylinePoint.Y());
+ if (aPolylinePoint.X() < distance)
+ {
+ i1 = i;
+ pt1 = aPolylinePoint;
+ }
+ if (aPolylinePoint.X() >= distance)
+ {
+ pt2 = aPolylinePoint;
+ break;
+ }
+ }
+ if ((i1 == 0) && (distance > 0))
+ {
+ DEBTRACE("Projection aborted : non centered profile");
+ return aResAltitude;
+ }
+ if (i1 == aProfilePoints.Size()) // distance >= profile width
+ {
+ delta = pt1.Y();
+ }
+ else
+ {
+ delta = pt1.Y() + (pt2.Y() - pt1.Y())*(distance -pt1.X())/(pt2.X()-pt1.X());
+ }
+ aResAltitude = delta + aDepth;
+ DEBTRACE("distance XY: "<< aParam << " distance to guideline: " << distance << " final altitude: " << aResAltitude << " delta: " << delta);
+ return aResAltitude;