#include <ShapeFix_Shape.hxx>
#include <BRepCheck_Shell.hxx>
#include <BRepCheck_ListOfStatus.hxx>
+#include <TopTools_SequenceOfShape.hxx>
#include <QFile>
return false;
}
-bool HYDROData_LandCoverMap::ImportSHP( const QString& theSHPFileName )
-{
- HYDROData_ShapeFile anImporter;
- QStringList aPolygonsList;
- TopTools_SequenceOfShape aPolygonFaces;
- int aShapeTypeOfFile;
- int aStatus = anImporter.ImportPolygons( theSHPFileName, aPolygonsList, aPolygonFaces, aShapeTypeOfFile);
-
- bool isOK = ( aStatus == 1 );
- if( isOK )
- {
- QString aDefaultStricklerType = "";
-
- HYDROData_MapOfFaceToStricklerType aFaces;
- for( int i=1, n=aPolygonFaces.Length(); i<=n; i++ )
- {
- TopoDS_Shape aShape = aPolygonFaces.Value( i );
- if( aShape.ShapeType()==TopAbs_FACE )
- aFaces.Add( TopoDS::Face( aShape ), aDefaultStricklerType );
- }
-
- StoreLandCovers( aFaces );
- }
-
- anImporter.Free();
- return isOK;
-}
-
/**
Load attributes from DBF File
///
return DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING;
}
-void HYDROData_LandCoverMap::ExportSHP( const QString& theSHPFileName ) const
-{
- //TODO
-}
-
/**
Export attributes to DBF File
///
QString aDbfFileName = thePyScriptPath;
aDbfFileName.replace( ".py", ".dbf" );
- //TODO: export shape file
- ExportSHP( aShpFileName );
+ ExportSHP( aShpFileName, true, 0.1 );
QString anAttr = "CODE_06"; //TODO: some custom choice
QStringList anAttrValues, aTypes;
return anAttr->Get();
}
+
+bool HYDROData_LandCoverMap::ImportSHP( const QString& theSHPFileName,
+ const QList<int>& theIndices )
+{
+ HYDROData_ShapeFile anImporter;
+ QStringList aPolyList;
+ TopTools_SequenceOfShape aFaces;
+ int aSHapeType = -1;
+ int Stat = anImporter.ImportPolygons(theSHPFileName, 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& theSHPFileName, bool bUseDiscr, double theDefl) const
+{
+ HYDROData_ShapeFile anExporter;
+ QStringList aList;
+ anExporter.Export(theSHPFileName, this, aList, bUseDiscr, theDefl );
+ if (aList.empty())
+ return true;
+ else
+ return false;
+}
+