From: Paul RASCLE Date: Wed, 12 Aug 2015 08:48:40 +0000 (+0200) Subject: get altitude with GetDepthFromDistance function OK, housekeeping needed X-Git-Tag: BR_quadtree_20150925~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0eb6230e5da284d5966b4c688afd48fe91abbb01;p=modules%2Fhydro.git get altitude with GetDepthFromDistance function OK, housekeeping needed --- diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index 04b316c9..3ac722fb 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -126,6 +126,11 @@ TopoDS_Shape HYDROData_Channel::GetShape3D() const return getShape3D(); } +//TopoDS_Wire HYDROData_Channel::GetLeftBank() const +//{ +// +//} + bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine, const Handle(HYDROData_Profile)& theProfile, PrsDefinition& thePrs ) @@ -318,6 +323,11 @@ void HYDROData_Channel::Update() 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 ); diff --git a/src/HYDROData/HYDROData_Channel.h b/src/HYDROData/HYDROData_Channel.h index a53db842..55a26aa7 100644 --- a/src/HYDROData/HYDROData_Channel.h +++ b/src/HYDROData/HYDROData_Channel.h @@ -58,6 +58,7 @@ protected: DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve DataTag_GuideLine, DataTag_Profile, +// DataTag_LeftBank, }; public: @@ -100,7 +101,12 @@ public: */ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const; - /** +// /** +// * Returns the left bank of the object. +// */ +// HYDRODATA_EXPORT virtual TopoDS_Wire GetLeftBank() const; + + /** * Update the shape presentations of stream. * Call this method whenever you made changes for channel data. */ diff --git a/src/HYDROData/HYDROData_ChannelAltitude.cxx b/src/HYDROData/HYDROData_ChannelAltitude.cxx index 1b1111c4..7d985833 100644 --- a/src/HYDROData/HYDROData_ChannelAltitude.cxx +++ b/src/HYDROData/HYDROData_ChannelAltitude.cxx @@ -256,16 +256,27 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c // 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); @@ -278,21 +289,23 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c } } - // 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) { @@ -310,47 +323,16 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) c 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; } }