]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
new functions for python wrapping
authorisn <isn@opencascade.com>
Fri, 13 Nov 2015 17:56:59 +0000 (20:56 +0300)
committerisn <isn@opencascade.com>
Mon, 16 Nov 2015 08:56:42 +0000 (11:56 +0300)
(not tested yet)

src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROPy/HYDROData_LandCoverMap.sip

index 06c80d4d938f2ffaa1d01a9d8a1aedec0cbca71d..368fdc60e00852f1957ad4d74348e73d457c4e55 100644 (file)
@@ -52,6 +52,7 @@
 #include <ShapeFix_Shape.hxx>
 #include <BRepCheck_Shell.hxx>
 #include <BRepCheck_ListOfStatus.hxx>
+#include <TopTools_SequenceOfShape.hxx>
 
 
 #include <QFile>
@@ -995,3 +996,59 @@ double HYDROData_LandCoverMap::GetTransparency() const
   return anAttr->Get();
   
 }
+
+bool HYDROData_LandCoverMap::ImportShp( const QString& theFileName,
+                                        const QList<int>& theIndices )
+{
+  HYDROData_ShapeFile anImporter;
+  QStringList aPolyList; 
+  TopTools_SequenceOfShape aFaces;
+  int aSHapeType = -1;
+  int Stat = anImporter.ImportPolygons(theFileName, aPolyList, aFaces, aSHapeType);
+  //
+  if (Stat != 1)
+    return false;
+  //
+  HYDROData_MapOfFaceToStricklerType aMapFace2ST;
+  int maxInd = *std::max_element(theIndices.begin(), theIndices.end());
+  if (maxInd > aPolyList.length())
+    return false;
+  //
+  if (theIndices.empty())
+  {
+    //import all shapes
+    for ( int i = 1; i <=aFaces.Length(); i++ )
+    {
+      TopoDS_Shape aShape = aFaces(i);
+      if ( aShape.IsNull() ) 
+        continue;
+      aMapFace2ST.Add( TopoDS::Face( aShape ), "" );
+    }
+  }
+  else
+  {
+    //import given indices
+    foreach ( int Ind, theIndices )
+    {
+      TopoDS_Shape aShape = aFaces(Ind + 1);
+      if ( aShape.IsNull() ) 
+        continue;
+      aMapFace2ST.Add( TopoDS::Face( aShape ), "" );
+    }
+  }
+  //
+  StoreLandCovers(aMapFace2ST);
+  return true;
+}
+
+bool HYDROData_LandCoverMap::ExportShp( const QString& theFileName) const
+{
+  HYDROData_ShapeFile anExporter;
+  QStringList aList;
+  anExporter.Export(theFileName, this, aList);
+  if (aList.empty())
+    return true;
+  else 
+    return false;
+}
+
index 8aea8443fce9d90c7579405a4818dcb96c065ac0..caf89f64bea7d188981b981fd26f0a6405b8459a 100644 (file)
@@ -99,6 +99,11 @@ public:
                                    const QStringList& theDBFValues,
                                    const QStringList& theStricklerTypes ) const;
 
+  bool ImportShp( const QString& theFileName, 
+                  const QList<int>& theIndices =  QList<int>());
+
+  bool ExportShp( const QString& theFileName) const;
+
   HYDRODATA_EXPORT bool ExportTelemac( const QString& theFileName, double theDeflection ) const;
 
   HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType );
index cd0ed5b8713d08b48da1641e5cd9668b51bbda1b..5b351ccd80e8520a21c107237a047f6a60fa6c30 100644 (file)
@@ -61,6 +61,10 @@ public:
     const QString& theFieldName, 
     const QStringList& theDBFValues,
     const QStringList& theStricklerTypes ) const;
+  bool ImportShp( const QString& theFileName);
+
+  bool ExportShp( const QString& theFileName) const;
 
   bool ExportTelemac( const QString& theFileName, double theDeflection ) const;