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
22 #include "HYDROData.h"
24 #include <NCollection_Sequence.hxx>
26 #include <TopTools_SequenceOfShape.hxx>
27 #include <NCollection_IndexedDataMap.hxx>
28 #include <QStringList>
37 class HYDROData_PolylineXY;
38 class HYDROData_Polyline3D;
39 class HYDROData_Document;
42 class HYDROData_Entity;
43 class HYDROData_LandCoverMap;
45 class HYDROData_ShapeFile
60 DBF_FieldType_Integer,
67 ImportShapeType_Polyline,
68 ImportShapeType_Polyline3D,
69 ImportShapeType_Polygon,
80 myFieldType = DBF_FieldType_None;
85 std::string myRawValue;
86 DBF_FieldType myFieldType;
91 HYDRODATA_EXPORT HYDROData_ShapeFile( );
92 virtual HYDRODATA_EXPORT ~HYDROData_ShapeFile();
95 HYDRODATA_EXPORT void Export(Handle(HYDROData_Document) theDocument,
96 const QString& aFileName,
97 NCollection_Sequence<Handle(HYDROData_PolylineXY)> aPolyXYSeq,
98 NCollection_Sequence<Handle(HYDROData_Polyline3D)> aPoly3DSeq,
99 QStringList& aNonExpList);
101 HYDRODATA_EXPORT void Export(Handle(HYDROData_Document) theDocument,
102 const QString& aFileName,
103 const Handle(HYDROData_LandCoverMap)& aLCM,
104 QStringList& aNonExpList,
105 bool bCheckLinear = true,
106 bool bUseDiscr = false,
107 double theDefl = 0.1);
109 int WriteObjectPolyXY(Handle(HYDROData_Document) theDocument, SHPHandle theShpHandle,
110 Handle(HYDROData_PolylineXY) thePoly );
112 int WriteObjectPoly3D(Handle(HYDROData_Document) theDocument, SHPHandle theShpHandle,
113 Handle(HYDROData_Polyline3D) thePoly );
115 int WriteObjectPolygon(Handle(HYDROData_Document) theDocument, SHPHandle theShpHandle,
116 const TopoDS_Shape& theInputShape, bool bUseDiscr, double theDefl );
118 bool Parse(SHPHandle theHandle, ShapeType theType);
120 void ReadSHPPolygon(Handle(HYDROData_Document) theDocument, SHPObject* anObj, int i, TopoDS_Face& F);
122 HYDRODATA_EXPORT int ImportPolygons(Handle(HYDROData_Document) theDocument,
123 const QString theFileName,
124 QStringList& thePolygonsList,
125 TopTools_SequenceOfShape& theFaces);
127 HYDRODATA_EXPORT void Free();
130 void ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
131 int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
132 bool bReadAsPolylin = false);
134 void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj,
135 const Handle(HYDROData_PolylineXY)& aPolylineXY,
136 NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
138 HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
139 NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*>& theEntitiesToSHPObj,
140 ImportShapeType theShapeTypesToImport);
142 HYDRODATA_EXPORT int ImportPolylines3D(Handle(HYDROData_Document) theDocument,
143 NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*> thePolyXYToObj,
144 NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
145 ImportShapeType theShapeTypesToImport);
147 HYDRODATA_EXPORT int OpenAndParse(const QString& theFileName);
150 HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
152 HYDRODATA_EXPORT int GetShapeType() const;
156 HYDRODATA_EXPORT bool CheckDBFFileExisting(const QString& theSHPFilePath, QString& thePathToDBFFile);
157 HYDRODATA_EXPORT bool DBF_OpenDBF(const QString& thePathToDBFFile);
158 HYDRODATA_EXPORT int DBF_GetNbFields();
159 HYDRODATA_EXPORT QStringList DBF_GetFieldList();
160 HYDRODATA_EXPORT void DBF_GetFieldTypeList(std::vector<DBF_FieldType>& FTVect);
161 HYDRODATA_EXPORT int DBF_GetNbRecords();
162 HYDRODATA_EXPORT void DBF_CloseDBF();
163 HYDRODATA_EXPORT void DBF_GetAttributeList(int theIndexOfField, std::vector<DBF_AttrValue>& theAttrV);
164 HYDRODATA_EXPORT bool DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector<DBF_AttrValue>& theAttrV, bool bUseStrValue);
168 void ProcessFace(Handle(HYDROData_Document) theDocument,
169 const TopoDS_Face& theFace, SHPHandle theShpHandle,
170 bool bUseDiscr, double theDefl);
172 bool CheckLinear(const TopoDS_Shape& theInpShape);
174 int TryOpenShapeFile(QString theFileName);
176 void GetFreeIndices(std::vector<int>& theAllowedIndexes, QString strName, size_t theObjsSize,
177 QStringList theExistingNames, QString theBaseFileName);
180 std::vector<SHPObject*> mySHPObjects;
184 friend class test_HYDROData_ShapeFile;