1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDRODATA_SHAPEFILE_H
20 #define HYDRODATA_SHAPEFILE_H
23 #include <NCollection_Sequence.hxx>
24 #include <QStringList>
25 #include "HYDROData.h"
32 class Handle_HYDROData_PolylineXY;
33 class Handle_HYDROData_Polyline3D;
34 class Handle(HYDROData_Document);
35 class TopTools_SequenceOfShape;
38 class Handle_HYDROData_Entity;
39 class Handle_HYDROData_LandCoverMap;
41 class HYDROData_ShapeFile
56 DBF_FieldType_Integer,
69 myFieldType = DBF_FieldType_None;
74 std::string myRawValue;
75 DBF_FieldType myFieldType;
80 HYDRODATA_EXPORT HYDROData_ShapeFile( );
81 virtual HYDRODATA_EXPORT ~HYDROData_ShapeFile();
84 HYDRODATA_EXPORT void Export(const QString& aFileName,
85 NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq,
86 NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq,
87 const Handle_HYDROData_LandCoverMap& aLCM,
88 QStringList& aNonExpList);
89 int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly );
90 int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
91 int WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape );
93 bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile);
95 void ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F);
96 HYDRODATA_EXPORT int ImportPolygons(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile);
97 HYDRODATA_EXPORT void Free();
99 void ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
100 int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
101 void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
102 int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
103 HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
104 NCollection_Sequence<Handle_HYDROData_Entity>& theEntities, int& theShapeTypeOfFile);
105 HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
108 HYDRODATA_EXPORT bool CheckDBFFileExisting(const QString& theSHPFilePath, QString& thePathToDBFFile);
109 HYDRODATA_EXPORT bool DBF_OpenDBF(const QString& thePathToDBFFile);
110 HYDRODATA_EXPORT int DBF_GetNbFields();
111 HYDRODATA_EXPORT QStringList DBF_GetFieldList();
112 HYDRODATA_EXPORT void DBF_GetFieldTypeList(std::vector<DBF_FieldType>& FTVect);
113 HYDRODATA_EXPORT int DBF_GetNbRecords();
114 HYDRODATA_EXPORT void DBF_CloseDBF();
115 HYDRODATA_EXPORT void DBF_GetAttributeList(int theIndexOfField, std::vector<DBF_AttrValue>& theAttrV);
116 HYDRODATA_EXPORT bool DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector<DBF_AttrValue>& theAttrV, bool bUseStrValue);
119 void ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle);
120 int TryOpenShapeFile(QString theFileName);
122 std::vector<SHPObject*> mySHPObjects;
126 friend class test_HYDROData_ShapeFile;