From: asl Date: Mon, 7 Dec 2015 05:57:21 +0000 (+0300) Subject: refs #751: automatic test for bug X-Git-Tag: SALOME_HYDRO_V1.0~57^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6bf853653225dfdfb49486e91fe5e79ad1c82440;p=modules%2Fhydro.git refs #751: automatic test for bug --- diff --git a/src/HYDRO_tests/reference_data/Channel.png b/src/HYDRO_tests/reference_data/Channel.png deleted file mode 100644 index f30b4949..00000000 Binary files a/src/HYDRO_tests/reference_data/Channel.png and /dev/null differ diff --git a/src/HYDRO_tests/test_HYDROData_Channel.cxx b/src/HYDRO_tests/test_HYDROData_Channel.cxx index 82ca4336..c80b0da3 100644 --- a/src/HYDRO_tests/test_HYDROData_Channel.cxx +++ b/src/HYDRO_tests/test_HYDROData_Channel.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -34,35 +35,55 @@ TopoDS_Edge Spline( const QList& theXYList, bool isClosed = false ); -void test_HYDROData_Channel::test_2d_prs() +void test_HYDROData_Channel::test_channel_prs_refs_751() { Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); - Handle(HYDROData_PolylineXY) aPolyline2d = + Handle(HYDROData_PolylineXY) Polyline_2 = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); - aPolyline2d->SetName( "polyline2d_1" ); - aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false ); + Polyline_2->SetName( "polyline2d_1" ); + Polyline_2->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false ); + Polyline_2->AddPoint( 0, gp_XY( -192.40, 397.86 ) ); + Polyline_2->AddPoint( 0, gp_XY( -53.44, 293.35 ) ); + Polyline_2->AddPoint( 0, gp_XY( 102.14, 225.65 ) ); + Polyline_2->AddPoint( 0, gp_XY( 251.78, 108.08 ) ); + Polyline_2->Update(); + + CPPUNIT_ASSERT_EQUAL( false, (bool)Polyline_2->GetShape().IsNull() ); + + Handle(HYDROData_Profile) aProfile0 = + Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); + aProfile0->SetName( "profile_0" ); + + HYDROData_IPolyline::PointsList aPoints; + aPoints.Append( gp_XY( 0.0, 0.0 ) ); + aPoints.Append( gp_XY( 1.0, 0.0 ) ); + aProfile0->GetProfileUZ( true ); + aProfile0->SetParametricPoints( aPoints ); + aProfile0->Update(); 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 ); + aPolyline3d->SetPolylineXY( Polyline_2 ); + aPolyline3d->SetProfileUZ( aProfile0->GetProfileUZ() ); + aPolyline3d->Update(); 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 ); + aPoints.Clear(); + aPoints.Append( gp_XY( 0.0, 0.1 ) ); + aPoints.Append( gp_XY( 12.5, 0.0 ) ); + aPoints.Append( gp_XY( 25.0, 0.1 ) ); + aProfile->GetProfileUZ( true ); + aProfile->SetParametricPoints( aPoints ); + aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE ); + aProfile->Update(); + CPPUNIT_ASSERT_EQUAL( false, (bool)aProfile->GetShape3D().IsNull() ); + CPPUNIT_ASSERT_EQUAL( false, (bool)aPolyline3d->GetShape3D().IsNull() ); Handle(HYDROData_Channel) aChannel = Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) ); @@ -77,8 +98,10 @@ void test_HYDROData_Channel::test_2d_prs() TestViewer::show( aChannel->GetTopShape(), AIS_Shaded, true, "Channel" ); TestViewer::show( aChannel->GetLeftShape(), AIS_WireFrame, true, Qt::red ); TestViewer::show( aChannel->GetRightShape(), AIS_WireFrame, true, Qt::red ); - //TestViewer::show( aWire, AIS_Shaded, true, "Channel" ); + Handle(HYDROGUI_Polyline) Polyline_Prs = new HYDROGUI_Polyline( aPolyline3d->GetShape3D() ); + Polyline_Prs->SetColor( Quantity_NOC_WHITE ); + TestViewer::show( Polyline_Prs, AIS_WireFrame, 0, true, "" ); CPPUNIT_ASSERT_IMAGES - + aDoc->Close(); } diff --git a/src/HYDRO_tests/test_HYDROData_Channel.h b/src/HYDRO_tests/test_HYDROData_Channel.h index c4e22a89..0d66258f 100644 --- a/src/HYDRO_tests/test_HYDROData_Channel.h +++ b/src/HYDRO_tests/test_HYDROData_Channel.h @@ -20,13 +20,13 @@ class test_HYDROData_Channel : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( test_HYDROData_Channel ); - CPPUNIT_TEST( test_2d_prs ); + CPPUNIT_TEST( test_channel_prs_refs_751 ); CPPUNIT_TEST_SUITE_END(); private: public: - void test_2d_prs(); + void test_channel_prs_refs_751(); }; CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_Channel );