Salome HOME
fix test on stream linear interpolation
[modules/hydro.git] / src / HYDROData / HYDROData_ChannelAltitude.cxx
index d3c0008ee321a7e5d799a34783767989797bf31d..5467a236a944ab05535c689f998bb341d1876385 100644 (file)
@@ -26,8 +26,9 @@
 #include "HYDROData_PolylineXY.h"
 #include "HYDROData_ProfileUZ.h"
 #include "HYDROData_Profile.h"
+#include <TDataStd_Integer.hxx>
 
-#define _DEVDEBUG_
+//#define _DEVDEBUG_
 #include "HYDRO_trace.hxx"
 #include <QString>
 
@@ -287,7 +288,10 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
 
           distance *= aSign;
           DEBTRACE("distance to guideline " << distance);
-          
+
+          if (GetInvertDirection())
+            distance*=-1;
+
           // get delta altitude on section (supposed symmetric) from guideline distance (aParam)
           double delta = 0;
           int i1 = 0;
@@ -313,7 +317,7 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
             }
           if ((i1 == 0) && (i2 == 0))
             {
-              DEBTRACE("Projection aborted: non centered profile");
+              DEBTRACE("Projection aborted : non centered profile");
               return aResAltitude;
             }
           else if (i1 == 0)  // distance <  - profile width
@@ -346,5 +350,27 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
 }
 
 
+void HYDROData_ChannelAltitude::SetInvertDirection(bool IsInverted)
+{
+  if ( GetInvertDirection() == IsInverted )
+    return;
+
+  TDataStd_Integer::Set( myLab.FindChild( DataTag_InvertDirection ), (Standard_Integer)IsInverted );
+}
+
+bool HYDROData_ChannelAltitude::GetInvertDirection() const
+{
+  bool aRes = false;
+
+  TDF_Label aLabel = myLab.FindChild( DataTag_InvertDirection, false );
+  if ( !aLabel.IsNull() )
+  {
+    Handle(TDataStd_Integer) anIntVal;
+    if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) )
+      aRes = (bool)anIntVal->Get();
+  }
+
+  return aRes;
+}