OGS
SHPInterface.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <string>
7#include <vector>
8
9//ShapeLib includes
10#include <shapefil.h>
11
12
13namespace GeoLib {
14 class GEOObjects;
15 class Polyline;
16}
17
18namespace MeshLib {
19 class Mesh;
20 class Element;
21}
22
23
24namespace FileIO
25{
26
30class SHPInterface final
31{
32public:
34 enum class OGSType
35 {
37 POINT = 1,
41 };
42
44 explicit SHPInterface(GeoLib::GEOObjects& geoObjects)
45 : _geoObjects(geoObjects)
46 {
47 }
48
50 static bool readSHPInfo(const std::string& filename, int& shapeType,
51 int& numberOfEntities);
52
54 void readSHPFile(const std::string& filename, OGSType choice,
55 const std::string& listName, std::string const& gmsh_path);
56
59 static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh);
60
61private:
63 void readPoints (const SHPHandle &hSHP, int numberOfElements, std::string listName);
64
66 void readStations (const SHPHandle &hSHP, int numberOfElements, std::string listName);
67
69 void readPolylines (const SHPHandle &hSHP, int numberOfElements, std::string listName);
70
72 void readPolygons(const SHPHandle& hSHP, int numberOfElements,
73 const std::string& listName,
74 std::string const& gmsh_path);
75
77 static SHPObject* createShapeObject(MeshLib::Element const& e,
78 std::size_t const shp_record);
79
81};
82
83} // namespace FileIO
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:46
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition Polyline.h:29