X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_ShapeFile.h;h=d74e63d5fa8ccd971d490f8f1912e3f64dd5826f;hb=a95289fabbb6fbf6f32c06207422c65aafd5bd65;hp=3fef48fffd34b61d4e30f1c89baa0ce5506e31ef;hpb=5f19fc7af832224fdb587fbcfe0eed4c41d0d6aa;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_ShapeFile.h b/src/HYDROData/HYDROData_ShapeFile.h index 3fef48ff..d74e63d5 100644 --- a/src/HYDROData/HYDROData_ShapeFile.h +++ b/src/HYDROData/HYDROData_ShapeFile.h @@ -1,8 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -35,38 +31,133 @@ class gp_XYZ; class Handle_HYDROData_PolylineXY; class Handle_HYDROData_Polyline3D; -class Handle_HYDROData_LandCover; +class Handle(HYDROData_Document); class TopTools_SequenceOfShape; class TopoDS_Face; +class TopoDS_Shape; +class Handle_HYDROData_Entity; +class Handle_HYDROData_LandCoverMap; class HYDROData_ShapeFile { +public: + +enum ShapeType +{ + ShapeType_Polyline, + ShapeType_Polygon +}; + +enum DBF_FieldType +{ + DBF_FieldType_None, + DBF_FieldType_String, + DBF_FieldType_Integer, + DBF_FieldType_Double, + DBF_FieldType_Invalid +}; + + +struct DBF_AttrValue +{ + DBF_AttrValue() + { + myIntVal = -1; + myDoubleVal = -1.0; + myIsNull = true; + myFieldType = DBF_FieldType_None; + } + QString myStrVal; + int myIntVal; + double myDoubleVal; + std::string myRawValue; + DBF_FieldType myFieldType; + bool myIsNull; +}; + public: HYDRODATA_EXPORT HYDROData_ShapeFile( ); virtual HYDRODATA_EXPORT ~HYDROData_ShapeFile(); -public: //Export operation - HYDRODATA_EXPORT void Export(const QString& aFileName, + HYDRODATA_EXPORT void Export(Handle(HYDROData_Document) theDocument, + const QString& aFileName, NCollection_Sequence aPolyXYSeq, NCollection_Sequence aPoly3DSeq, - NCollection_Sequence aLCSeq, QStringList& aNonExpList); - int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly ); - int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly ); - int WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC ); + + HYDRODATA_EXPORT void Export(Handle(HYDROData_Document) theDocument, + const QString& aFileName, + const Handle_HYDROData_LandCoverMap& aLCM, + QStringList& aNonExpList, + bool bCheckLinear = true, + bool bUseDiscr = false, + double theDefl = 0.1); + + int WriteObjectPolyXY(Handle(HYDROData_Document) theDocument, SHPHandle theShpHandle, + Handle_HYDROData_PolylineXY thePoly ); + + int WriteObjectPoly3D(Handle(HYDROData_Document) theDocument, SHPHandle theShpHandle, + Handle_HYDROData_Polyline3D thePoly ); + + int WriteObjectPolygon(Handle(HYDROData_Document) theDocument, SHPHandle theShpHandle, + const TopoDS_Shape& theInputShape, bool bUseDiscr, double theDefl ); + //Import + bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile); //Import Landcover - void Parse(SHPHandle theHandle); - void ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F); - HYDRODATA_EXPORT bool ImportLandCovers(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces); + void ReadSHPPolygon(Handle(HYDROData_Document) theDocument, SHPObject* anObj, int i, TopoDS_Face& F); + + HYDRODATA_EXPORT int ImportPolygons(Handle(HYDROData_Document) theDocument, + const QString theFileName, + QStringList& thePolygonsList, + TopTools_SequenceOfShape& theFaces, + int& theShapeTypeOfFile); + HYDRODATA_EXPORT void Free(); - /// + + //Import Polyline + void ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, + int theInd, NCollection_Sequence& theEntities, bool bReadAsPolyline = false); + + void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, + int theInd, NCollection_Sequence& theEntities); + + HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName, + NCollection_Sequence& theEntities, int& theShapeTypeOfFile); + + HYDRODATA_EXPORT QString GetShapeTypeName(int theType); + + //DBF I/O Methods + HYDRODATA_EXPORT bool CheckDBFFileExisting(const QString& theSHPFilePath, QString& thePathToDBFFile); + HYDRODATA_EXPORT bool DBF_OpenDBF(const QString& thePathToDBFFile); + HYDRODATA_EXPORT int DBF_GetNbFields(); + HYDRODATA_EXPORT QStringList DBF_GetFieldList(); + HYDRODATA_EXPORT void DBF_GetFieldTypeList(std::vector& FTVect); + HYDRODATA_EXPORT int DBF_GetNbRecords(); + HYDRODATA_EXPORT void DBF_CloseDBF(); + HYDRODATA_EXPORT void DBF_GetAttributeList(int theIndexOfField, std::vector& theAttrV); + HYDRODATA_EXPORT bool DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector& theAttrV, bool bUseStrValue); + private: - void ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle); + + void ProcessFace(Handle(HYDROData_Document) theDocument, + const TopoDS_Face& theFace, SHPHandle theShpHandle, + bool bUseDiscr, double theDefl); + + bool CheckLinear(const TopoDS_Shape& theInpShape); + + int TryOpenShapeFile(QString theFileName); + + void GetFreeIndices(std::vector& theAllowedIndexes, QString strName, size_t theObjsSize, + QStringList theExistingNames, QString theBaseFileName); + private: std::vector mySHPObjects; SHPHandle myHSHP; + DBFHandle myHDBF; + + friend class test_HYDROData_ShapeFile; }; #endif