OGS
GocadSGridReader.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 <spdlog/spdlog.h>
7
8#include <boost/dynamic_bitset.hpp>
9#include <cstddef>
10#include <limits>
11#include <numeric>
12#include <string>
13#include <vector>
14
15#include "CoordinateSystem.h"
16#include "GocadNode.h"
17#include "IndexCalculator.h"
18#include "Layer.h"
20#include "Property.h"
21#include "Region.h"
22
23namespace FileIO
24{
25namespace Gocad
26{
28{
29public:
34 explicit GocadSGridReader(std::string const& fname);
36
37 GocadSGridReader() = delete;
39 GocadSGridReader(GocadSGridReader const& src) = delete;
42
43 std::unique_ptr<MeshLib::Mesh> getMesh() const;
44 std::unique_ptr<MeshLib::Mesh> getFaceSetMesh(
45 std::size_t const face_set_number) const;
46
47 std::vector<std::string> getPropertyNames() const;
48
49private:
50 using Bitset = boost::dynamic_bitset<>;
51
52 void parseDims(std::string const& line);
53 void parseFileName(std::string const& line,
54 std::string& result_string) const;
55 void parseHeader(std::istream& in);
56 void parseFaceSet(std::string& line, std::istream& in);
57
58 void readNodesBinary();
59 std::vector<Bitset> readRegionFlagsBinary() const;
61 void mapRegionFlagsToCellProperties(std::vector<Bitset> const& rf);
62
63 std::vector<MeshLib::Element*> createElements(
64 std::vector<MeshLib::Node*> const& nodes) const;
65
66 // split handling
69 std::vector<MeshLib::Node*>& nodes,
70 std::vector<MeshLib::Element*> const& elements) const;
71 static void modifyElement(MeshLib::Element const* hex,
72 MeshLib::Node const* node2sub,
73 MeshLib::Node* substitute_node);
74
75 void addFaceSetQuad(
76 GocadNode* face_set_node, std::size_t face_set_number,
77 std::vector<MeshLib::Node*>& face_set_nodes,
78 std::vector<MeshLib::Element*>& face_set_elements) const;
79
80 Gocad::Property const* getProperty(std::string const& name) const;
82
83 std::string const& _fname;
84 std::string const _path;
85 // data read from sg file
88 std::string _pnts_fname;
89 std::string _flags_fname;
91
92 std::vector<Gocad::Region> regions;
93 std::vector<Gocad::Layer> layers;
94 std::size_t _n_face_sets;
95
98
99 // data read from binary points file
100 std::vector<GocadNode*> _nodes;
101 std::vector<GocadSplitNode*> _split_nodes;
102 // properties
103 std::vector<Gocad::Property> _property_meta_data_vecs;
104}; // end class GocadSGridReader
105
106} // end namespace Gocad
107} // end namespace FileIO
Gocad::Property const * getProperty(std::string const &name) const
std::vector< Gocad::Property > _property_meta_data_vecs
GocadSGridReader & operator=(GocadSGridReader const &rhs)=delete
std::vector< MeshLib::Element * > createElements(std::vector< MeshLib::Node * > const &nodes) const
std::unique_ptr< MeshLib::Mesh > getFaceSetMesh(std::size_t const face_set_number) const
GocadSGridReader & operator=(GocadSGridReader &&rhs)=delete
std::vector< GocadNode * > _nodes
std::vector< Gocad::Region > regions
GocadSGridReader(GocadSGridReader &&src)=delete
std::unique_ptr< MeshLib::Mesh > getMesh() const
GocadSGridReader(GocadSGridReader const &src)=delete
std::vector< Bitset > readRegionFlagsBinary() const
void addGocadPropertiesToMesh(MeshLib::Mesh &mesh) const
void applySplitInformation(std::vector< MeshLib::Node * > &nodes, std::vector< MeshLib::Element * > const &elements) const
void mapRegionFlagsToCellProperties(std::vector< Bitset > const &rf)
Gocad::CoordinateSystem _coordinate_system
static void modifyElement(MeshLib::Element const *hex, MeshLib::Node const *node2sub, MeshLib::Node *substitute_node)
void parseFaceSet(std::string &line, std::istream &in)
void parseFileName(std::string const &line, std::string &result_string) const
Gocad::IndexCalculator _index_calculator
boost::dynamic_bitset<> Bitset
std::vector< GocadSplitNode * > _split_nodes
std::vector< std::string > getPropertyNames() const
void addFaceSetQuad(GocadNode *face_set_node, std::size_t face_set_number, std::vector< MeshLib::Node * > &face_set_nodes, std::vector< MeshLib::Element * > &face_set_elements) const
std::vector< Gocad::Layer > layers