From: asl Date: Mon, 26 Oct 2015 11:51:51 +0000 (+0300) Subject: refs #634: check type of split polyline X-Git-Tag: v1.5~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=092d22ec4f8551a5b59cbe054e0c402da2976bce;p=modules%2Fhydro.git refs #634: check type of split polyline --- diff --git a/src/HYDRO_tests/reference_data/Split_Straight.png b/src/HYDRO_tests/reference_data/Split_Straight.png new file mode 100644 index 00000000..c93ac469 Binary files /dev/null and b/src/HYDRO_tests/reference_data/Split_Straight.png differ diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index f89a11ae..9ec336c1 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -419,3 +419,74 @@ void test_HYDROData_PolylineXY::test_merge_refs_630() aDoc->Close(); } + +void test_HYDROData_PolylineXY::test_split_straight_refs_634() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); + + Handle(HYDROData_PolylineXY) aPolyline1 = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + Handle(HYDROData_PolylineXY) aPolyline2 = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + + aPolyline1->SetName( "test1" ); + aPolyline1->AddSection( "", HYDROData_PolylineXY::SECTION_POLYLINE, false ); + aPolyline1->AddPoint( 0, gp_XY( 0, 0 ) ); + aPolyline1->AddPoint( 0, gp_XY( 10, 20 ) ); + aPolyline1->AddPoint( 0, gp_XY( 30, 10 ) ); + aPolyline1->Update(); + + aPolyline2->SetName( "test2" ); + aPolyline2->AddSection( "", HYDROData_PolylineXY::SECTION_SPLINE, false ); + aPolyline2->AddPoint( 0, gp_XY( 0, 30 ) ); + aPolyline2->AddPoint( 0, gp_XY( 10, 10 ) ); + aPolyline2->AddPoint( 0, gp_XY( 30, 20 ) ); + aPolyline2->Update(); + + HYDROData_PolylineOperator anOp; + HYDROData_SequenceOfObjects aPolylines; + aPolylines.Append( aPolyline1 ); + aPolylines.Append( aPolyline2 ); + bool isIntersected; + CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline1, aPolyline2, 1E-3, isIntersected ) ); + CPPUNIT_ASSERT_EQUAL( true, isIntersected ); + + HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY ); + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.Current()->GetName() ); + anIt.Next(); + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test2" ), anIt.Current()->GetName() ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1_1" ), anIt.Current()->GetName() ); + Handle(HYDROData_PolylineXY) aPart1 = + Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); + CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_POLYLINE, aPart1->GetSectionType( 0 ) ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1_2" ), anIt.Current()->GetName() ); + Handle(HYDROData_PolylineXY) aPart2 = + Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); + CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_POLYLINE, aPart2->GetSectionType( 0 ) ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1_3" ), anIt.Current()->GetName() ); + Handle(HYDROData_PolylineXY) aPart3 = + Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); + CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_POLYLINE, aPart3->GetSectionType( 0 ) ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( false, anIt.More() ); + + TestViewer::show( aPart1->GetShape(), 0, true, "Split_Straight" ); + TestViewer::show( aPart2->GetShape(), 0, true, Qt::red ); + TestViewer::show( aPart3->GetShape(), 0, true, Qt::green ); + TestViewer::show( aPolyline2->GetShape(), 0, true, Qt::darkGreen ); + CPPUNIT_ASSERT_IMAGES + + aDoc->Close(); +} diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.h b/src/HYDRO_tests/test_HYDROData_PolylineXY.h index 588fd7dd..d51b20f5 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.h +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.h @@ -29,6 +29,7 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture { CPPUNIT_TEST( test_extraction_channel_refs_611 ); CPPUNIT_TEST( test_custom_polylines ); CPPUNIT_TEST( test_merge_refs_630 ); + CPPUNIT_TEST( test_split_straight_refs_634 ); CPPUNIT_TEST_SUITE_END(); private: @@ -53,6 +54,7 @@ public: void test_presentation(); void test_custom_polylines(); void test_merge_refs_630(); + void test_split_straight_refs_634(); }; CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);