OGS
SHPInterface.h
Go to the documentation of this file.
1
18#pragma once
19
20#include <string>
21#include <vector>
22
23//ShapeLib includes
24#include <shapefil.h>
25
26
27namespace GeoLib {
28 class GEOObjects;
29 class Polyline;
30}
31
32namespace MeshLib {
33 class Mesh;
34 class Element;
35}
36
37
38namespace FileIO
39{
40
44class SHPInterface final
45{
46public:
48 enum class OGSType
49 {
50 UNDEFINED = 0,
51 POINT = 1,
52 STATION = 2,
53 POLYLINE = 3,
54 POLYGON = 4
55 };
56
58 explicit SHPInterface(GeoLib::GEOObjects& geoObjects)
59 : _geoObjects(geoObjects)
60 {
61 }
62
64 static bool readSHPInfo(const std::string& filename, int& shapeType,
65 int& numberOfEntities);
66
68 void readSHPFile(const std::string& filename, OGSType choice,
69 const std::string& listName, std::string const& gmsh_path);
70
73 static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh);
74
75private:
77 void readPoints (const SHPHandle &hSHP, int numberOfElements, std::string listName);
78
80 void readStations (const SHPHandle &hSHP, int numberOfElements, std::string listName);
81
83 void readPolylines (const SHPHandle &hSHP, int numberOfElements, std::string listName);
84
86 void readPolygons(const SHPHandle& hSHP, int numberOfElements,
87 const std::string& listName,
88 std::string const& gmsh_path);
89
91 static SHPObject* createShapeObject(MeshLib::Element const& e,
92 std::size_t const shp_record);
93
95};
96
97} // namespace FileIO
Manages the import of ESRI shape files into GeoLib.
Definition: SHPInterface.h:45
SHPInterface(GeoLib::GEOObjects &geoObjects)
Constructor.
Definition: SHPInterface.h:58
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.
Definition: SHPInterface.h:49
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
Definition: SHPInterface.h:94
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:61