From 092d22ec4f8551a5b59cbe054e0c402da2976bce Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 26 Oct 2015 14:51:51 +0300 Subject: [PATCH] refs #634: check type of split polyline --- .../reference_data/Split_Straight.png | Bin 0 -> 6470 bytes src/HYDRO_tests/test_HYDROData_PolylineXY.cxx | 71 ++++++++++++++++++ src/HYDRO_tests/test_HYDROData_PolylineXY.h | 2 + 3 files changed, 73 insertions(+) create mode 100644 src/HYDRO_tests/reference_data/Split_Straight.png 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 0000000000000000000000000000000000000000..c93ac4692de956e0ac5eabd0ffc8b05d0dfe049e GIT binary patch literal 6470 zcmZWt2{@G7|39-}Y#B=uVk}8aWvfv1j>b|~a#5F3k+pKOCcB|gQ`w8qrc!i^R8%5l zDZ1Q7h!$CsB5SsU|2gmUzj}Ump2y>R&iS0r`Fxl6yzeQ0HRwgm^J{A zXaErHDg3Y}BQV+r{v-RFY_X%jUl_%e1KWZ=77qRZEUH3(gcQw1asbHmZDBI(f-Zb* z+mqwg!VnlflBeAp&Dc!s+FWfHCU|3wO<0^BC77}$rz_EtbC)gRzE#O|m$s5%?XkWy zW>Rcdr_r@;G+kSga?iFJ0rH5ch)}Y1v~hq&@Lzg?55#mm2A^LD9sKZVV0?Clp>*bf zLH3i$+l6!eWv`8upd{W8J9bHI^Wa0+@PAu73q4>(P-w8_*exRs{cB)BJ3m313|MBK z7#wvaQ(?~{UlC!z;{T;*rw{6RaR6d~el)_LLiSJmYkYJoZ}d1C75Zh=j5qfeHZwoO zb_(@?G)$NXu;qF*05BaQ1@=f99OnZV-!DCKI70=_-;aHsl86A5#}?3_ZGvo76&4)T(tVx}fI5qx z41k3hfU{^s)Kg=LFqrBt7$BWr_?bOu^>o}9jwSMiUlu}WO9_yGMV7B50-Clc6qOhY z5P@>MGXW$fB6=1ZEv|ZXL7GJ!5-Y()LU{6Bap#h7*K3%Fp7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zE*`yfdc^Rf&m;+eyx_x>&Z5q)>d2XnFZ+gqVc1Fy#xGAKY}imaDSf)Ic=prF%kvYR zWk-AK(!DLib3;&W)NNCT2-DwNhQ4>iZ-|(C?f)raa`r?-@A?nLbMB?zo7c?#GdQ?! z+qB23yxhV_sfyvsHKmk!U6Ia*d5%S;GxH_A3qEBLbBWK6YZ@;v0`l0UZOAR)v6+buo90f0<)kAaBJLd~D|Hxxs7TG-2^&(|> z&8FD{Q%|+n-tN=wJA~kK0I@S_->$!l{L!5&{dZ)Uy~rk+zPN3U9+h(R9s^(So6!z+ z+{Skar^TqKj^Mk5Pa2Z_9pCU;(F+Tc!#6oPqW9#{QxRnWzJWmzyq|UHyg=Y)0q30^ RfzzmGi>Vbe&%`PE{{WTyB@+Mu literal 0 HcmV?d00001 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); -- 2.39.2