Salome HOME
refs #1813 ... lot 14 combined commit : parts : 1 - 16
[modules/hydro.git] / src / HYDROData / HYDROData_ShapeFile.h
index eb381ceecc4263f62dd29f22ea4fde06464eaf74..b546bd235a5123a713ea2826bd283d930db6d19a 100644 (file)
@@ -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
 #ifndef HYDRODATA_SHAPEFILE_H
 #define HYDRODATA_SHAPEFILE_H
 
-#include <vector>
+#include "HYDROData.h"
+
 #include <NCollection_Sequence.hxx>
+
+#include <TopTools_SequenceOfShape.hxx>
+
 #include <QStringList>
-#include "HYDROData.h"
+
+#include <vector>
+
 
 //extern "C" {
 #include <shapefil.h> 
 //};
 
 class gp_XYZ;
-class Handle_HYDROData_PolylineXY;
-class Handle_HYDROData_Polyline3D;
-class Handle(HYDROData_Document);
-class TopTools_SequenceOfShape;
+class HYDROData_PolylineXY;
+class HYDROData_Polyline3D;
+class HYDROData_Document;
 class TopoDS_Face;
-class Handle_HYDROData_Entity;
-class Handle_HYDROData_LandCoverMap;
+class TopoDS_Shape;
+class HYDROData_Entity;
+class HYDROData_LandCoverMap;
 
 class HYDROData_ShapeFile 
 {
@@ -61,6 +63,13 @@ enum DBF_FieldType
   DBF_FieldType_Invalid
 };
 
+enum ImportShapeType
+{
+  ImportShapeType_Polyline,
+  ImportShapeType_Polyline3D,
+  ImportShapeType_Polygon,
+  ImportShapeType_All
+};
 
 struct DBF_AttrValue
 {
@@ -84,43 +93,79 @@ public:
   virtual HYDRODATA_EXPORT ~HYDROData_ShapeFile();
 
   //Export operation
-  HYDRODATA_EXPORT void Export(const QString& aFileName, 
-                               NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq,
-                               NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq,
-                               const Handle_HYDROData_LandCoverMap& aLCSeq,
+  HYDRODATA_EXPORT void Export(Handle(HYDROData_Document) theDocument,
+                               const QString& aFileName,
+                               NCollection_Sequence<Handle(HYDROData_PolylineXY)> aPolyXYSeq,
+                               NCollection_Sequence<Handle(HYDROData_Polyline3D)> aPoly3DSeq,
                                QStringList& aNonExpList);
-  int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly );
-  int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
-  //TODO: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 ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F);
-  HYDRODATA_EXPORT int ImportLandCovers(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile);
+  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<Handle_HYDROData_Entity>& theEntities);
+                     int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
+                     bool bReadAsPolylin = false);
+
   void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, 
-                        int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+                     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);
+                                       NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile,
+                                       ImportShapeType theShapeTypesToImport);
+
   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);
-  bool DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector<DBF_AttrValue>& theAttrV, bool bUseStrValue);
+  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<DBF_FieldType>& FTVect);
+  HYDRODATA_EXPORT int DBF_GetNbRecords();
+  HYDRODATA_EXPORT void DBF_CloseDBF();
+  HYDRODATA_EXPORT void DBF_GetAttributeList(int theIndexOfField, std::vector<DBF_AttrValue>& theAttrV);
+  HYDRODATA_EXPORT bool DBF_WriteFieldAndValues(const QString& theFileName, const QString& theFieldName, DBF_FieldType theType, const std::vector<DBF_AttrValue>& 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<int>& theAllowedIndexes, QString strName, size_t theObjsSize,
+                      QStringList theExistingNames, QString theBaseFileName);
+
 private:
   std::vector<SHPObject*> mySHPObjects;
   SHPHandle myHSHP;