]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
#refs 651: draft version of the test on dump land cover map to Python
authorasl <asl@opencascade.com>
Fri, 23 Oct 2015 06:04:31 +0000 (09:04 +0300)
committerasl <asl@opencascade.com>
Fri, 23 Oct 2015 06:04:31 +0000 (09:04 +0300)
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h

index 0cf4c403258ebc2c8dffdbf4913aca7922b66b57..93457716225fdd41c6166418d181343bae9f0950 100644 (file)
@@ -267,6 +267,7 @@ bool HYDROData_Document::DumpToPython( const QString& theFileName,
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CHANNEL );
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_DIGUE );
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_OBSTACLE );
+  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_LAND_COVER_MAP );
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CALCULATION );
 
   // Dump code to close python fuction
index 5ba643a95dc305feff80b17f73d24e00db665a8a..a429e381ae43931784e002cf925fac6169926e8a 100644 (file)
@@ -749,3 +749,27 @@ TopoDS_Face HYDROData_LandCoverMap::FindByPoint( const gp_Pnt2d& thePoint, QStri
   theType = "";
   return TopoDS_Face();
 }
+
+/**
+  Dump to Python
+  @param theTreatedObjects the map of treated objects
+*/
+QStringList HYDROData_LandCoverMap::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList = dumpObjectCreation( theTreatedObjects );
+  QString aName = GetObjPyName();
+
+  //Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+  //setPythonReferenceObject( theTreatedObjects, aResList, aHydAxis, "SetHydraulicAxis" );
+
+  //HYDROData_SequenceOfObjects aSeqOfProfiles = GetProfiles();
+  //for ( int i = 1, aNb = aSeqOfProfiles.Size(); i <= aNb; ++i )
+  //{
+    //const Handle(HYDROData_Entity) aProfile = aSeqOfProfiles.Value( i );
+    //setPythonReferenceObject( theTreatedObjects, aResList, aProfile, "AddProfile" );
+  //}
+
+  //TODO
+
+  return aResList;
+}
index 1bb887e4bb1419248c28ab3b935045b96d79c97a..cf6b7ca508dd1e4d2704f2af03d30438da92c58f 100644 (file)
@@ -108,6 +108,8 @@ public:
 
   HYDRODATA_EXPORT TopoDS_Shape GetShape() const;
 
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
 protected:
   void SetShape( const TopoDS_Shape& );
 
index 8f38a522f4d88a6c846b8e3102fe6408dde1f022..829211fac81cc8677f267bab061f2a43100e5e74 100644 (file)
@@ -34,6 +34,7 @@
 #include <QString>
 #include <QColor>
 #include <QMap>
+#include <QDir>
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
 
@@ -520,3 +521,32 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
   aDoc->Close();
 }
 
+void test_HYDROData_LandCoverMap::test_dump_python()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_LandCoverMap) aMap =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  aMap->SetName( "test_LCM" );
+
+  CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
+
+  TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
+
+  TopoDS_Face aLC2 = Face( 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, "test2" ) );
+
+  TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
+                                            127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
+
+  QString aTmpPath = QDir::tempPath() + "/lc_dump.py";
+  CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
+
+  //TODO: compare files
+}
index 95ea4d4b753ffb397d367d590c520fc5f2b1d9ef..4d0a14d780768bad285969b2195ef6727af2ada4 100644 (file)
@@ -35,6 +35,7 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture
   CPPUNIT_TEST( test_import_dbf );
   CPPUNIT_TEST( test_land_cover_prs_by_types );
   CPPUNIT_TEST( test_land_cover_prs_by_coeff );
+  CPPUNIT_TEST( test_dump_python );
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -48,6 +49,7 @@ public:
   void test_import_dbf();
   void test_land_cover_prs_by_types();
   void test_land_cover_prs_by_coeff();
+  void test_dump_python();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );