OGS
GocadSGridReader.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <spdlog/spdlog.h>
13
14#include <boost/dynamic_bitset.hpp>
15#include <cstddef>
16#include <limits>
17#include <numeric>
18#include <string>
19#include <vector>
20
21#include "CoordinateSystem.h"
22#include "GocadNode.h"
23#include "IndexCalculator.h"
24#include "Layer.h"
26#include "Property.h"
27#include "Region.h"
28
29namespace FileIO
30{
31namespace Gocad
32{
34{
35public:
40 explicit GocadSGridReader(std::string const& fname);
42
43 GocadSGridReader() = delete;
45 GocadSGridReader(GocadSGridReader const& src) = delete;
48
49 std::unique_ptr<MeshLib::Mesh> getMesh() const;
50 std::unique_ptr<MeshLib::Mesh> getFaceSetMesh(
51 std::size_t const face_set_number) const;
52
53 std::vector<std::string> getPropertyNames() const;
54
55private:
56 using Bitset = boost::dynamic_bitset<>;
57
58 void parseDims(std::string const& line);
59 void parseFileName(std::string const& line,
60 std::string& result_string) const;
61 void parseHeader(std::istream& in);
62 void parseFaceSet(std::string& line, std::istream& in);
63
64 void readNodesBinary();
65 std::vector<Bitset> readRegionFlagsBinary() const;
67 void mapRegionFlagsToCellProperties(std::vector<Bitset> const& rf);
68
69 std::vector<MeshLib::Element*> createElements(
70 std::vector<MeshLib::Node*> const& nodes) const;
71
72 // split handling
75 std::vector<MeshLib::Node*>& nodes,
76 std::vector<MeshLib::Element*> const& elements) const;
77 static void modifyElement(MeshLib::Element* hex,
78 MeshLib::Node const* node2sub,
79 MeshLib::Node* substitute_node);
80
81 void addFaceSetQuad(
82 GocadNode* face_set_node, std::size_t face_set_number,
83 std::vector<MeshLib::Node*>& face_set_nodes,
84 std::vector<MeshLib::Element*>& face_set_elements) const;
85
86 Gocad::Property const* getProperty(std::string const& name) const;
88
89 std::string const& _fname;
90 std::string const _path;
91 // data read from sg file
94 std::string _pnts_fname;
95 std::string _flags_fname;
97
98 std::vector<Gocad::Region> regions;
99 std::vector<Gocad::Layer> layers;
100 std::size_t _n_face_sets;
101
104
105 // data read from binary points file
106 std::vector<GocadNode*> _nodes;
107 std::vector<GocadSplitNode*> _split_nodes;
108 // properties
109 std::vector<Gocad::Property> _property_meta_data_vecs;
110}; // end class GocadSGridReader
111
112} // end namespace Gocad
113} // end namespace FileIO
Definition of the Element class.
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
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
static void modifyElement(MeshLib::Element *hex, MeshLib::Node const *node2sub, MeshLib::Node *substitute_node)
void parseDims(std::string const &line)
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
void parseHeader(std::istream &in)
std::vector< Gocad::Layer > layers