]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
#668: split and simple automatic test
authorasl <asl@opencascade.com>
Wed, 14 Oct 2015 09:24:29 +0000 (12:24 +0300)
committerasl <asl@opencascade.com>
Wed, 14 Oct 2015 09:24:29 +0000 (12:24 +0300)
.gitignore
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDRO_tests/reference_data/LandCoverMap_Split_1.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h

index 88d6704ef8961c500a6c7968dd5bdfa492f4884b..12916051c48cbbcb0c5ba6930785f3e3ac094c22 100644 (file)
@@ -1,3 +1,4 @@
 html
 latex
 documentation.log
+tests.cfg
index 887fc9bd9ae15d830ca32c16e9bd5f71b4c79cc2..cc08ba781b7b9c8a6d85a6ab75cbde301abb5d61 100644 (file)
@@ -17,6 +17,7 @@
 //
 
 #include <HYDROData_LandCoverMap.h>
+#include <HYDROData_PolylineXY.h>
 #include <HYDROData_Tool.h>
 
 #include <BOPAlgo_Builder.hxx>
@@ -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, "" );
 }
 
 /**
index e09d5e8bfa743e4c9182fac676da35e5dc095124..c9c774d6e6007bada3ae4985f9aadb31fd6da913 100644 (file)
@@ -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 (file)
index 0000000..24d4ac8
Binary files /dev/null and b/src/HYDRO_tests/reference_data/LandCoverMap_Split_1.png differ
index aa9135f47f6073a29ae4445688e8c170dc80f201..e715c51d4d0409224677e93b282bf8e1fadd1a03 100644 (file)
@@ -19,6 +19,7 @@
 #include <test_HYDROData_LandCoverMap.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_LandCoverMap.h>
+#include <HYDROData_PolylineXY.h>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopoDS_Face.hxx>
@@ -30,6 +31,7 @@
 #include <TestViewer.h>
 #include <AIS_DisplayMode.hxx>
 #include <QString>
+#include <QColor>
 
 TopoDS_Edge Spline( const QList<double>& theXYList, bool isClosed = false )
 {
@@ -65,7 +67,7 @@ TopoDS_Face LandCover( const QList<double>& 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<double>() << 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<double>() << 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();
+}
index 15628e53501577982a6c3fca2ad2e19d3fe3c50f..95684210bedd4a17102bb765d6d80f0fedc1d120 100644 (file)
 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 );