From e2f98a615ba69e3b1b8a6e9bae61bd4746b1415e Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 14 Oct 2015 12:24:29 +0300 Subject: [PATCH] #668: split and simple automatic test --- .gitignore | 1 + src/HYDROData/HYDROData_LandCoverMap.cxx | 12 ++++--- src/HYDROData/HYDROData_LandCoverMap.h | 6 ++-- .../reference_data/LandCoverMap_Split_1.png | Bin 0 -> 7434 bytes .../test_HYDROData_LandCoverMap.cxx | 33 +++++++++++++++++- src/HYDRO_tests/test_HYDROData_LandCoverMap.h | 6 ++-- 6 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 src/HYDRO_tests/reference_data/LandCoverMap_Split_1.png diff --git a/.gitignore b/.gitignore index 88d6704e..12916051 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ html latex documentation.log +tests.cfg diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 887fc9bd..cc08ba78 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -17,6 +17,7 @@ // #include +#include #include #include @@ -190,7 +191,7 @@ bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_Object )& theObject, c @param theType the Strickler type for the new land cover @return if the addition is successful */ -bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_Polyline )& thePolyline, const QString& theType ) +bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_PolylineXY )& thePolyline, const QString& theType ) { //TODO return false; @@ -212,10 +213,13 @@ bool HYDROData_LandCoverMap::Remove( const TopoDS_Face& theFace ) @param thePolyline the tool polyline to split the land cover map @return if the removing is successful */ -bool HYDROData_LandCoverMap::Split( const Handle( HYDROData_Polyline )& thePolyline ) +bool HYDROData_LandCoverMap::Split( const Handle( HYDROData_PolylineXY )& thePolyline ) { - //TODO - return false; + if( thePolyline.IsNull() ) + return false; + + TopoDS_Shape aShape = thePolyline->GetShape(); + return LocalPartition( aShape, "" ); } /** diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index e09d5e8b..c9c774d6 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -28,7 +28,7 @@ class TopoDS_Face; class TopoDS_Shape; class TopoDS_Iterator; class TopTools_ListOfShape; -class Handle( HYDROData_Polyline ); +class Handle( HYDROData_PolylineXY ); class Handle( HYDROData_Object ); class HYDROData_MapOfFaceToStricklerType; @@ -74,11 +74,11 @@ public: bool ExportTelemac( const QString& theFileName ) const; bool Add( const Handle( HYDROData_Object )&, const QString& theType ); - bool Add( const Handle( HYDROData_Polyline )&, const QString& theType ); + bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType ); bool Remove( const TopoDS_Face& ); - bool Split( const Handle( HYDROData_Polyline )& ); + bool Split( const Handle( HYDROData_PolylineXY )& ); bool Merge( const TopTools_ListOfShape&, const QString& theType ); protected: diff --git a/src/HYDRO_tests/reference_data/LandCoverMap_Split_1.png b/src/HYDRO_tests/reference_data/LandCoverMap_Split_1.png new file mode 100644 index 0000000000000000000000000000000000000000..24d4ac8c15446e59a2ea2bb8e73d1482d6b80846 GIT binary patch literal 7434 zcmXw730zF;`+v`wQ*&D9OeI5U&P1Q5?Fxms$*CqyDn+4g z(%8ET1|j>DR-%z8t{++uvW&V~EdAee@BPo`)2Dad=Xsyy`z-JCPEJtZJR|*y`Tzi< z`Tmmc0br2;pi*2H?x4=KU*SJ2Nj(1t9DY*qSOxs9x7I%_2>|0d<`3C3)z|_6%RlE! zynjg9|Mq{8l`EEPRcpVSQS=+fC}N%2U*c6$vV@&xbAl2k66M)PBt^l;pH#-%o0LbB zGQHC>Rn+9p9h^)j+uB%>-E5*Mk4)Cj9M~sIw>z^-ty6S*H%l`SOls-oz0Vq~oy5?RwG?l|$#Nzi9S%4qkID4Kq5mG zD2G5#5G$ZwLw6tVPX@g5;mR@`S^v=x2g!jX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?YBL|1 zJKjX4S3XI5(NdcIzPe}Uh3C-x7}Y|9l6?a@-`%t#ug}!RZ|QpB zweZxXkstqhLPUS<+ltRpPPDb z;i?#y`Ch+D+m;nIAK12U<$=vFS_2Pwj66JXeG}6@DrRqZ{TSVb(7!)CrnA*_lBDqK zgu+eNKj(KW9~+Il_PjQ0DAoGt&=Ie+`xhd=jZaJ)ICXtw!>O`2t-pThweJ`kS$Rt8 zb8VnI_tk~SEw6$C9JUUWJ^k|eWyQ8{k?*b!J&C*sLox>2$xF|ni$#fB-z**L{q6XH z*&ow6sn6bTA6bgD*SK11rfa>;eC^1k%OYl-{ZR4g^3C$qQ066WMMciEC3>Fs$@7UJYMM0kWBgG9S!RBfR}& z`iLH9OBcl^4T90jImTOhm24&MEpC;w=O%q%1sMg4Z%No!S}YKHwVp{h=^>kwhyyX# zRwD3_B|hN+xt)JyP9L4Qxd>=1gT-rVS#d9KqtpPV7eh=^@e(b;C7Xbfeb4Bq6l;Vs zu}QFZmw7yi04h#!8>a>tNjZzC^RW4IFm`dzZ8l(WCvPyZ2pXU04<<`gc|L2Y|6TD$ zNO1a0nT9U8vJO!?2S@u-RK*o7qKvuKutNc#PXB$HUW_4`e~dpFxAJZvvo+s0P;yc% G%lJR8BNT`L literal 0 HcmV?d00001 diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index aa9135f4..e715c51d 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include TopoDS_Edge Spline( const QList& theXYList, bool isClosed = false ) { @@ -65,7 +67,7 @@ TopoDS_Face LandCover( const QList& theXYList ) return aFace; } -void test_HYDROData_LandCoverMap::test_local_partition() +void test_HYDROData_LandCoverMap::test_add_2_objects() { Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); @@ -83,6 +85,35 @@ void test_HYDROData_LandCoverMap::test_local_partition() TestViewer::show( aMap->GetShape(), AIS_Shaded, true ); TestViewer::AssertEqual( "LandCoverMap_Add_2_Objects" ); + //TODO: check the types + aDoc->Close(); } +void test_HYDROData_LandCoverMap::test_split_by_polyline() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_LandCoverMap) aMap = + Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) ); + + CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() ); + + TopoDS_Face aLC = LandCover( QList() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 ); + CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) ); + + Handle(HYDROData_PolylineXY) aPolyline = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire(); + aPolyline->SetShape( aWire ); + + CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) ); + + TestViewer::show( aMap->GetShape(), AIS_Shaded, true ); + //TestViewer::show( aWire, QColor(), 0 ); + TestViewer::AssertEqual( "LandCoverMap_Split_1" ); + + //TODO: check the types + + aDoc->Close(); +} diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.h b/src/HYDRO_tests/test_HYDROData_LandCoverMap.h index 15628e53..95684210 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.h +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.h @@ -25,11 +25,13 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( test_HYDROData_LandCoverMap ); - CPPUNIT_TEST( test_local_partition ); + CPPUNIT_TEST( test_add_2_objects ); + CPPUNIT_TEST( test_split_by_polyline ); CPPUNIT_TEST_SUITE_END(); public: - void test_local_partition(); + void test_add_2_objects(); + void test_split_by_polyline(); }; CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap ); -- 2.39.2