X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_Stream.cxx;h=11e7ee1002d6647d5d3788afc0bff73b1789b788;hb=3bece499e83cc9ca95536228c7f6740030e9d5d8;hp=338eb7821d88ccf48e705da4275be7ac562827f1;hpb=96ec23982d2f1a1c3acff1ba9ff7c015927d9e0e;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_Stream.cxx b/src/HYDRO_tests/test_HYDROData_Stream.cxx index 338eb782..11e7ee10 100644 --- a/src/HYDRO_tests/test_HYDROData_Stream.cxx +++ b/src/HYDRO_tests/test_HYDROData_Stream.cxx @@ -26,10 +26,15 @@ #include #include #include +#include #include #include #include +#include +#include +#include + extern QString REF_DATA_PATH; NCollection_Sequence points2; const double EPS = 1E-3; @@ -49,8 +54,9 @@ void test_HYDROData_Stream::tearDown() void test_HYDROData_Stream::test_dialog() { + return; TestViewer::eraseAll( true, true ); - + HYDROGUI_StreamDlg* aDlg = new HYDROGUI_StreamDlg( 0, "stream" ); aDlg->show(); qApp->processEvents(); @@ -70,10 +76,10 @@ void test_HYDROData_Stream::test_dialog() void test_HYDROData_Stream::test_alt_object() { TestViewer::eraseAll( true, true ); - - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); - Handle(HYDROData_Stream) aStream = + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); + + Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) ); CPPUNIT_ASSERT_EQUAL( false, (bool)aStream.IsNull() ); @@ -82,7 +88,7 @@ void test_HYDROData_Stream::test_alt_object() CPPUNIT_ASSERT_EQUAL( false, (bool)aStream->GetAltitudeObject().IsNull() ); CPPUNIT_ASSERT_EQUAL( KIND_DTM, aStream->getAltitudeObjectType() ); - Handle(HYDROData_DTM) aDTM = + Handle(HYDROData_DTM) aDTM = Handle(HYDROData_DTM)::DownCast( aStream->GetAltitudeObject() ); CPPUNIT_ASSERT_EQUAL( false, (bool)aDTM.IsNull() ); @@ -92,18 +98,18 @@ void test_HYDROData_Stream::test_alt_object() void test_HYDROData_Stream::test_params_sync() { TestViewer::eraseAll( true, true ); - - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); - Handle(HYDROData_Stream) aStream = + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); + + Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) ); Handle(HYDROData_DTM) aDTM = aStream->DTM(); CPPUNIT_ASSERT_EQUAL( false, (bool)aDTM.IsNull() ); - Handle(HYDROData_Profile) aProfile1 = + Handle(HYDROData_Profile) aProfile1 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); - Handle(HYDROData_Profile) aProfile2 = + Handle(HYDROData_Profile) aProfile2 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); aProfile1->SetParametricPoints( points2 ); @@ -145,19 +151,19 @@ void test_HYDROData_Stream::test_params_sync() void test_HYDROData_Stream::test_dump() { TestViewer::eraseAll( true, true ); - + // Case 1. Without hydraulic axis - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); - Handle(HYDROData_Stream) aStream1 = + Handle(HYDROData_Stream) aStream1 = Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) ); aStream1->SetName( "stream_1" ); - Handle(HYDROData_Profile) aProfile1 = + Handle(HYDROData_Profile) aProfile1 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); aProfile1->SetName( "p1" ); - Handle(HYDROData_Profile) aProfile2 = + Handle(HYDROData_Profile) aProfile2 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); aProfile2->SetName( "p2" ); @@ -184,25 +190,27 @@ void test_HYDROData_Stream::test_dump() objs["p2"] = aProfile2; QStringList aScript1 = aStream1->DumpToPython( "", objs ); - CPPUNIT_ASSERT_EQUAL( 10, aScript1.size() ); + + CPPUNIT_ASSERT_EQUAL( 11, aScript1.size() ); CPPUNIT_ASSERT_EQUAL( std::string( "stream_1 = hydro_doc.CreateObject( KIND_STREAM )" ), aScript1[0].toStdString() ); CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetName( \"stream_1\" )" ), aScript1[1].toStdString() ); CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[2].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p1 )" ), aScript1[3].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p2 )" ), aScript1[4].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetDDZ( 0.200 )" ), aScript1[5].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetSpatialStep( 3.000 )" ), aScript1[6].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[7].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.Update()" ), aScript1[8].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[9].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetInterpolationMethod( 0 )" ), aScript1[3].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p1 )" ), aScript1[4].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p2 )" ), aScript1[5].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetDDZ( 0.200 )" ), aScript1[6].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetSpatialStep( 3.000 )" ), aScript1[7].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[8].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.Update()" ), aScript1[9].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[10].toStdString() ); // Case 2. With hydraulic axis - Handle(HYDROData_Stream) aStream2 = + Handle(HYDROData_Stream) aStream2 = Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) ); aStream2->SetName( "stream_2" ); - Handle(HYDROData_PolylineXY) anHAxis = + Handle(HYDROData_PolylineXY) anHAxis = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); anHAxis->SetName( "axis" ); @@ -217,18 +225,19 @@ void test_HYDROData_Stream::test_dump() objs["axis"] = anHAxis; QStringList aScript2 = aStream2->DumpToPython( "", objs ); - CPPUNIT_ASSERT_EQUAL( 11, aScript2.size() ); + CPPUNIT_ASSERT_EQUAL( 12, aScript2.size() ); CPPUNIT_ASSERT_EQUAL( std::string( "stream_2 = hydro_doc.CreateObject( KIND_STREAM )" ), aScript2[0].toStdString() ); CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetName( \"stream_2\" )" ), aScript2[1].toStdString() ); CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[2].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetHydraulicAxis( axis )" ), aScript2[3].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.AddProfile( p1 )" ), aScript2[4].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.AddProfile( p2 )" ), aScript2[5].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetDDZ( 0.200 )" ), aScript2[6].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetSpatialStep( 3.000 )" ), aScript2[7].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[8].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.Update()" ), aScript2[9].toStdString() ); - CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[10].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetInterpolationMethod( 0 )" ), aScript2[3].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetHydraulicAxis( axis )" ), aScript2[4].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.AddProfile( p1 )" ), aScript2[5].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.AddProfile( p2 )" ), aScript2[6].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetDDZ( 0.200 )" ), aScript2[7].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetSpatialStep( 3.000 )" ), aScript2[8].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[9].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.Update()" ), aScript2[10].toStdString() ); + CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[11].toStdString() ); aDoc->Close(); } @@ -236,15 +245,15 @@ void test_HYDROData_Stream::test_dump() void test_HYDROData_Stream::test_presentation() { TestViewer::eraseAll( true, true ); - - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); - + + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); + TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); fname += "/Profiles.xyz"; NCollection_Sequence bad_ids; int aSize = HYDROData_Profile::ImportFromFile( aDoc, fname, bad_ids, true ); - + CPPUNIT_ASSERT_EQUAL( 0, bad_ids.Size() ); CPPUNIT_ASSERT_EQUAL( 46, aSize ); @@ -259,7 +268,7 @@ void test_HYDROData_Stream::test_presentation() } } - Handle(HYDROData_Stream) aStream = + Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) ); aStream->SetProfiles( profiles, false ); @@ -280,3 +289,68 @@ void test_HYDROData_Stream::test_presentation() aDoc->Close(); } + +void test_HYDROData_Stream::test_lism_1() +{ + TCollection_AsciiString ref_path = REF_DATA_PATH.toLatin1().data(); + + TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data(); + fname += "/study_lism_1.cbf"; + CPPUNIT_ASSERT_EQUAL( (int)DocError_OK, (int)HYDROData_Document::Load( fname.ToCString() ) ); + + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); + + HYDROData_SequenceOfObjects profiles; + HYDROData_Iterator it( aDoc, KIND_PROFILE ); + for( int i=0; it.More(); it.Next(), i++ ) + { + if( i>=15 && i<=42 ) + profiles.Append( Handle(HYDROData_Profile)::DownCast( it.Current() ) ); + } + CPPUNIT_ASSERT_EQUAL( 28, (int)profiles.Size() ); + /// + + Handle(HYDROData_PolylineXY) aPolyXY_AX = Handle(HYDROData_PolylineXY)::DownCast(aDoc->FindObjectByName("AX")); + Handle(HYDROData_PolylineXY) aPolyXY_LB = Handle(HYDROData_PolylineXY)::DownCast(aDoc->FindObjectByName("LB")); + Handle(HYDROData_PolylineXY) aPolyXY_RB = Handle(HYDROData_PolylineXY)::DownCast(aDoc->FindObjectByName("RB")); + + aPolyXY_AX->Update(); + aPolyXY_LB->Update(); + aPolyXY_RB->Update(); + // + Handle(HYDROData_LISM) aLISM = Handle(HYDROData_LISM)::DownCast( aDoc->CreateObject( KIND_LISM ) ); + aLISM->SetProfiles( profiles ); + aLISM->SetHaxStep(2.0); + aLISM->SetNbProfilePoints( 200 ); + aLISM->SetHydraulicAxis(aPolyXY_AX); + aLISM->SetLeftBank(aPolyXY_LB); + aLISM->SetRightBank(aPolyXY_RB); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0, aLISM->GetHaxStep(), EPS ); + CPPUNIT_ASSERT_EQUAL( 200, aLISM->GetNbProfilePoints() ); + aLISM->Update(); + + CPPUNIT_ASSERT_EQUAL( 99000, (int)aLISM->GetAltitudePoints().size() ); + + Handle(AIS_InteractiveContext) aContext = TestViewer::context(); + HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, aLISM ); + //aBathPrs->Build(); + aBathPrs->update( true, false ); + aBathPrs->RescaleDefault(); + double min, max; + aBathPrs->GetRange( min, max ); + TestViewer::colorScale()->SetRange( min, max ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.98390276785714281, min, EPS ); + CPPUNIT_ASSERT_DOUBLES_EQUAL( 25.991840625000002, max, EPS ); + + aBathPrs->UpdateWithColorScale( TestViewer::colorScale() ); + + Handle(AIS_InteractiveObject) lism_prs = aBathPrs->getAISObjects()[0]; + CPPUNIT_ASSERT( !lism_prs.IsNull() ); + + TestViewer::show( lism_prs, 0, 0, true, "lism_prs" ); + CPPUNIT_ASSERT_IMAGES + + delete aBathPrs; + aDoc->Close(); +} +