]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/BR_LAND_COVER_MAP' into BR_LAND_COVER_REMOVING
authorasl <asl@opencascade.com>
Tue, 20 Oct 2015 10:12:22 +0000 (13:12 +0300)
committerasl <asl@opencascade.com>
Tue, 20 Oct 2015 10:12:22 +0000 (13:12 +0300)
Conflicts:
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h

1  2 
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROData/HYDROData_ShapeFile.cxx
src/HYDROData/HYDROData_ShapeFile.h
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/TestViewer.h
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h

Simple merge
Simple merge
Simple merge
index 6cf7242fa3f7666d7884c5f33df9583cf15a8e84,7dcec1aa3c2a972d91bd0318082ad995617a7522..fd8c5f867f3550c52a7ec04818a8a747680dfdd3
@@@ -1,9 -1,7 +1,8 @@@
  
  #include <TestViewer.h>
 -//#include <random.h>
 +#include <HYDROData_Tool.h>
- #include <random.h>
  #include <OCCViewer_ViewManager.h>
 +#include <OCCViewer_ViewPort3d.h>
  #ifdef WIN32
    #pragma warning ( disable: 4251 )
  #endif
@@@ -68,35 -65,28 +67,39 @@@ Handle(AIS_InteractiveContext) context(
    return TestViewer::viewer()->getAISContext();
  }
  
- QColor randomColor()
+ QColor TestViewer::GetColor(int i)
  {
-   int r = test_rand();
-   int aHue = r%255;
-   //std::cout << "hue: " << aHue << std::endl;
-   QColor aColor = QColor::fromHsl( aHue, 255, 128 );
-   return aColor;
+   QVector<QColor> aCV;
+   aCV  << QColor(0,0,255) 
+     << QColor(0,255,0)
+     << QColor(255,0,0)
+     << QColor(255,255,20) 
+     << QColor(20,255,255) 
+     << QColor(100,100,20) 
+     << QColor(10,100,150);
+   return aCV[i];
  }
  
 -void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor )
 +void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
 +                       int theMode, int theSelectionMode, bool isFitAll, const char* theKey )
  {
 -  double r = theColor.red() / 255.0;
 -  double g = theColor.green() / 255.0;
 -  double b = theColor.blue() / 255.0;
 +  context()->EraseAll( Standard_False );
 +  context()->Display( theObject, theMode, theSelectionMode );
 +
 +  myKey = theKey;
  
 +  if( isFitAll )
 +  {
 +    viewWindow()->onTopView();
 +    viewWindow()->onFitAll();
 +  }
 +}
 +
 +void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor )
 +{
    Handle(AIS_Shape) aShape = new AIS_Shape( theShape );
    aShape->SetMaterial( Graphic3d_NOM_PLASTIC );
 -  aShape->SetColor( Quantity_Color( r, g, b, Quantity_TOC_RGB ) );
 +  aShape->SetColor( HYDROData_Tool::toOccColor( theColor ) );
    context()->Display( aShape, theMode, 0, Standard_False );
  
    if( isFitAll )
  
  void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey )
  {
 -  context()->EraseAll();
 +  context()->EraseAll( Standard_False );
    
    myKey = theKey;
-   test_srand( 0 );
-   if( theShape.ShapeType()==TopAbs_COMPOUND )
+   int i = 0;
+   if( theShape.ShapeType()==TopAbs_SHELL )
    {
      TopoDS_Iterator anIt( theShape );
-     for( ; anIt.More(); anIt.Next() )
-       show( anIt.Value(), theMode, false, randomColor() );
+     for( ; anIt.More(); anIt.Next(), i++ )
+       show( anIt.Value(), theMode, false, GetColor(i) );
    }
    else
-     show( theShape, theMode, false, randomColor() );
+     show( theShape, theMode, false, GetColor(0) );
  
    if( isFitAll )
    {
index 73e50b59e29e7e773b2f630a8c902cfb5d9f58ee,64438b6cea009aa5092a49220c4d3566c4330baa..4f6ee5503869499d020421c597175e177087a0bf
@@@ -22,9 -18,8 +22,10 @@@ public
    static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor );
    static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey );
    static bool AssertImages( QString& theMessage );
+   static QColor GetColor(int i);
  
 +  static Handle_Aspect_ColorScale showColorScale();
 +
  private:
    static OCCViewer_ViewManager* myViewManager;
    static OCCViewer_ViewWindow* myViewWindow;
index e05a4cd2ccbd0d1f75f047110af8bf9504de40cf,a2219f248bb5725daf99a20134a7d187abcd7d96..ce19c750f7937809c02d30b2690d6dd351b38752
  #include <TestViewer.h>
  #include <TopTools_ListOfShape.hxx>
  #include <AIS_DisplayMode.hxx>
 +#include <Aspect_ColorScale.hxx>
  #include <QString>
  #include <QColor>
+ #include <QMap>
  #include <BRepTools.hxx>
  #include <BRep_Builder.hxx>
  
@@@ -448,69 -444,46 +448,112 @@@ void test_HYDROData_LandCoverMap::test_
      CPPUNIT_ASSERT_IMAGES
      CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
    }
 -}
+ }
+ void test_HYDROData_LandCoverMap::test_import_dbf()
+ {
+   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() );
+   QString aFileName = REF_DATA_PATH + "/t1.dbf";
+   QStringList aDBFV;
+   QStringList aST;
+   aDBFV.append("100");
+   aDBFV.append("200");
+   aDBFV.append("300");
+   aST.append("water");
+   aST.append("forest");
+   aST.append("road");
+   // aST.size() == aDBFV.size()!!
+   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 );
+   for (int i = 0; i < 3; i++)
+     aMap->Add(aPolyline, "");
+   TopoDS_Face aLC1 = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
+   
+   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
+   QMap<int, int> Inds;
+   Inds.insert(1, 1);
+   Inds.insert(2, 2);
+   Inds.insert(3, 3);
+   aMap->ImportDBF(aFileName, "TESTFIELD1", aDBFV, aST, Inds);
+   HYDROData_LandCoverMap::Iterator anIt( aMap );
+  
+   CPPUNIT_ASSERT_EQUAL(true, "water" == anIt.StricklerType());
+   anIt.Next();
+   CPPUNIT_ASSERT_EQUAL(true, "forest" == anIt.StricklerType());
 +}
 +
 +void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
 +{
 +  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 +
 +  Handle(HYDROData_StricklerTable) aTable =
 +    Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
 +  CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
 +
 +  Handle(HYDROData_LandCoverMap) aMap =
 +    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
 +
 +  TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
 +  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
 +
 +  TopoDS_Face aLC2 = LandCover( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
 +                                                   44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
 +                                                  128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
 +                                                  31 << 114 );
 +  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
 +
 +  TopoDS_Face aLC3 = LandCover( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
 +                                                 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
 +  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
 +
 +  Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
 +  aPrs->SetTable( aTable );
 +  TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByTypes" );
 +  CPPUNIT_ASSERT_IMAGES
 +
 +  aDoc->Close();
 +}
 +
 +void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
 +{
 +  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 +
 +  Handle(HYDROData_StricklerTable) aTable =
 +    Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
 +  CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
 +
 +  Handle(HYDROData_LandCoverMap) aMap =
 +    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
 +
 +  TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
 +  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
 +
 +  TopoDS_Face aLC2 = LandCover( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
 +                                                   44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
 +                                                  128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
 +                                                  31 << 114 );
 +  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
 +
 +  TopoDS_Face aLC3 = LandCover( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
 +                                                 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
 +  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
 +
 +  Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
 +  aPrs->SetTable( aTable );
 +  aPrs->SetColorScale( TestViewer::showColorScale() );
 +  TestViewer::show( aPrs, AIS_Shaded, 1, true, "LandCoverMap_PrsByCoeff" );
 +  CPPUNIT_ASSERT_IMAGES
 +
 +  aDoc->Close();
 +}
++
index cbe087706fe57fe90c6fac5907e47ef36a583c9c,4f10b1edae96c4b2a00892e3a9ca4bfe48ae7e78..95ea4d4b753ffb397d367d590c520fc5f2b1d9ef
@@@ -32,8 -32,7 +32,9 @@@ class test_HYDROData_LandCoverMap : pub
    CPPUNIT_TEST( test_remove );
    CPPUNIT_TEST( test_merge_faces_boxes );
    CPPUNIT_TEST( test_merge_faces_circles );
+   CPPUNIT_TEST( test_import_dbf );
 +  CPPUNIT_TEST( test_land_cover_prs_by_types );
 +  CPPUNIT_TEST( test_land_cover_prs_by_coeff );
    CPPUNIT_TEST_SUITE_END();
  
  public:
@@@ -44,8 -43,7 +45,9 @@@
    void test_remove();
    void test_merge_faces_boxes();
    void test_merge_faces_circles();
+   void test_import_dbf();
 +  void test_land_cover_prs_by_types();
 +  void test_land_cover_prs_by_coeff();
  };
  
  CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );