From: asl Date: Wed, 21 Oct 2015 13:25:31 +0000 (+0300) Subject: #refs 611: test on polylines extraction from the channel X-Git-Tag: v1.5~75^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6907327a9c59fb980a374ecaa1bbf28ffd583958;p=modules%2Fhydro.git #refs 611: test on polylines extraction from the channel --- diff --git a/src/HYDRO_tests/reference_data/Extraction_Channel.png b/src/HYDRO_tests/reference_data/Extraction_Channel.png new file mode 100644 index 00000000..f30b4949 Binary files /dev/null and b/src/HYDRO_tests/reference_data/Extraction_Channel.png differ diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index cb3a5592..a311e48d 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -18,13 +18,17 @@ #include +#include #include #include +#include #include +#include #include #include #include +#include #include #include #include @@ -150,3 +154,60 @@ void test_HYDROData_PolylineXY::test_extraction_immersible_zone() aDoc->Close(); } + +void test_HYDROData_PolylineXY::test_extraction_channel_refs_611() +{ +Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_PolylineXY) aPolyline2d = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + aPolyline2d->SetName( "polyline2d_1" ); + aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false ); + + Handle(HYDROData_Polyline3D) aPolyline3d = + Handle(HYDROData_Polyline3D)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) ); + aPolyline3d->SetName( "polyline3d_1" ); + aPolyline3d->SetPolylineXY( aPolyline2d ); + + QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; + TopoDS_Wire aWire = Wire( aCoords, false ); + aPolyline2d->SetShape( aWire ); + aPolyline3d->SetTopShape( aWire ); + aPolyline3d->SetShape3D( aWire ); + + Handle(HYDROData_Profile) aProfile = + Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); + aProfile->SetName( "profile_1" ); + + QList aCoordsPr = QList() << 0.0 << 0.1 << 0.5 << 0.0 << 1.0 << 0.1; + TopoDS_Wire aWirePr = Wire( aCoordsPr, false ); + aProfile->SetTopShape( aWirePr ); + aProfile->SetShape3D( aWirePr ); + + + Handle(HYDROData_Channel) aChannel = + Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) ); + aChannel->SetName( "channel_1" ); + + aChannel->SetGuideLine( aPolyline3d ); + aChannel->SetProfile( aProfile ); + aChannel->Update(); + CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetTopShape().IsNull() ); + CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetShape3D().IsNull() ); + + HYDROData_PolylineOperator anOp; + CPPUNIT_ASSERT_EQUAL( true, anOp.Extract( aDoc, aChannel ) ); + + Handle(HYDROData_PolylineXY) aLeft = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "channel_1_Left_Bank_1", KIND_POLYLINEXY ) ); + Handle(HYDROData_PolylineXY) aRight = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "channel_1_Right_Bank_1", KIND_POLYLINEXY ) ); + CPPUNIT_ASSERT_EQUAL( false, (bool)aRight.IsNull() ); + + TestViewer::show( aChannel->GetTopShape(), 1, true, "Extraction_Channel" ); + TestViewer::show( aLeft->GetShape(), 0, true, Qt::red ); + TestViewer::show( aRight->GetShape(), 0, true, Qt::red ); + CPPUNIT_ASSERT_IMAGES + + aDoc->Close(); +} diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.h b/src/HYDRO_tests/test_HYDROData_PolylineXY.h index 829d7f3b..cf58c980 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.h +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.h @@ -24,6 +24,7 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture { CPPUNIT_TEST( testCopy ); CPPUNIT_TEST( testSplit_refs_624 ); CPPUNIT_TEST( test_extraction_immersible_zone ); + CPPUNIT_TEST( test_extraction_channel_refs_611 ); CPPUNIT_TEST_SUITE_END(); private: @@ -43,6 +44,7 @@ public: void testSplit_refs_624(); void test_extraction_immersible_zone(); + void test_extraction_channel_refs_611(); }; CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);