]> SALOME platform Git repositories - modules/hydro.git/blobdiff - src/HYDRO_tests/test_HYDROData_DTM.cxx
Salome HOME
using DTM object in stream
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_DTM.cxx
index 97d122abf52250be0405377abbb079be7d87ce98..6659e93013f59edfb658ac6bff5ce3beb9dc30b7 100644 (file)
@@ -20,6 +20,7 @@
 #include <HYDROData_Document.h>
 #include <HYDROData_Profile.h>
 #include <HYDROData_DTM.h>
+#include <HYDROData_Iterator.h>
 #include <Geom2d_Curve.hxx>
 #include <Geom2d_BSplineCurve.hxx>
 #include <gp_XY.hxx>
@@ -38,6 +39,7 @@
 
 const double EPS = 1E-3;
 
+extern QString REF_DATA_PATH;
 NCollection_Sequence<HYDROData_IPolyline::Point> points;
 
 class DTM_item : public QGraphicsItem
@@ -564,5 +566,53 @@ void test_HYDROData_DTM::test_presentation()
 
 void test_HYDROData_DTM::test_garonne()
 {
-  //TODO
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+  
+  TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
+  fname += "/Profiles.xyz";
+  NCollection_Sequence<int> bad_ids;
+
+  int aSize = HYDROData_Profile::ImportFromFile( aDoc, fname, bad_ids, true );
+  
+  CPPUNIT_ASSERT_EQUAL( 0, bad_ids.Size() );
+  CPPUNIT_ASSERT_EQUAL( 46, aSize );
+
+  HYDROData_SequenceOfObjects profiles;
+  HYDROData_Iterator it( aDoc, KIND_PROFILE );
+  for( int i=0; it.More(); it.Next(), i++ )
+  {
+    if( i>=25 && i<=35 )
+      profiles.Append( Handle(HYDROData_Profile)::DownCast( it.Current() ) );
+  }
+
+  //CPPUNIT_ASSERT_EQUAL( 46, (int)profiles.Size() );
+
+
+
+  Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+  DTM->SetProfiles( profiles );
+  DTM->SetDDZ( 0.1 );
+  DTM->SetSpatialStep( 1.0 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
+  DTM->Update();
+  
+  CPPUNIT_ASSERT_EQUAL( 282336, (int)DTM->GetAltitudePoints().size() ); 
+
+  Handle_AIS_InteractiveContext aContext = TestViewer::context();
+  HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
+  aBathPrs->update( true, false );
+
+  TestViewer::showColorScale( true );
+  Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
+  aCS->SetMin( 0.0 );
+  aCS->SetMax( 25.0 );
+  aCS->SetNumberOfIntervals( 30 );
+  aBathPrs->UpdateWithColorScale( aCS );
+  
+  QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
+  CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_2" );
+  delete aBathPrs;
+
+  aDoc->Close();
 }