Salome HOME
Merge branch 'BR_v14_rc' into BR_SINUSX_FORMAT
[modules/hydro.git] / src / HYDROData / HYDROData_ProfileUZ.cxx
index a551f43f2d49248f38bd3df1f8284d12e51cb182..1189970cb45bfe753c1ae92687a2a2eec03186eb 100755 (executable)
@@ -32,6 +32,9 @@
 
 #include <TopoDS_Shape.hxx>
 
+#include <HYDROData_Profile.h>
+#include <HYDROData_PolylineXY.h>
+
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ProfileUZ, HYDROData_IPolyline)
@@ -275,4 +278,36 @@ HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theS
   return aResList;
 }
 
+void HYDROData_ProfileUZ::CalculateAndAddPoints(const NCollection_Sequence<gp_XYZ>& theXYZPoints, Handle_HYDROData_PolylineXY& thePolylineXY)
+{
+   // Fill 2D polyline
+  for ( int i = 1; i <= theXYZPoints.Size(); i++ ) {
+    const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
+    thePolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+  }
+  
+  // Calculate profile UZ points
+
+  // First point
+  const HYDROData_Profile::ProfilePoint& aFirstBottomPoint = theXYZPoints.First();
+  AddPoint( 0, HYDROData_ProfileUZ::Point( 0, aFirstBottomPoint.Z() ) );
+
+  // Intermediate points
+  double aPolylineCommonDist = thePolylineXY->GetDistance( 0, thePolylineXY->NbPoints( 0 ) - 1 );
+
+  for ( int i = 2, aNbPoints = theXYZPoints.Size(); i < aNbPoints; i++ ) {
+    const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
+    
+    double aDistance = thePolylineXY->GetDistance( 0, i - 1 );
+    
+    Standard_Real anU = aDistance; // = ( aDistance / aPolylineCommonDist ) * aPolylineCommonDist;
+    AddPoint( 0, HYDROData_ProfileUZ::Point( anU, aBottomPoint.Z() ) );
+  }
+  
+  // Last point
+  const HYDROData_Profile::ProfilePoint& aLastBottomPoint = theXYZPoints.Last();
+  AddPoint( 0, HYDROData_ProfileUZ::Point( aPolylineCommonDist, aLastBottomPoint.Z() ) );
+}
+