From: asl Date: Wed, 14 Oct 2015 09:24:29 +0000 (+0300) Subject: #668: split and simple automatic test X-Git-Tag: v1.5~126 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e2f98a615ba69e3b1b8a6e9bae61bd4746b1415e;p=modules%2Fhydro.git #668: split and simple automatic test --- 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 00000000..24d4ac8c Binary files /dev/null and b/src/HYDRO_tests/reference_data/LandCoverMap_Split_1.png differ 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 );