]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
debug of the land cover maps
authorasl <asl@opencascade.com>
Tue, 10 Nov 2015 09:28:25 +0000 (12:28 +0300)
committerasl <asl@opencascade.com>
Tue, 10 Nov 2015 09:28:25 +0000 (12:28 +0300)
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDRO_tests/reference_data/LCM_split_2a.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/LCM_split_2b.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/lcm_poly_2_sections.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h

index 5487b6ad255d8e0c459d667e235f5415a53f6e25..d56db3d23a7bafe65cb87881b0d1a4413b1b36f5 100644 (file)
@@ -437,6 +437,15 @@ bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_Object )& theObject, c
   return LocalPartition( aFace, theType );
 }
 
+bool HYDROData_LandCoverMap::Add( const TopoDS_Wire& theWire, const QString& theType )
+{
+  if( !theWire.Closed() )
+    return false;
+
+  TopoDS_Face aFace = BRepBuilderAPI_MakeFace( theWire, Standard_True ).Face();
+  return LocalPartition( aFace, theType );
+}
+
 /**
   Add a new polyline as land cover
   @param thePolyline the polyline to add as land cover
@@ -449,15 +458,22 @@ bool HYDROData_LandCoverMap::Add( const Handle( HYDROData_PolylineXY )& thePolyl
     return false;
 
   TopoDS_Shape aShape = thePolyline->GetShape();
-  if( aShape.ShapeType()!=TopAbs_WIRE )
-    return false;
+  if( aShape.ShapeType()==TopAbs_WIRE )
+    return Add( TopoDS::Wire( aShape ), theType );
 
-  TopoDS_Wire aWire = TopoDS::Wire( aShape );
-  if( !aWire.Closed() )
-    return false;
+  if( aShape.ShapeType()==TopAbs_COMPOUND )
+  {
+    TopExp_Explorer anExp( aShape, TopAbs_WIRE );
+    for( ; anExp.More(); anExp.Next() )
+    {
+      TopoDS_Wire aPart = TopoDS::Wire( anExp.Current() );
+      if( !Add( aPart, theType ) )
+        return false;
+    }
+    return true;
+  }
 
-  TopoDS_Face aFace = BRepBuilderAPI_MakeFace( aWire, Standard_True ).Face();
-  return LocalPartition( aFace, theType );
+  return false;
 }
 
 /**
index f3492f17da8de64034bea85198b03f15afbdcf02..96acd1fc18fa74d72ffac539ae88a4a6164a9c57 100644 (file)
@@ -30,6 +30,7 @@ typedef NCollection_IndexedDataMap<TopoDS_Face, QString> HYDROData_MapOfFaceToSt
 DEFINE_STANDARD_HANDLE( HYDROData_LandCoverMap, HYDROData_Entity )
 
 class TopoDS_Shape;
+class TopoDS_Wire;
 class TopoDS_Iterator;
 class TopTools_ListOfShape;
 class Handle( HYDROData_PolylineXY );
@@ -121,6 +122,7 @@ public:
 protected:
   void SetShape( const TopoDS_Shape& );
 
+  bool Add( const TopoDS_Wire&, const QString& );
   bool LocalPartition( const TopoDS_Shape&, const QString& theNewType );
   static TopoDS_Shape MergeFaces(const TopTools_ListOfShape& theFaces,
                       bool IsToUnify, double theTolerance = 1E-5 );
diff --git a/src/HYDRO_tests/reference_data/LCM_split_2a.png b/src/HYDRO_tests/reference_data/LCM_split_2a.png
new file mode 100644 (file)
index 0000000..51cf6e0
Binary files /dev/null and b/src/HYDRO_tests/reference_data/LCM_split_2a.png differ
diff --git a/src/HYDRO_tests/reference_data/LCM_split_2b.png b/src/HYDRO_tests/reference_data/LCM_split_2b.png
new file mode 100644 (file)
index 0000000..2f054f8
Binary files /dev/null and b/src/HYDRO_tests/reference_data/LCM_split_2b.png differ
diff --git a/src/HYDRO_tests/reference_data/lcm_poly_2_sections.png b/src/HYDRO_tests/reference_data/lcm_poly_2_sections.png
new file mode 100644 (file)
index 0000000..7b7d7fc
Binary files /dev/null and b/src/HYDRO_tests/reference_data/lcm_poly_2_sections.png differ
index a64ed48016064057184f6a3e132cee902b065586..7e47eaf4007e682387c1d336f2b2de6e2afa4fac 100644 (file)
@@ -841,3 +841,98 @@ void test_HYDROData_LandCoverMap::test_shp_loop_back()
   CPPUNIT_ASSERT_EQUAL(0, remove(aSFileName.toStdString().c_str()));
 }
 
+void test_HYDROData_LandCoverMap::test_add_2_section_poly()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+  Handle(HYDROData_PolylineXY) Polyline_12 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_12->SetName( "Polyline_12" );
+
+  Polyline_12->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_12->AddPoint( 0, gp_XY( -148.70, 145.68 ) );
+  Polyline_12->AddPoint( 0, gp_XY( -81.71, 210.97 ) );
+  Polyline_12->AddPoint( 0, gp_XY( -21.09, 122.79 ) );
+  Polyline_12->AddPoint( 0, gp_XY( -106.30, 102.44 ) );
+  Polyline_12->AddSection( "Section_2", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_12->AddPoint( 1, gp_XY( -7.09, 227.08 ) );
+  Polyline_12->AddPoint( 1, gp_XY( 46.32, 228.78 ) );
+  Polyline_12->AddPoint( 1, gp_XY( 69.64, 165.61 ) );
+  Polyline_12->AddPoint( 1, gp_XY( 13.68, 156.28 ) );
+
+  Polyline_12->Update();
+
+  Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  CPPUNIT_ASSERT_EQUAL( true, LCM->Add( Polyline_12, "" ) );
+
+  TestViewer::show( LCM->GetShape(), AIS_Shaded, true, "lcm_poly_2_sections" );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
+
+void test_HYDROData_LandCoverMap::test_split_2()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+  Handle(HYDROData_PolylineXY) Polyline_1 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  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_6 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_6->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_6->AddPoint( 0, gp_XY( -155.15, 199.47 ) );
+  Polyline_6->AddPoint( 0, gp_XY( -71.19, 289.12 ) );
+  Polyline_6->AddPoint( 0, gp_XY( 22.01, 211.57 ) );
+  Polyline_6->AddPoint( 0, gp_XY( -84.00, 134.73 ) );
+  Polyline_6->Update();
+
+  Handle(HYDROData_PolylineXY) Polyline_7 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_7->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_7->AddPoint( 0, gp_XY( -50.56, 232.20 ) );
+  Polyline_7->AddPoint( 0, gp_XY( 40.51, 286.98 ) );
+  Polyline_7->AddPoint( 0, gp_XY( 118.77, 256.39 ) );
+  Polyline_7->AddPoint( 0, gp_XY( 72.52, 114.10 ) );
+  Polyline_7->Update();
+
+  Handle(HYDROData_PolylineXY) Polyline_8 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_8->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, true );
+  Polyline_8->AddPoint( 0, gp_XY( -44.16, 190.93 ) );
+  Polyline_8->AddPoint( 0, gp_XY( 9.91, 226.51 ) );
+  Polyline_8->AddPoint( 0, gp_XY( 35.53, 175.99 ) );
+  Polyline_8->AddPoint( 0, gp_XY( -9.30, 157.50 ) );
+  Polyline_8->Update();
+
+  Handle(HYDROData_PolylineXY) Polyline_9 =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Polyline_9->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, false );
+  Polyline_9->AddPoint( 0, gp_XY( -103.92, 288.40 ) );
+  Polyline_9->AddPoint( 0, gp_XY( -53.41, 246.43 ) );
+  Polyline_9->AddPoint( 0, gp_XY( 10.62, 245.01 ) );
+  Polyline_9->Update();
+
+
+  Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  CPPUNIT_ASSERT_EQUAL( true, LCM->Add( Polyline_1, "" ) );
+  CPPUNIT_ASSERT_EQUAL( true, LCM->Add( Polyline_6, "" ) );
+  CPPUNIT_ASSERT_EQUAL( true, LCM->Add( Polyline_7, "" ) );
+
+  CPPUNIT_ASSERT_EQUAL( true, LCM->Split( Polyline_9 ) );
+
+  TestViewer::show( LCM->GetShape(), AIS_Shaded, true, "LCM_split_2a" );
+  CPPUNIT_ASSERT_IMAGES
+
+  CPPUNIT_ASSERT_EQUAL( true, LCM->Split( Polyline_8 ) );
+
+  TestViewer::show( LCM->GetShape(), AIS_Shaded, true, "LCM_split_2b" );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
index f8f2a40a7d1cf7f2cd4eb85a89418113085f1c0d..8772f9dbf6ad8de54a919a4ff9ac18c54355bf92 100644 (file)
@@ -27,8 +27,10 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture
 {
   CPPUNIT_TEST_SUITE( test_HYDROData_LandCoverMap );
   CPPUNIT_TEST( test_add_2_objects );
+  CPPUNIT_TEST( test_add_2_section_poly );
   CPPUNIT_TEST( test_add_triangles );
   CPPUNIT_TEST( test_split );
+  CPPUNIT_TEST( test_split_2 );
   CPPUNIT_TEST( test_incomplete_split );
   CPPUNIT_TEST( test_merge );
   CPPUNIT_TEST( test_remove );
@@ -50,8 +52,10 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture
 
 public:
   void test_add_2_objects();
+  void test_add_2_section_poly();
   void test_add_triangles();
   void test_split();
+  void test_split_2();
   void test_incomplete_split();
   void test_merge();
   void test_remove();