From: asl Date: Fri, 21 Aug 2015 13:06:02 +0000 (+0300) Subject: refs #640: correct width for non-georeferenced profile X-Git-Tag: BR_quadtree_20150925~2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e97e1872f423c498db548a551efc1221f9b99e89;p=modules%2Fhydro.git refs #640: correct width for non-georeferenced profile --- diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index 819e3030..a2bb6f47 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -220,7 +220,7 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& } // Get the profile middle point ( 3D ) - gp_Pnt aMiddlePoint( theProfile->GetMiddlePoint() ); + gp_Pnt aMiddlePoint( theProfile->GetMiddlePoint( true ) ); // Translate the profile to each point on the guide line ( 3D ) Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aNbPoints ); diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index cef87e2f..2649e2b0 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -187,7 +187,7 @@ void HYDROData_Profile::Update() { HYDROData_Object::Update(); - TopoDS_Shape aShape = CreateProfileWire( false ); + TopoDS_Shape aShape = CreateProfileWire( true ); SetShape3D( aShape ); } @@ -251,7 +251,7 @@ bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal, thePoint = GetParametricPoints().First(); - thePoint.SetX( 0 ); + //thePoint.SetX( 0 ); thePoint.SetY( 0 ); //default left point of not-georeferenced profile TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint, false ); if ( aLabel.IsNull() ) @@ -302,6 +302,7 @@ bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal, return false; thePoint = GetParametricPoints().Last(); + thePoint.SetY( 0 ); TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint, false ); if ( aLabel.IsNull() ) @@ -442,8 +443,8 @@ HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints const HYDROData_ProfileUZ::Point& aFirstParPoint = aParametricPoints.First(); const HYDROData_ProfileUZ::Point& aLastParPoint = aParametricPoints.Last(); - double aGeoDistance = gp_Pnt2d( aFirstPoint ).Distance( aLastPoint ); - double aParCommonDist = gp_Pnt2d( aFirstParPoint.X(), 0 ).Distance( gp_Pnt2d( aLastParPoint.X(), 0 ) ); + double aFullLength = aLastPoint.X() - aFirstPoint.X(); + double aParFullLength = aLastParPoint.X() - aFirstParPoint.X(); // Add first point as is aResPoints.Append( ProfilePoint( aFirstPoint.X(), aFirstPoint.Y(), aFirstParPoint.Y() ) ); @@ -453,14 +454,11 @@ HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints { const HYDROData_ProfileUZ::Point& aParPoint = aParametricPoints.Value( i ); - double aParPointDist = gp_Pnt2d( aFirstParPoint.X(), 0 ).Distance( gp_Pnt2d( aParPoint.X(), 0 ) ); - - double aParLen = ( aParPointDist / aParCommonDist ) * aGeoDistance; - - double aRatio = aParLen / ( aGeoDistance - aParLen ); + double aParPointDist = aParPoint.X() - aFirstParPoint.X(); + double aRatio = aParPointDist / aParFullLength; - double aParX = ( aFirstPoint.X() + aRatio * aLastPoint.X() ) / ( 1 + aRatio ); - double aParY = ( aFirstPoint.Y() + aRatio * aLastPoint.Y() ) / ( 1 + aRatio ); + double aParX = aFirstPoint.X() * (1-aRatio) + aLastPoint.X() * aRatio; + double aParY = aFirstPoint.Y() * (1-aRatio) + aLastPoint.Y() * aRatio; ProfilePoint aCompPoint( aParX, aParY, aParPoint.Y() ); aResPoints.Append( aCompPoint ); @@ -755,12 +753,12 @@ HYDROData_Profile::ProfilePoint HYDROData_Profile::GetBottomPoint() const return aBottom; } - HYDROData_Profile::ProfilePoint HYDROData_Profile::GetMiddlePoint() const + HYDROData_Profile::ProfilePoint HYDROData_Profile::GetMiddlePoint( bool CanUseDefault ) const { ProfilePoint aMiddlePoint; gp_XY aLeftPnt, aRightPnt; - if ( GetLeftPoint( aLeftPnt, false ) && GetRightPoint( aRightPnt, false ) ) { + if ( GetLeftPoint( aLeftPnt, true, CanUseDefault ) && GetRightPoint( aRightPnt, true, CanUseDefault ) ) { gp_XYZ aPnt1( aLeftPnt.X(), aLeftPnt.Y(), 0. ); gp_XYZ aPnt2( aRightPnt.X(), aRightPnt.Y(), 0. ); gp_Pnt aMiddlePoint2d( 0.5 * ( aPnt1 + aPnt2 ) ); diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index fb7edcd7..997c617c 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -200,7 +200,7 @@ public: * Return profile middle point. * \return non-parametric profile point */ - HYDRODATA_EXPORT ProfilePoint GetMiddlePoint() const; + HYDRODATA_EXPORT ProfilePoint GetMiddlePoint( bool CanUseDefault ) const; public: // Public methods to work with files.