Salome HOME
refs #613: duplicated names
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_LandCoverMap.cxx
index 1ae4bd40d0eb23d0ee5dcc620fec4370bbda463a..c8c12a84da8aca679faafa78bee81cc4dd016dd8 100644 (file)
@@ -412,7 +412,6 @@ void test_HYDROData_LandCoverMap::test_merge_faces_circles()
     CPPUNIT_ASSERT_IMAGES
     CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
   }
-
 }
 
 void test_HYDROData_LandCoverMap::test_import_dbf()
@@ -450,6 +449,8 @@ void test_HYDROData_LandCoverMap::test_import_dbf()
   CPPUNIT_ASSERT_EQUAL( QString( "forest" ), anIt.StricklerType() );
   anIt.Next();
   CPPUNIT_ASSERT_EQUAL( QString( "road" ), anIt.StricklerType() );
+
+  aDoc->Close();
 }
 
 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
@@ -550,6 +551,8 @@ void test_HYDROData_LandCoverMap::test_dump_python()
   CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
 
   //TODO: compare files
+
+  aDoc->Close();
 }
 
 void test_HYDROData_LandCoverMap::test_transparent_prs()
@@ -587,4 +590,75 @@ void test_HYDROData_LandCoverMap::test_transparent_prs()
   TestViewer::show( aPrs, AIS_Shaded, 0, true, "" );
 
   CPPUNIT_ASSERT_IMAGES
+  aDoc->Close();
+}
+
+void test_HYDROData_LandCoverMap::test_add_triangles()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_PolylineXY) Polyline_1 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+
+  Polyline_1->SetName( "Polyline_1" );
+  Polyline_1->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_1->AddPoint( 0, gp_XY( -264.84, 323.44 ) );
+  Polyline_1->AddPoint( 0, gp_XY( 254.45, 301.19 ) );
+  Polyline_1->AddPoint( 0, gp_XY( -291.54, -47.48 ) );
+  Polyline_1->Update();
+
+  Handle(HYDROData_PolylineXY) Polyline_2 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_2->SetName( "Polyline_2" );
+  Polyline_2->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, false );
+  Polyline_2->AddPoint( 0, gp_XY( -42.28, -351.63 ) );
+  Polyline_2->AddPoint( 0, gp_XY( 218.84, -146.88 ) );
+  Polyline_2->AddPoint( 0, gp_XY( 413.20, -235.91 ) );
+  Polyline_2->AddPoint( 0, gp_XY( 466.62, -388.72 ) );
+  Polyline_2->Update();
+
+  Handle(HYDROData_PolylineXY) Polyline_3 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_3->SetName( "Polyline_3" );
+  Polyline_3->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_3->AddPoint( 0, gp_XY( -108.31, 213.65 ) );
+  Polyline_3->AddPoint( 0, gp_XY( 127.60, 382.79 ) );
+  Polyline_3->AddPoint( 0, gp_XY( 192.88, -91.99 ) );
+  Polyline_3->Update();
+
+  Handle(HYDROData_PolylineXY) Polyline_4 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_4->SetName( "Polyline_4" );
+  Polyline_4->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_4->AddPoint( 0, gp_XY( 215.52, 344.61 ) );
+  Polyline_4->AddPoint( 0, gp_XY( 68.25, 258.52 ) );
+  Polyline_4->AddPoint( 0, gp_XY( 200.58, 154.65 ) );
+  Polyline_4->Update();
+
+  Handle(HYDROData_PolylineXY) Polyline_5 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_5->SetName( "Polyline_5" );
+  Polyline_5->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, false );
+  Polyline_5->AddPoint( 0, gp_XY( 16.15, -58.08 ) );
+  Polyline_5->AddPoint( 0, gp_XY( 116.47, 84.21 ) );
+  Polyline_5->AddPoint( 0, gp_XY( 266.59, 29.43 ) );
+  Polyline_5->Update();
+
+  Handle(HYDROData_LandCoverMap) aMap =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+
+  CPPUNIT_ASSERT_EQUAL( true, aMap->Add( Polyline_1, "" ) );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->Add( Polyline_3, "" ) );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->Add( Polyline_4, "" ) );
+
+  Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
+  TestViewer::show( aPrs, AIS_Shaded, 0, true, "LandCover_Triangles" );
+  CPPUNIT_ASSERT_IMAGES
+
+  CPPUNIT_ASSERT_EQUAL( true, aMap->Split( Polyline_5 ) );
+  Handle(HYDROGUI_LandCoverMapPrs) aPrs2 = new HYDROGUI_LandCoverMapPrs( aMap );
+  TestViewer::show( aPrs2, AIS_Shaded, 0, true, "LandCover_Triangles_Split" );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
 }