Salome HOME
6.12.2013.Fix of HasIntersection method.
[modules/hydro.git] / src / HYDROData / HYDROData_ProfileUZ.cxx
index 36ce31c6a528c9b03c6534072d23fa43c11e3c3d..80fe9987309b306ecf9dc7ac997a2718e8577ec7 100755 (executable)
@@ -4,12 +4,13 @@
 #include "HYDROData_Tool.h"
 
 #include <gp_XY.hxx>
+#include <gp_Pnt2d.hxx>
 
 #include <TColStd_ListIteratorOfListOfReal.hxx>
 
 #include <TDataStd_RealList.hxx>
 
-#include <TopoDS_Wire.hxx>
+#include <TopoDS_Shape.hxx>
 
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline)
@@ -24,10 +25,46 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ()
 {
 }
 
-TopoDS_Wire HYDROData_ProfileUZ::GetWire() const
+TopoDS_Shape HYDROData_ProfileUZ::GetShape()
 {
   // TODO
-  return TopoDS_Wire();
+  return TopoDS_Shape();
+}
+
+double HYDROData_ProfileUZ::GetDepthFromDistance( const double& theDistance ) const
+{
+  double aResDepth = 0.0;
+
+  HYDROData_IPolyline::PointsList aPoints = GetPoints();
+  int aNbPoints = aPoints.Size();
+  if ( aNbPoints < 2 )
+    return aResDepth;
+
+  double aCompDist = 0.0;
+  HYDROData_IPolyline::Point aPrevPoint = aPoints.First();
+  for ( int i = 2; i <= aNbPoints; ++i )
+  {
+    const Point& aCurPoint = aPoints.Value( i );
+
+    double aPntDist = gp_Pnt2d( aPrevPoint.X(), 0 ).Distance( gp_Pnt2d( aCurPoint.X(), 0 ) );
+
+    aCompDist += aPntDist;
+
+    if ( theDistance < aCompDist )
+    {
+      double aComPntDist = gp_Pnt2d( aPoints.First().X(), 0 ).Distance( gp_Pnt2d( aPrevPoint.X(), 0 ) );
+
+      double aFindDist = theDistance - aComPntDist;
+      double aRatio = aFindDist / ( aPntDist - aFindDist );
+
+      aResDepth = ( aPrevPoint.Y() + aRatio * aCurPoint.Y() ) / ( 1 + aRatio );
+      break;
+    }
+
+    aPrevPoint = aCurPoint;
+  }
+
+  return aResDepth;
 }
 
 int HYDROData_ProfileUZ::NbSections() const
@@ -35,7 +72,29 @@ int HYDROData_ProfileUZ::NbSections() const
   return 1;
 }
 
-void HYDROData_ProfileUZ::AddSection( const bool /*theIsClosed*/ )
+void HYDROData_ProfileUZ::AddSection( const TCollection_AsciiString& /*theSectName*/,
+                                      const SectionType              /*theSectionType*/,
+                                      const bool                     /*theIsClosed*/ )
+{
+}
+
+TCollection_AsciiString HYDROData_ProfileUZ::GetSectionName( const int /*theSectionIndex*/ ) const
+{
+  return "Section_1";
+}
+
+void HYDROData_ProfileUZ::SetSectionName( const int                      /*theSectionIndex*/, 
+                                          const TCollection_AsciiString& /*theSectionName*/ )
+{
+}
+
+HYDROData_ProfileUZ::SectionType HYDROData_ProfileUZ::GetSectionType( const int /*theSectionIndex*/ ) const
+{
+  return SECTION_POLYLINE;
+}
+
+void HYDROData_ProfileUZ::SetSectionType( const int         /*theSectionIndex*/, 
+                                          const SectionType /*theSectionType*/ )
 {
 }
 
@@ -44,6 +103,11 @@ bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const
   return false;
 }
 
+void HYDROData_ProfileUZ::SetSectionClosed( const int  /*theSectionIndex*/, 
+                                            const bool /*theIsClosed*/ )
+{
+}
+
 void HYDROData_ProfileUZ::RemoveSection( const int /*theSectionIndex*/ )
 {
   RemoveSections();
@@ -118,8 +182,8 @@ void HYDROData_ProfileUZ::AddPoint( const int    /*theSectionIndex*/,
 }
 
 void HYDROData_ProfileUZ::SetPoint( const int    theSectionIndex,
-                                    const int    /*thePointIndex*/,
-                                    const Point& thePoint )
+                                    const Point& thePoint,
+                                    const int    /*thePointIndex*/ )
 {
   AddPoint( theSectionIndex, thePoint );
 }