return aResAltitude;
}
DEBTRACE("aChannel: " << aChannel->GetName().toStdString());
+
Handle(HYDROData_Polyline3D) aGuideLine = aChannel->GetGuideLine();
if (aGuideLine.IsNull())
{
return aResAltitude;
}
DEBTRACE("aGuideLine: " << aGuideLine->GetName().toStdString());
+
+ Handle(HYDROData_PolylineXY) aGuideXY = aGuideLine->GetPolylineXY();
+ if (aGuideXY.IsNull())
+ {
+ DEBTRACE("aGuideXY.IsNull()");
+ return aResAltitude;
+ }
+ DEBTRACE("aGuideXY: " << aGuideXY->GetName().toStdString());
+
+ Handle(HYDROData_ProfileUZ) aGuideUZ = aGuideLine->GetProfileUZ();
+ if (aGuideUZ.IsNull())
+ {
+ aGuideUZ = aGuideLine->GetChildProfileUZ(); // profile obtained from bathymetry
+ }
+ if (aGuideUZ.IsNull())
+ {
+ DEBTRACE("aGuideUZ.IsNull()");
+ return aResAltitude;
+ }
+ DEBTRACE("aGuideUZ: " << aGuideUZ->GetName().toStdString());
+
Handle (HYDROData_Profile) aProfile = aChannel->GetProfile();
if (aProfile.IsNull())
{
// --- See GEOMImpl_ProjectionDriver.cxx
- TopoDS_Shape aShape = aGuideLine->GetShape3D();
- double middleZ = -9999;
- aGuideLine->GetMiddleZ(middleZ); // use the middle Z value of the 3d line to help the projection.
- if (middleZ < -9000)
- {
- DEBTRACE("the middle Z value of the 3d line is incorrect");
- }
- gp_Pnt P1(thePoint.X(), thePoint.Y(), middleZ);
+// TopoDS_Shape aShape = aGuideLine->GetShape3D();
+// double middleZ = -9999;
+// aGuideLine->GetMiddleZ(middleZ); // use the middle Z value of the 3d line to help the projection.
+// if (middleZ < -9000)
+// {
+// DEBTRACE("the middle Z value of the 3d line is incorrect");
+// }
+// gp_Pnt P1(thePoint.X(), thePoint.Y(), middleZ);
+
+ TopoDS_Shape aShape = aGuideXY->GetShape();
+ gp_Pnt P1(thePoint.X(), thePoint.Y(), 0);
TopoDS_Shape aPoint = BRepBuilderAPI_MakeVertex(P1).Shape();
if (aPoint.IsNull() || aShape.IsNull())
// Normalize parameter.
TopoDS_Edge aSupportEdge = TopoDS::Edge(aSupportShape);
Standard_Real aF, aL;
-
BRep_Tool::Range(aSupportEdge, aF, aL);
-
if (Abs(aL - aF) <= aTolConf)
{
DEBTRACE("Projection aborted : degenerated projection edge");
return aResAltitude;
}
+ aParam = (aParam - aF)/(aL - aF);
+
+ // Compute edge index.
+ TopExp_Explorer anExp(aShape, TopAbs_EDGE);
+ int anIndex = 0;
+ for (; anExp.More(); anExp.Next(), anIndex++)
+ {
+ if (aSupportShape.IsSame(anExp.Current()))
+ {
+ break;
+ }
+ }
// Construct a projection vertex.
const gp_Pnt &aPntProj = aDistShSh.PointOnShape2(i);
- TopoDS_Shape aProj = BRepBuilderAPI_MakeVertex(aPntProj).Shape();
+// TopoDS_Shape aProj = BRepBuilderAPI_MakeVertex(aPntProj).Shape();
DEBTRACE("projection: (" << aPntProj.X() << ", " << aPntProj.Y() << ", " << aPntProj.Z() << ")");
gp_XY aProjXY = gp_XY(aPntProj.X(), aPntProj.Y());
aProjXY.Subtract(thePoint);
DEBTRACE("Projection aborted : non centered profile");
return aResAltitude;
}
+
+ // get the point with the same param on altitude profile
+ double zRef = 0; //aPntProj.Z();
+ TopoDS_Shape aShapeUZ = aGuideUZ->GetShape();
+ if (!aShapeUZ.IsNull())
+ {
+ TopExp_Explorer anExpUZ(aShapeUZ, TopAbs_EDGE);
+ TopoDS_Edge anEdgeUZ;
+ int anI = 0;
+ for (; anExpUZ.More(); anExpUZ.Next(), anI++)
+ {
+ if (anI == anIndex)
+ {
+ anEdgeUZ = TopoDS::Edge(anExpUZ.Current());
+ break;
+ }
+ }
+ if (!anEdgeUZ.IsNull())
+ {
+ double anEdgePars[2];
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdgeUZ, anEdgePars[0], anEdgePars[1]);
+ gp_Pnt aVal;
+ aCurve->D0(aParam, aVal);
+ DEBTRACE("altitude point: " << aVal.X() << " "<< aVal.Y() << " "<< aVal.Z());
+ zRef = aVal.Y();
+ }
+ else zRef = 20;
+ }
+ else zRef = 20;
+
+ // distance on section to get altitude
if (i1 == aProfilePoints.Size()) // distance >= profile width
{
- aResAltitude = aPntProj.Z() + pt1.Y();
+ aResAltitude = zRef + pt1.Y();
}
else
{
double z = pt1.Y() + (pt2.Y() - pt1.Y())*(distance -pt1.X())/(pt2.X()-pt1.X());
- aResAltitude = aPntProj.Z() + z;
+ aResAltitude = zRef + z;
}
- DEBTRACE("altitude: " << aResAltitude << " delta: " << aResAltitude - aPntProj.Z());
+ DEBTRACE("altitude: " << aResAltitude << " delta: " << aResAltitude - zRef);
return aResAltitude;
}
}