Salome HOME
Refs #289 - Spline profile is represented in OCC view as polyline profile
[modules/hydro.git] / src / HYDROData / HYDROData_Polyline3D.cxx
index 0507b2e8bcba9ce1396bdbbdb563a0561e1da307..67fe1a88f3d26daecbebc3274c9a390a3ec9a90d 100644 (file)
@@ -1,7 +1,7 @@
 
 #include "HYDROData_Polyline3D.h"
 
-#include "HYDROData_Bathymetry.h"
+#include "HYDROData_IAltitudeObject.h"
 #include "HYDROData_Document.h"
 #include "HYDROData_PolylineXY.h"
 #include "HYDROData_Profile.h"
@@ -99,8 +99,8 @@ void HYDROData_Polyline3D::Update()
 
   Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ();
 
-  Handle(HYDROData_Bathymetry) aBathymetry = GetBathymetry();
-  if ( !aBathymetry.IsNull() )
+  Handle(HYDROData_IAltitudeObject) anAltitude = GetAltitudeObject();
+  if ( !anAltitude.IsNull() )
     aProfileUZ = GetChildProfileUZ();
 
   if ( aProfileUZ.IsNull() )
@@ -217,7 +217,7 @@ bool HYDROData_Polyline3D::SetProfileUZ( const Handle(HYDROData_ProfileUZ)& theP
   SetReferenceObject( theProfile, DataTag_ProfileUZ );
 
   // Remove the bathymetry, because one altitude object can be presented at time
-  RemoveBathymetry();
+  RemoveAltitudeObject();
 
   // Indicate model of the need to update the polyline presentation
   SetToUpdate( true );
@@ -243,14 +243,15 @@ void HYDROData_Polyline3D::RemoveProfileUZ()
   SetToUpdate( true );
 }
 
-bool HYDROData_Polyline3D::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry )
+bool HYDROData_Polyline3D::SetAltitudeObject( 
+  const Handle(HYDROData_IAltitudeObject)& theAltitude )
 {
-  Handle(HYDROData_Bathymetry) aPrevBathymetry = GetBathymetry();
+  Handle(HYDROData_IAltitudeObject) aPrevAltitude = GetAltitudeObject();
 
-  if ( !HYDROData_Object::SetBathymetry( theBathymetry ) )
+  if ( !HYDROData_Object::SetAltitudeObject( theAltitude ) )
     return false;
 
-  if ( IsEqual( aPrevBathymetry, theBathymetry ) )
+  if ( IsEqual( aPrevAltitude, theAltitude ) )
     return true;
 
   // Remove the u,z profile, because one altitude object can be presented at time
@@ -263,9 +264,9 @@ bool HYDROData_Polyline3D::SetBathymetry( const Handle(HYDROData_Bathymetry)& th
 }
 
 
-void HYDROData_Polyline3D::RemoveBathymetry()
+void HYDROData_Polyline3D::RemoveAltitudeObject()
 {
-  HYDROData_Object::RemoveBathymetry();
+  HYDROData_Object::RemoveAltitudeObject();
 
   // Remove the child profile object 
   removeChildProfileUZ();
@@ -299,11 +300,11 @@ Handle(HYDROData_ProfileUZ) HYDROData_Polyline3D::GetChildProfileUZ( const bool
 }
 
 HYDROData_IPolyline::PointsList generateProfileUZPoints(
-  const Handle(HYDROData_PolylineXY)& thePolyline,
-  const Handle(HYDROData_Bathymetry)& theBathymetry )
+  const Handle(HYDROData_PolylineXY)&      thePolyline,
+  const Handle(HYDROData_IAltitudeObject)& theAltitude )
 {
   HYDROData_IPolyline::PointsList aPointsList;
-  if ( thePolyline.IsNull() || theBathymetry.IsNull() )
+  if ( thePolyline.IsNull() || theAltitude.IsNull() )
     return aPointsList;
 
   bool anIsSectionClosed = thePolyline->IsClosedSection( 0 );
@@ -317,7 +318,9 @@ HYDROData_IPolyline::PointsList generateProfileUZPoints(
     const HYDROData_PolylineXY::Point& aSectPoint = aPolylinePoints.Value( i );
 
     double aPointDistance = thePolyline->GetDistance( 0, i - 1 );
-    double aPointDepth = theBathymetry->GetAltitudeForPoint( aSectPoint );
+    double aPointDepth = theAltitude->GetAltitudeForPoint( aSectPoint );
+    if( aPointDepth == theAltitude->GetInvalidAltitude() )
+      aPointDepth = 0.0;
 
     HYDROData_IPolyline::Point anAltitudePoint( aPointDistance, aPointDepth );
     aPointsList.Append( anAltitudePoint );
@@ -328,8 +331,8 @@ HYDROData_IPolyline::PointsList generateProfileUZPoints(
 
 void HYDROData_Polyline3D::updateChildProfilePoints()
 {
-  Handle(HYDROData_Bathymetry) aBathymetry = GetBathymetry();
-  if ( aBathymetry.IsNull() )
+  Handle(HYDROData_IAltitudeObject) anAltitude = GetAltitudeObject();
+  if ( anAltitude.IsNull() )
     return;
 
   Handle(HYDROData_ProfileUZ) aChildProfileUZ = GetChildProfileUZ();
@@ -342,7 +345,7 @@ void HYDROData_Polyline3D::updateChildProfilePoints()
     return;
 
   HYDROData_IPolyline::PointsList aProfilePoints = 
-    generateProfileUZPoints( GetPolylineXY(), GetBathymetry() );
+    generateProfileUZPoints( GetPolylineXY(), anAltitude );
   aProfile->SetParametricPoints( aProfilePoints );
 
   aProfile->Update();