]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
draft version of the DTM object
authorasl <asl@opencascade.com>
Tue, 6 Sep 2016 13:13:29 +0000 (16:13 +0300)
committerasl <asl@opencascade.com>
Tue, 6 Sep 2016 13:13:29 +0000 (16:13 +0300)
17 files changed:
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROData/HYDROData_DTM.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_DTM.h [new file with mode: 0644]
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_PolylineOperator.cxx
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROData/HYDROData_Profile.h
src/HYDROData/HYDROData_TopoCurve.cxx
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/ExternalFiles.cmake
src/HYDRO_tests/test_HYDROData_DTM.cxx [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_DTM.h [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_Main.cxx

index 86edacf83dfe9c2622c16467b8f4432798e678e6..e831498a3e37a1eecca2a0d019fa42384b04860d 100644 (file)
@@ -63,7 +63,7 @@ set(PROJECT_HEADERS
     HYDROData_ShapeFile.h
     HYDROData_LandCoverMap.h
     HYDROData_LCM_FaceClassifier.h
-   
+    HYDROData_DTM.h   
 )
 
 set(PROJECT_SOURCES 
@@ -125,7 +125,7 @@ set(PROJECT_SOURCES
     HYDROData_ShapeFile.cxx
     HYDROData_LandCoverMap.cxx
     HYDROData_LCM_FaceClassifier.cxx
-
+    HYDROData_DTM.cxx
  )
 
 add_definitions(
index db67785251b498ab336b59558fa7ecd0620a815a..22b007881fef20d4642d656a9e322d08d02f42aa 100644 (file)
@@ -20,6 +20,7 @@
 #include "HYDROData_Document.h"
 #include "HYDROData_Tool.h"
 #include "HYDROData_PolylineXY.h"
+#include "HYDROData_QuadtreeNode.hxx"
 
 #include <gp_XY.hxx>
 #include <gp_XYZ.hxx>
index 1fed12a2b4a6be2b0d23a099ab93c1be5207c6e2..1cffaaf27919a943c65b36ef19fee097b2d83cb2 100644 (file)
 #define HYDROData_Bathymetry_HeaderFile
 
 #include "HYDROData_IAltitudeObject.h"
-#include "HYDROData_QuadtreeNode.hxx"
-
-#ifndef LIGHT_MODE
-#include <vtkPolyData.h>
-#include <vtkIdList.h>
-#endif
 
 class QFile;
 class gp_XYZ;
 class gp_XY;
 class Handle_HYDROData_PolylineXY;
-
+class HYDROData_QuadtreeNode;
+class vtkPolyData;
+class vtkIdList;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
 
diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx
new file mode 100644 (file)
index 0000000..a80edf2
--- /dev/null
@@ -0,0 +1,191 @@
+
+#include <HYDROData_DTM.h>
+#include <HYDROData_Profile.h>
+
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2dAPI_Interpolate.hxx>
+#include <TColgp_HArray1OfPnt2d.hxx>
+#include <TColgp_Array1OfVec2d.hxx>
+#include <TColStd_HArray1OfBoolean.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopExp_Explorer.hxx>
+#include <BRep_Tool.hxx>
+#include <gp_Ax3.hxx>
+#include <Geom_Line.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+
+IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
+IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
+
+HYDROData_DTM::HYDROData_DTM()
+{
+}
+
+HYDROData_DTM::~HYDROData_DTM()
+{
+}
+
+
+void GetProperties( const Handle_HYDROData_Profile& theProfile,
+                    gp_Pnt& theLowestPoint,
+                    gp_Vec2d& theDir,
+                    bool isNormalDir )
+{
+  theLowestPoint = theProfile->GetBottomPoint();
+  
+  gp_XY aLeft, aRight;
+  theProfile->GetLeftPoint( aLeft, true, true );
+  theProfile->GetRightPoint( aRight, true, true );
+  double x = aRight.X()-aLeft.X();
+  double y = aRight.Y()-aLeft.Y();
+  if( isNormalDir )
+    theDir = gp_Vec2d( -y, x );
+  else
+    theDir = gp_Vec2d( x, y );
+}
+
+inline gp_Pnt2d To2D( const gp_Pnt& thePnt, const gp_Trsf& theTr )
+{
+  gp_Pnt p = thePnt.Transformed( theTr );
+  return gp_Pnt2d( p.X(), p.Z() );
+}
+
+Handle(TColgp_HArray1OfPnt2d) To2D( const TColgp_Array1OfPnt& thePoints, const gp_Trsf& theTr )
+{
+  int low = thePoints.Lower(), up = thePoints.Upper();
+  Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( low, up );
+  for( int i=low; i<=up; i++ )
+    points->SetValue( i, To2D( thePoints.Value( i ), theTr ) );
+  return points;
+}
+
+Handle(Geom2d_Curve) CurveTo2D( const Handle(Geom_Curve)& theCurve, 
+                                Standard_Real theFirst, Standard_Real theLast,
+                                const gp_Trsf& theTr )
+{
+  if( theCurve->IsKind( STANDARD_TYPE( Geom_Line ) ) )
+  {
+    gp_Pnt aFirstPnt, aLastPnt;
+    theCurve->D0( theFirst, aFirstPnt );
+    theCurve->D0( theLast, aLastPnt );
+
+    gp_Pnt2d
+      aFirst2d = To2D( aFirstPnt, theTr ),
+      aLast2d = To2D( aLastPnt, theTr );
+
+    gp_Vec2d dir( aFirst2d, aLast2d );
+    Handle_Geom2d_Line aLine2d = new Geom2d_Line( aFirst2d, gp_Dir2d( dir.X(), dir.Y() ) );
+    return new Geom2d_TrimmedCurve( aLine2d, 0, aLast2d.Distance( aFirst2d ) );
+  }
+
+  if( theCurve->IsKind( STANDARD_TYPE( Geom_BSplineCurve ) ) )
+  {
+    Handle(Geom_BSplineCurve) aSpline = Handle(Geom_BSplineCurve)::DownCast( theCurve );
+
+    Handle(TColgp_HArray1OfPnt2d) poles = To2D( aSpline->Poles(), theTr );
+    const TColStd_Array1OfReal& knots = aSpline->Knots();
+    const TColStd_Array1OfInteger& multiplicities = aSpline->Multiplicities();
+    int aDegree = aSpline->Degree();
+
+    return new Geom2d_BSplineCurve( poles->Array1(), knots, multiplicities, aDegree );
+  }
+
+  return Handle(Geom2d_Curve)();
+}
+
+Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis( 
+  const std::vector<Handle_HYDROData_Profile>& theProfiles )
+{
+  size_t n = theProfiles.size();
+  Handle_Geom2d_BSplineCurve aResult;
+
+  Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, (int)n );
+  TColgp_Array1OfVec2d tangents( 1, (int)n );
+  Handle(TColStd_HArray1OfBoolean) flags = new TColStd_HArray1OfBoolean( 1, (int)n );
+
+  for( size_t i = 1; i <= n; i++ )
+  {
+    Handle_HYDROData_Profile aProfile = theProfiles[i-1];
+    gp_Pnt aLowest;
+    gp_Vec2d aTangent;
+    GetProperties( aProfile, aLowest, aTangent, true );
+    aTangent.Normalize();
+
+    points->SetValue( (int)i, gp_Pnt2d( aLowest.X(), aLowest.Y() ) );
+    tangents.SetValue( (int)i, aTangent );
+    flags->SetValue( (int)i, Standard_True );
+  }
+
+  Geom2dAPI_Interpolate anInterpolator( points, Standard_False, Standard_False );
+  anInterpolator.Load( tangents, flags );
+  anInterpolator.Perform();
+  if( anInterpolator.IsDone() )
+    aResult = anInterpolator.Curve();
+  return aResult;
+}
+
+std::vector<Handle_Geom2d_Curve> HYDROData_DTM::ProfileToParametric( const Handle_HYDROData_Profile& theProfile )
+{
+  std::vector<Handle_Geom2d_Curve> curves;
+  theProfile->Update();
+  
+  // Transformation of the coordinate systems
+  gp_Pnt aLowest;
+  gp_Vec2d aDir;
+  GetProperties( theProfile, aLowest, aDir, false );
+
+  gp_Ax3 aStd3d( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( 1, 0, 0 ) );
+  gp_Ax3 aLocal( aLowest, gp_Dir( 0, 0, 1 ), gp_Dir( aDir.X(), aDir.Y(), 0 ) );
+
+  gp_Trsf aTransf;
+  aTransf.SetTransformation( aStd3d, aLocal );
+
+  // Iteration via edges
+  TopoDS_Wire aWire = TopoDS::Wire( theProfile->GetShape3D() );
+  TopExp_Explorer anExp( aWire, TopAbs_EDGE );
+  for( ; anExp.More(); anExp.Next() )
+  {
+    // Extract an edge from wire
+    TopoDS_Edge anEdge = TopoDS::Edge( anExp.Current() );
+
+    // Extract a curve corresponding to the edge
+    TopLoc_Location aLoc;
+    Standard_Real aFirst, aLast;
+    Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aLoc, aFirst, aLast );
+
+    // Convert the curve to 2d CS
+    Handle(Geom2d_Curve) aCurve2d = CurveTo2D( aCurve, aFirst, aLast, aTransf );
+    if( !aCurve2d.IsNull() )
+      curves.push_back( aCurve2d );
+  }
+  return curves;
+}
+
+void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& theProfile, 
+                                           double theMinZ, double theMaxZ, double theDDZ,
+                                           CurveUZ& theMidPointCurve,
+                                           CurveUZ& theWidthCurve )
+{
+  /*for( double z = theMinZ; z<=theMaxZ; z += theDDZ )
+  {
+
+  }*/
+}
+
+void HYDROData_DTM::Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
+                                 int theNbSteps, std::vector<CurveUZ>& theInterpolation )
+{
+}
+
+void HYDROData_DTM::CurveTo3d( const CurveUZ& theCurve, const CurveUZ& theCurveB, 
+                               int theNbSteps, std::vector<CurveUZ>& theInterpolation )
+{
+}
diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h
new file mode 100644 (file)
index 0000000..a91357e
--- /dev/null
@@ -0,0 +1,86 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_DTM_HeaderFile
+#define HYDROData_DTM_HeaderFile
+
+#include "HYDROData_Bathymetry.h"
+#include <vector>
+
+class Handle_HYDROData_Profile;
+class Handle_Geom2d_BSplineCurve;
+class Handle_Geom2d_Curve;
+
+DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
+
+/**\class HYDROData_DTM
+ * \brief Class that represents the Digital Terrain Model
+ */
+class HYDROData_DTM : public HYDROData_Bathymetry
+{
+protected:
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
+  };
+
+public:
+  DEFINE_STANDARD_RTTI( HYDROData_DTM );
+
+protected:
+  friend class HYDROData_Iterator;
+  friend class test_HYDROData_DTM;
+
+  HYDRODATA_EXPORT HYDROData_DTM();
+  virtual HYDRODATA_EXPORT ~HYDROData_DTM();
+
+  struct PointUZ
+  {
+    double U;
+    double Z;
+  };
+  class CurveUZ : public std::vector<PointUZ>
+  {
+  public:
+    CurveUZ( double theXCurv );
+    ~CurveUZ();
+
+  private:
+    double Xcurv;
+  };
+
+  static Handle_Geom2d_BSplineCurve CreateHydraulicAxis( const std::vector<Handle_HYDROData_Profile>& theProfiles );
+
+  static std::vector<Handle_Geom2d_Curve> ProfileToParametric( const Handle_HYDROData_Profile& theProfile );
+
+  static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile, 
+                                     double theMinZ, double theMaxZ, double theDDZ,
+                                     CurveUZ& theMidPointCurve,
+                                     CurveUZ& theWidthCurve );
+
+  static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
+                           int theNbSteps, std::vector<CurveUZ>& theInterpolation );
+
+  static void CurveTo3d( const CurveUZ& theCurve, const CurveUZ& theCurveB, 
+                         int theNbSteps, std::vector<CurveUZ>& theInterpolation );
+};
+
+#endif
index 51186e607beed5a9c755f78d1b15c17e2875d2f0..a38e771dd47ba9a8499061bc6a34835b23e38882 100644 (file)
@@ -65,6 +65,7 @@ const ObjectKind KIND_STRICKLER_TABLE     = 26;
 const ObjectKind KIND_LAND_COVER_OBSOLETE = 27;
 const ObjectKind KIND_CHANNEL_ALTITUDE    = 28;
 const ObjectKind KIND_LAND_COVER_MAP      = 29;
+const ObjectKind KIND_DTM                 = 30;
 const ObjectKind KIND_LAST                = KIND_LAND_COVER_MAP;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
index 09c6dee2d3e6fac1368b9090fe6a2353e7a99db0..8382162a3f1c6fa36fdf491f637941a7e0bb57a9 100644 (file)
@@ -44,6 +44,7 @@
 #include "HYDROData_VisualState.h"
 #include "HYDROData_Zone.h"
 #include "HYDROData_StricklerTable.h"
+#include "HYDROData_DTM.h"
 
 #include <TDataStd_Name.hxx>
 #include <TDataStd_NamedData.hxx>
@@ -160,6 +161,7 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel )
     case KIND_LAND_COVER_OBSOLETE: break;
     case KIND_CHANNEL_ALTITUDE:   aResult = new HYDROData_ChannelAltitude();      break;
     case KIND_LAND_COVER_MAP:     aResult = new HYDROData_LandCoverMap();         break;
+    case KIND_DTM:                aResult = new HYDROData_DTM();                  break;
     default:                       break;
   }
 
index 240db460801d73ff059a86480fb879f8ec4a80ab..f2570cfe08970263164b2e063f6b1d50a308c686 100644 (file)
@@ -313,7 +313,7 @@ void HYDROData_Object::checkAndSetAltitudeObject()
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
 
   ObjectKind anAltitudeObjectType = getAltitudeObjectType();
-  DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType);
+  //DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType);
   if ( anAltitudeObjectType == KIND_UNKNOWN )
     return; // No need to create altitude object
 
index c311866ad13104080b00befaaab77978511348cd..fd4a5edcd397fd155d866c3e9d177bedf8fec365 100644 (file)
@@ -236,11 +236,11 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD
       aSplitCurves.end();
     for (int iw=0; aCIt != aLastCIt; ++aCIt, iw++)
     {
-      std::stringstream brepName;
+      /*std::stringstream brepName;
       brepName << "theSplitWire_";
       brepName << iw;
       brepName << ".brep";
-      BRepTools::Write(aCIt->Wire() , brepName.str().c_str() );
+      BRepTools::Write(aCIt->Wire() , brepName.str().c_str() );*/
       aResult.push_back(aCIt->Wire());
     }
   }
index 6013e6538a56a8bb7e1e0850bbb239ed1c24e010..fc97524992fc8faa9c0e97234727ab7e7d6fbe6d 100644 (file)
@@ -624,9 +624,9 @@ bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape,
   if ( theShape.IsNull() )
     return false;
 
-  std::string brepName = this->GetName().toStdString();
-  brepName += ".brep";
-  BRepTools::Write( theShape, brepName.c_str() );
+  //std::string brepName = this->GetName().toStdString();
+  //brepName += ".brep";
+  //BRepTools::Write( theShape, brepName.c_str() );
 
   RemoveSections();
 
index 5bcc450da7a182a4503ace453f15920e1c00e90d..f35b5c00cb495584b368d544a070ae92a3862941 100644 (file)
@@ -20,7 +20,6 @@
 #define HYDROData_Profile_HeaderFile
 
 #include "HYDROData_Object.h"
-
 #include "HYDROData_ProfileUZ.h"
 
 DEFINE_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object)
index a69395d4881490478addfbc8504bb7e2cb6294f5..c08d6bf6d84d324194718d02d6a16912092935be 100644 (file)
@@ -660,9 +660,9 @@ int HYDROData_TopoCurve::Intersect(
   const TopoDS_Wire& theWire,
   std::deque<std::list<double> >& theParameters) const
 {
-  std::string brepName = "theWireToIntersect";
-  brepName += ".brep";
-  BRepTools::Write( theWire, brepName.c_str() );
+  //std::string brepName = "theWireToIntersect";
+  //brepName += ".brep";
+  //BRepTools::Write( theWire, brepName.c_str() );
 
   int aIntCount = 0;
   theParameters.resize(myEdges.size());
index 8ff5e1c01e884c1310ac57a611748fd37832c498..47a3e94279e3af65b92317c82677a396f05984a0 100644 (file)
@@ -20,6 +20,7 @@ set(PROJECT_HEADERS
   test_HYDROGUI_Shape.h
   test_HYDROGUI_LandCoverMapDlg.h
   test_Dependencies.h
+  test_HYDROData_DTM.h
 
   TestShape.h
   TestViewer.h
@@ -41,6 +42,7 @@ set(PROJECT_SOURCES
   test_HYDROData_Profile.cxx
   test_HYDROData_ShapeFile.cxx
   test_HYDROData_StricklerTable.cxx
+  test_HYDROData_DTM.cxx
   test_HYDROGUI_ListModel.cxx
   test_HYDROGUI_Shape.cxx
   test_HYDROGUI_LandCoverMapDlg.cxx
index 998b5c7d7f653ea3ec730def39799638e0961411..b137e502fbbcd2b4add149287a94d6e1fa418933 100644 (file)
@@ -58,6 +58,7 @@ set( EXTERNAL_FILES
   ../HYDROData/HYDROData_QuadTree.cxx
   ../HYDROData/HYDROData_QuadTreeNode.cxx
   ../HYDROData/HYDROData_LCM_FaceClassifier.cxx
+  ../HYDROData/HYDROData_DTM.cxx
 
   ../HYDROGUI/HYDROGUI_ListModel.cxx
   ../HYDROGUI/HYDROGUI_DataObject.cxx
diff --git a/src/HYDRO_tests/test_HYDROData_DTM.cxx b/src/HYDRO_tests/test_HYDROData_DTM.cxx
new file mode 100644 (file)
index 0000000..d1189c7
--- /dev/null
@@ -0,0 +1,109 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <test_HYDROData_DTM.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_DTM.h>
+#include <HYDROData_Profile.h>
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <gp_XY.hxx>
+#include <gp_Pnt2d.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+
+const double EPS = 1E-3;
+
+void test_HYDROData_DTM::test_creation()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_DTM) DTM = 
+    Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+
+  CPPUNIT_ASSERT_EQUAL( false, (bool)DTM.IsNull() );
+   
+  aDoc->Close();
+}
+
+void test_HYDROData_DTM::test_profile_conversion_to_2d()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Profile) aProfile1 = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+  Handle(HYDROData_Profile) aProfile2 = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+  NCollection_Sequence<HYDROData_IPolyline::Point> points;
+  points.Append( gp_XY( 0.0, 5.0 ) );
+  points.Append( gp_XY( 1.0, 1.0 ) );
+  points.Append( gp_XY( 1.5, 0.0 ) );
+  points.Append( gp_XY( 4.0, 4.0 ) );
+
+  aProfile1->SetParametricPoints( points );
+  aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+  aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+  aProfile1->SetRightPoint( gp_XY( 20, 20 ) );
+
+  aProfile2->SetParametricPoints( points );
+  aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+  aProfile2->SetLeftPoint( gp_XY( 10, 10 ) );
+  aProfile2->SetRightPoint( gp_XY( 20, 20 ) );
+
+  std::vector<Handle_Geom2d_Curve> curves1 = HYDROData_DTM::ProfileToParametric( aProfile1 );
+  std::vector<Handle_Geom2d_Curve> curves2 = HYDROData_DTM::ProfileToParametric( aProfile2 );
+
+  gp_Pnt2d aFirst, aLast;
+  CPPUNIT_ASSERT_EQUAL( 3, (int)curves1.size() );
+  curves1[0]->D0( curves1[0]->FirstParameter(), aFirst );
+  curves1[0]->D0( curves1[0]->LastParameter(), aLast );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aFirst.X(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   aFirst.Y(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aLast.X(),  EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  1.0,   aLast.Y(),  EPS );
+  curves1[1]->D0( curves1[1]->FirstParameter(), aFirst );
+  curves1[1]->D0( curves1[1]->LastParameter(), aLast );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aFirst.X(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  1.0,   aFirst.Y(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aLast.X(),  EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aLast.Y(),  EPS );
+  curves1[2]->D0( curves1[2]->FirstParameter(), aFirst );
+  curves1[2]->D0( curves1[2]->LastParameter(), aLast );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aFirst.X(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.0,   aFirst.Y(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  8.839, aLast.X(),  EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  4.0,   aLast.Y(),  EPS );
+
+  CPPUNIT_ASSERT_EQUAL( 1, (int)curves2.size() );
+  Handle(Geom2d_BSplineCurve) aBSpline = Handle(Geom2d_BSplineCurve)::DownCast( curves2[0] );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aBSpline.IsNull() );
+  const TColgp_Array1OfPnt2d& poles = aBSpline->Poles();
+  CPPUNIT_ASSERT_EQUAL( 1, (int)poles.Lower() );
+  CPPUNIT_ASSERT_EQUAL( 8, (int)poles.Upper() );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, poles.Value( 1 ).X(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  5.0,   poles.Value( 1 ).Y(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -4.125, poles.Value( 2 ).X(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  3.667, poles.Value( 2 ).Y(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -3.150, poles.Value( 3 ).X(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  2.120, poles.Value( 3 ).Y(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.242, poles.Value( 4 ).X(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(  0.574, poles.Value( 4 ).Y(), EPS );
+
+  aDoc->Close();
+}
diff --git a/src/HYDRO_tests/test_HYDROData_DTM.h b/src/HYDRO_tests/test_HYDROData_DTM.h
new file mode 100644 (file)
index 0000000..30eac98
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_DTM : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( test_HYDROData_DTM );
+  CPPUNIT_TEST( test_creation );
+  CPPUNIT_TEST( test_profile_conversion_to_2d );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp() {}
+  void tearDown() {}
+
+  void test_creation();
+  void test_profile_conversion_to_2d();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_DTM );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_DTM, "HYDROData_DTM" );
index c6a979d04c3fbbea15a6d0f058726d9e988316bb..d50bdcf7831fcec5954238c6a03c7a52385c759b 100644 (file)
@@ -68,8 +68,8 @@ int main( int argc, char* argv[] )
     CppUnit::TestFactoryRegistry::getRegistry();
   // Add the top suite to the test runner
   TestLib_Runner runner;
-  //QString aPath = qgetenv( "HYDRO_SRC_DIR" ) + "/src/tests.cfg";
-  //runner.Load( aPath.toStdString() );
+  QString aPath = qgetenv( "HYDRO_SRC_DIR" ) + "/src/tests.cfg";
+  runner.Load( aPath.toStdString() );
   runner.addTest( registry.makeTest() );   
   try
   {