]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
loopback test. BR_SHP_FORMAT2
authorisn <isn@opencascade.com>
Mon, 9 Nov 2015 16:58:36 +0000 (19:58 +0300)
committerisn <isn@opencascade.com>
Mon, 9 Nov 2015 17:00:00 +0000 (20:00 +0300)
src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h

index bebfe82eec5f2ec43b9530df8f48d3273be759a8..9cf8259fd27839c2040c0bfa73879988fe82d0c2 100644 (file)
@@ -95,7 +95,7 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
   aPolygonsGroup->setLayout( aPolygonsLayout );
 
   QVBoxLayout* aPageLayout = new QVBoxLayout;
-  myAttrCheckBox = new QCheckBox( tr("USE_DBF_AS_ST") ); //TODO replace with tr()
+  myAttrCheckBox = new QCheckBox( tr("USE_DBF_AS_ST") );
   myAttrCheckBox->setChecked(true);
 
   // Layout
@@ -292,7 +292,6 @@ void HYDROGUI_ImportLandCoverMapDlg::FillCorrespondenceTable(const QStringList&
   for (int i = 0; i < aFCSize; i++)
   {
     myCorrTableWidget->setItem(i, 2, new QTableWidgetItem);
-    //take the first color from array; this color corresponds to the first item in the combo box
     myCorrTableWidget->item(i, 2)->setBackground(myStrColors[theDefCBIndices[i]]);
   }
 
index 993ac81d86098dd6038357f4e73385747936e727..9708f6563ee4437f6e19aac542ffec6a09aded9d 100644 (file)
@@ -272,9 +272,9 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
   QSet<QString> aNameList;
   if (aDoc)
   {
-    HYDROData_Iterator It( aDoc, KIND_LAND_COVER_MAP );
-    for( ; It.More(); It.Next() )
-      aNameList << It.Current()->GetName();
+    HYDROData_Iterator anIt( aDoc, KIND_LAND_COVER_MAP );
+    for( ; anIt.More(); anIt.Next() )
+      aNameList << anIt.Current()->GetName();
   }
 
   QString aNewName = anObjName;
index fb7e80535a2dc07a0abcef6e004055e826da2336..a64ed48016064057184f6a3e132cee902b065586 100644 (file)
@@ -41,6 +41,7 @@
 #include <QDir>
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
+#include <BRepCheck_Analyzer.hxx>
 
 const QString REF_DATA_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
 const QString DEF_STR_PATH = qgetenv( "HYDRO_SRC_DIR" ) + "/src/HYDROGUI/resources/def_strickler_table.txt";
@@ -684,12 +685,12 @@ void test_HYDROData_LandCoverMap::test_assign_to_calc_case()
 void test_HYDROData_LandCoverMap::test_shp_import_cyp()
 {
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-  QString myFileName = REF_DATA_PATH + "/cyprus_natural.shp";
+  QString aFileName = REF_DATA_PATH + "/cyprus_natural.shp";
   HYDROData_ShapeFile anImporter;
   QStringList PolygonList;
   TopTools_SequenceOfShape PolygonFaces;
   int Type = -1;
-  int aStat = anImporter.ImportPolygons(myFileName, PolygonList, PolygonFaces, Type);
+  int aStat = anImporter.ImportPolygons(aFileName, PolygonList, PolygonFaces, Type);
   CPPUNIT_ASSERT(aStat == 1);
   CPPUNIT_ASSERT_EQUAL(5, Type);
   CPPUNIT_ASSERT_EQUAL(268, PolygonFaces.Length());
@@ -714,12 +715,12 @@ void test_HYDROData_LandCoverMap::test_shp_import_cyp()
 void test_HYDROData_LandCoverMap::test_shp_import_clc_dec()
 {
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-  QString myFileName = REF_DATA_PATH + "/CLC_decoupe.shp";
+  QString aFileName = REF_DATA_PATH + "/CLC_decoupe.shp";
   HYDROData_ShapeFile anImporter;
   QStringList PolygonList;
   TopTools_SequenceOfShape PolygonFaces;
   int Type = -1;
-  int aStat = anImporter.ImportPolygons(myFileName, PolygonList, PolygonFaces, Type);
+  int aStat = anImporter.ImportPolygons(aFileName, PolygonList, PolygonFaces, Type);
   CPPUNIT_ASSERT(aStat == 1);
   CPPUNIT_ASSERT_EQUAL(5, Type);
   CPPUNIT_ASSERT_EQUAL(625, PolygonFaces.Length());
@@ -744,12 +745,12 @@ void test_HYDROData_LandCoverMap::test_shp_import_clc_dec()
 void test_HYDROData_LandCoverMap::test_shp_import_nld_areas()
 {
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
-  QString myFileName = REF_DATA_PATH + "/NLD_water_areas_dcw.shp";
+  QString aFileName = REF_DATA_PATH + "/NLD_water_areas_dcw.shp";
   HYDROData_ShapeFile anImporter;
   QStringList PolygonList;
   TopTools_SequenceOfShape PolygonFaces;
   int Type = -1;
-  int aStat = anImporter.ImportPolygons(myFileName, PolygonList, PolygonFaces, Type);
+  int aStat = anImporter.ImportPolygons(aFileName, PolygonList, PolygonFaces, Type);
   CPPUNIT_ASSERT(aStat == 1);
   CPPUNIT_ASSERT_EQUAL(5, Type);
   CPPUNIT_ASSERT_EQUAL(127, PolygonFaces.Length());
@@ -771,3 +772,72 @@ void test_HYDROData_LandCoverMap::test_shp_import_nld_areas()
   aDoc->Close();
 }
 
+void test_HYDROData_LandCoverMap::test_shp_loop_back()
+{
+  QString aFFileName = REF_DATA_PATH + "/CLC06-cut_1.shp";
+  QString aSFileName = REF_DATA_PATH + "/CLC06-cut_1_res.shp";
+  //This test verify only some geom data (shp+shx) without any dbf reading/writing 
+  {
+    Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+    HYDROData_ShapeFile anImporter;
+    QStringList PolygonList;
+    TopTools_SequenceOfShape PolygonFaces;
+    int Type = -1;
+
+    //import LCM from file (#2-4; #12-14 polygons)
+    CPPUNIT_ASSERT( anImporter.ImportPolygons(aFFileName, PolygonList, PolygonFaces, Type));
+    Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+    HYDROData_MapOfFaceToStricklerType aMapFace2ST;
+
+    aMapFace2ST.Add( TopoDS::Face( PolygonFaces(2) ), "" );
+    aMapFace2ST.Add( TopoDS::Face( PolygonFaces(3) ), "" );
+    aMapFace2ST.Add( TopoDS::Face( PolygonFaces(4) ), "" );
+    aMapFace2ST.Add( TopoDS::Face( PolygonFaces(12) ), "" );
+    aMapFace2ST.Add( TopoDS::Face( PolygonFaces(13) ), "" );
+    aMapFace2ST.Add( TopoDS::Face( PolygonFaces(14) ), "" );
+
+    LCM->StoreLandCovers(aMapFace2ST);
+    LCM->SetName("lcm_1");
+
+    TopoDS_Shape aSh = LCM->GetShape();
+    BRepCheck_Analyzer aBCA(aSh);
+    CPPUNIT_ASSERT(aBCA.IsValid());
+
+    //export lcm
+    HYDROData_ShapeFile anExporter;
+    QStringList aNonExpList;
+    anExporter.Export(aSFileName, LCM, aNonExpList);
+    CPPUNIT_ASSERT (aNonExpList.empty());
+
+    aDoc->Close();
+  }
+  {
+    Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+    HYDROData_ShapeFile anImporter;
+    QStringList PolygonList;
+    TopTools_SequenceOfShape PolygonFaces;
+    int Type = -1;
+
+    //import all
+    CPPUNIT_ASSERT( anImporter.ImportPolygons(aSFileName, PolygonList, PolygonFaces, Type));
+    Handle(HYDROData_LandCoverMap) LCM = Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+    HYDROData_MapOfFaceToStricklerType aMapFace2ST;
+    CPPUNIT_ASSERT_EQUAL(PolygonFaces.Length(), 6);
+    for ( int i = 1; i <= PolygonFaces.Length(); i++ )
+      aMapFace2ST.Add( TopoDS::Face( PolygonFaces(i) ), "" );
+
+    LCM->StoreLandCovers(aMapFace2ST);
+    LCM->SetName("lcm_2");
+
+    TopoDS_Shape OutSh = LCM->GetShape();
+    BRepCheck_Analyzer aBCA(OutSh);
+    CPPUNIT_ASSERT(aBCA.IsValid());
+
+    TestViewer::show( OutSh, AIS_Shaded, true, "CLC06-cut_1_res" );
+    CPPUNIT_ASSERT_IMAGES
+
+    aDoc->Close();
+  }
+  CPPUNIT_ASSERT_EQUAL(0, remove(aSFileName.toStdString().c_str()));
+}
+
index 7d5a88aa31fc3a4d760f47037ba48c7fc8d08e21..f8f2a40a7d1cf7f2cd4eb85a89418113085f1c0d 100644 (file)
@@ -44,6 +44,7 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture
   CPPUNIT_TEST( test_shp_import_cyp );
   CPPUNIT_TEST( test_shp_import_clc_dec );
   CPPUNIT_TEST( test_shp_import_nld_areas );
+  CPPUNIT_TEST( test_shp_loop_back );
 #endif
   CPPUNIT_TEST_SUITE_END();
 
@@ -65,6 +66,7 @@ public:
   void test_shp_import_cyp();
   void test_shp_import_clc_dec();
   void test_shp_import_nld_areas();
+  void test_shp_loop_back();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );