From: isn Date: Fri, 13 Nov 2015 17:56:59 +0000 (+0300) Subject: new functions for python wrapping X-Git-Tag: v1.5~38^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c49173e7ecf4f500c55ef5d692c6a0ca497bf997;p=modules%2Fhydro.git new functions for python wrapping (not tested yet) --- diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 06c80d4d..368fdc60 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -995,3 +996,59 @@ double HYDROData_LandCoverMap::GetTransparency() const return anAttr->Get(); } + +bool HYDROData_LandCoverMap::ImportShp( const QString& theFileName, + const QList& 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; +} + diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index 8aea8443..caf89f64 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -99,6 +99,11 @@ public: const QStringList& theDBFValues, const QStringList& theStricklerTypes ) const; + bool ImportShp( const QString& theFileName, + const QList& theIndices = QList()); + + 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 ); diff --git a/src/HYDROPy/HYDROData_LandCoverMap.sip b/src/HYDROPy/HYDROData_LandCoverMap.sip index cd0ed5b8..5b351ccd 100644 --- a/src/HYDROPy/HYDROData_LandCoverMap.sip +++ b/src/HYDROPy/HYDROData_LandCoverMap.sip @@ -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;