Salome HOME
Merge branch 'BR_LAND_COVER_MAP' into BR_DBF_SUPPORT
[modules/hydro.git] / src / HYDROData / HYDROData_ShapeFile.h
index 3fef48fffd34b61d4e30f1c89baa0ce5506e31ef..11517a6647d937b6106706dad2aae02b2a3c28f7 100644 (file)
@@ -36,17 +36,46 @@ 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 Handle_HYDROData_Entity;
 
 class HYDROData_ShapeFile 
 {
 
+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() 
+  {
+    myIsNull = true;
+    myFieldType = DBF_FieldType_None;
+  }
+  QString myStrVal;
+  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, 
                                NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq,
@@ -56,17 +85,40 @@ public:
   int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly );
   int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
   int WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC );
+  //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(SHPObject* anObj, int i, TopoDS_Face& F);
+  HYDRODATA_EXPORT int ImportLandCovers(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<Handle_HYDROData_Entity>& theEntities);
+  void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, 
+                        int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+  HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName, 
+                       NCollection_Sequence<Handle_HYDROData_Entity>& theEntities, int& theShapeTypeOfFile);
+  HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
+
+  //DBF I/O Methods
+  bool CheckDBFFileExisting(const QString& theSHPFilePath, QString& thePathToDBFFile);
+  bool DBF_OpenDBF(const QString& thePathToDBFFile);
+  int DBF_GetNbFields();
+  QStringList DBF_GetFieldList();
+  void DBF_GetFieldTypeList(std::vector<DBF_FieldType>& FTVect);
+  int DBF_GetNbRecords();
+  void DBF_CloseDBF();
+  void DBF_GetAttributeList(int theIndexOfField, std::vector<DBF_AttrValue>& theAttrV);
+
 private:
   void ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle);
+  int TryOpenShapeFile(QString theFileName);
 private:
   std::vector<SHPObject*> mySHPObjects;
   SHPHandle myHSHP;
+  DBFHandle    myHDBF;
+
+  friend class test_HYDROData_ShapeFile;
 };
 
 #endif