return getShape3D();
}
+//TopoDS_Wire HYDROData_Channel::GetLeftBank() const
+//{
+//
+//}
+
bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
const Handle(HYDROData_Profile)& theProfile,
PrsDefinition& thePrs )
SetShape3D( aResultPrs.myPrs3D );
SetTopShape( aResultPrs.myPrs2D );
+// TopoDS_Wire aPrevLeftBank = GetLeftBank();
+// if ( ! aPrevLeftBank.IsNull() )
+// ClearReferenceObjects( DataTag_LeftBank );
+// SetReferenceObject( aResultPrs.myLeftBank, DataTag_LeftBank );
+
// Create groups for channel
TopTools_SequenceOfShape aLeftBankEdges;
HYDROData_ShapesTool::ExploreShapeToShapes( aResultPrs.myLeftBank, TopAbs_EDGE, aLeftBankEdges );
// Store the valid solution.
hasValidSolution = Standard_True;
- // Normalize parameter.
- TopoDS_Edge aSupportEdge = TopoDS::Edge(aSupportShape);
- Standard_Real aF, aL;
- BRep_Tool::Range(aSupportEdge, aF, aL);
- if (Abs(aL - aF) <= aTolConf)
+ DEBTRACE("distance XY: "<< aParam);
+// // 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);
+
+ // profile altitude at projection point
+ HYDROData_IPolyline::PointsList aProfilePoints = aGuideUZ->GetPoints();
+ if ( aProfilePoints.IsEmpty() )
{
- DEBTRACE("Projection aborted : degenerated projection edge");
+ DEBTRACE("empty profile UZ");
return aResAltitude;
}
- aParam = (aParam - aF)/(aL - aF);
+ double aDepth = HYDROData_ProfileUZ::GetDepthFromDistance( aProfilePoints, aParam );
+ DEBTRACE("profile altitude: " << aDepth);
// Compute edge index.
TopExp_Explorer anExp(aShape, TopAbs_EDGE);
}
}
- // Construct a projection vertex.
+ // get the XY distance from point to guideline
const gp_Pnt &aPntProj = aDistShSh.PointOnShape2(i);
-// 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);
double distance = aProjXY.Modulus();
- DEBTRACE("distance " << distance);
+ DEBTRACE("distance to guideline " << distance);
+
+ // get delta altitude on section (supposed symmetric) from guideline distance
+ double delta = 0;
int i1 = 0;
gp_XY pt1 = gp_XY();
gp_XY pt2 = gp_XY();
- HYDROData_ProfileUZ::PointsList aProfilePoints = aProfile->GetParametricPoints();
- for ( int i = 1, aNbPoints = aProfilePoints.Size(); i <= aNbPoints; ++i )
+ HYDROData_ProfileUZ::PointsList aSectionPoints = aProfile->GetParametricPoints();
+ for ( int i = 1, aNbPoints = aSectionPoints.Size(); i <= aNbPoints; ++i )
{
- const HYDROData_IPolyline::Point& aPolylinePoint = aProfilePoints.Value( i );
+ const HYDROData_IPolyline::Point& aPolylinePoint = aSectionPoints.Value( i );
DEBTRACE(" profile point: " << aPolylinePoint.X() << " " << aPolylinePoint.Y());
if (aPolylinePoint.X() < distance)
{
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 = zRef + pt1.Y();
+ delta = pt1.Y();
}
else
{
- double z = pt1.Y() + (pt2.Y() - pt1.Y())*(distance -pt1.X())/(pt2.X()-pt1.X());
- aResAltitude = zRef + z;
+ delta = pt1.Y() + (pt2.Y() - pt1.Y())*(distance -pt1.X())/(pt2.X()-pt1.X());
}
- DEBTRACE("altitude: " << aResAltitude << " delta: " << aResAltitude - zRef);
+ aResAltitude = delta + aDepth;
+ DEBTRACE("final altitude: " << aResAltitude << " delta: " << delta);
return aResAltitude;
}
}