#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";
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());
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());
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());
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()));
+}
+