OGS
SHPInterface.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <string>
17#include <vector>
18
19//ShapeLib includes
20#include <shapefil.h>
21
22
23namespace GeoLib {
24 class GEOObjects;
25 class Polyline;
26}
27
28namespace MeshLib {
29 class Mesh;
30 class Element;
31}
32
33
34namespace FileIO
35{
36
40class SHPInterface final
41{
42public:
44 enum class OGSType
45 {
46 UNDEFINED = 0,
47 POINT = 1,
48 STATION = 2,
49 POLYLINE = 3,
50 POLYGON = 4
51 };
52
54 explicit SHPInterface(GeoLib::GEOObjects& geoObjects)
55 : _geoObjects(geoObjects)
56 {
57 }
58
60 static bool readSHPInfo(const std::string& filename, int& shapeType,
61 int& numberOfEntities);
62
64 void readSHPFile(const std::string& filename, OGSType choice,
65 const std::string& listName, std::string const& gmsh_path);
66
69 static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh);
70
71private:
73 void readPoints (const SHPHandle &hSHP, int numberOfElements, std::string listName);
74
76 void readStations (const SHPHandle &hSHP, int numberOfElements, std::string listName);
77
79 void readPolylines (const SHPHandle &hSHP, int numberOfElements, std::string listName);
80
82 void readPolygons(const SHPHandle& hSHP, int numberOfElements,
83 const std::string& listName,
84 std::string const& gmsh_path);
85
87 static SHPObject* createShapeObject(MeshLib::Element const& e,
88 std::size_t const shp_record);
89
91};
92
93} // namespace FileIO
Manages the import of ESRI shape files into GeoLib.
SHPInterface(GeoLib::GEOObjects &geoObjects)
Constructor.
void readPolylines(const SHPHandle &hSHP, int numberOfElements, std::string listName)
Reads lines into a vector of Polyline objects.
static bool readSHPInfo(const std::string &filename, int &shapeType, int &numberOfEntities)
Reads the header of the shape file.
void readPoints(const SHPHandle &hSHP, int numberOfElements, std::string listName)
Reads points into a vector of Point objects.
OGSType
Connection between ESRI type system for shape files and OGS GeoLib.
void readStations(const SHPHandle &hSHP, int numberOfElements, std::string listName)
Reads points into a vector of Point objects and marks them as Station.
void readSHPFile(const std::string &filename, OGSType choice, const std::string &listName, std::string const &gmsh_path)
Reads data from the shape file.
GeoLib::GEOObjects & _geoObjects
static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh)
static SHPObject * createShapeObject(MeshLib::Element const &e, std::size_t const shp_record)
Creates a shape object polygon out of a 2D mesh element.
void readPolygons(const SHPHandle &hSHP, int numberOfElements, const std::string &listName, std::string const &gmsh_path)
Reads lines into a vector of Polyline and Surface objects.
Container class for geometric objects.
Definition GEOObjects.h:57