Salome HOME
tests for DTM/warnings
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_DTM.cxx
index 48a470691ea6d6f25058ff9a37caab63f9454b58..be6e80ef6e485ebf53c828d42e48f774eadff15e 100644 (file)
@@ -670,3 +670,82 @@ void test_HYDROData_DTM::test_classifier_1()
   aDoc->Close();
 }
 
+void test_HYDROData_DTM::test_profile_discretization_warnings()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  {
+    Handle(HYDROData_Profile) aProfile = 
+      Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+    NCollection_Sequence<gp_XY> pnts;
+    pnts.Append( gp_XY( 0.0, 1.0 ) );
+    pnts.Append( gp_XY( 1.0, 0.0 ) );
+    pnts.Append( gp_XY( 2.0, 4.0 ) );
+    pnts.Append( gp_XY( 3.0, 5.0 ) );
+
+    aProfile->SetParametricPoints( pnts );
+    aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+    aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+    aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+    HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+    int dummy = 0;
+    QSet<QString> warnings;
+    HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+    //CPPUNIT_ASSERT_EQUAL(1, warnings.size());
+    CPPUNIT_ASSERT( warnings.contains("One of the extreme points is higher than another"));
+  }
+  {
+    Handle(HYDROData_Profile) aProfile = 
+      Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+    NCollection_Sequence<gp_XY> pnts;
+    pnts.Append( gp_XY( 0.0, 1.0 ) );
+    pnts.Append( gp_XY( 1.0, 0.0 ) );
+    pnts.Append( gp_XY( 2.0, 5.0 ) );
+    pnts.Append( gp_XY( 3.0, 0.0 ) );
+    pnts.Append( gp_XY( 4.0, 1.0 ) );
+
+    aProfile->SetParametricPoints( pnts );
+    aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+    aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+    aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+    HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+    int dummy = 0;
+    QSet<QString> warnings;
+    HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+    CPPUNIT_ASSERT_EQUAL(1, warnings.size());
+    CPPUNIT_ASSERT( warnings.contains("More than 2 intersections between profile & altitude Z-lines found"));
+  }
+  {
+    //plato case
+    Handle(HYDROData_Profile) aProfile = 
+      Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+    NCollection_Sequence<gp_XY> pnts;
+    pnts.Append( gp_XY( 0.0, 5.0 ) );
+    pnts.Append( gp_XY( 1.0, 5.0 ) );
+    pnts.Append( gp_XY( 2.0, 0.5 ) );
+    pnts.Append( gp_XY( 3.0, 5.0 ) );
+    pnts.Append( gp_XY( 4.0, 5.0 ) );
+
+    aProfile->SetParametricPoints( pnts );
+    aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+    aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+    aProfile->SetRightPoint( gp_XY( 10, 20 ) );
+
+    HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0, 0 ), aWid( 0.0, gp_Vec2d(), 0, 0 );
+    int dummy = 0;
+    QSet<QString> warnings;
+    HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 5.0, 0.5, aMid, aWid, dummy, 1E-6, warnings );
+
+    CPPUNIT_ASSERT_EQUAL(2, warnings.size());
+    CPPUNIT_ASSERT( warnings.contains("Plato case on extremes"));
+  }
+
+  aDoc->Close();
+}