forked from IfcOpenShell/IfcOpenShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHdfSerializer.h
More file actions
116 lines (95 loc) · 4.18 KB
/
HdfSerializer.h
File metadata and controls
116 lines (95 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#ifndef HDFSERIALIZER_H
#define HDFSERIALIZER_H
#ifdef WITH_HDF5
#include <set>
#include <string>
#include <fstream>
#include "H5Cpp.h"
#include "../serializers/serializers_api.h"
#include "../ifcgeom_schema_agnostic/GeometrySerializer.h"
#define USE_BINARY
class SERIALIZERS_API HdfSerializer : public GeometrySerializer {
private:
const std::string hdf_filename;
unsigned int vcount_total;
H5::H5File file;
SerializerSettings settings_;
static const H5std_string DATASET_NAME_POSITIONS;
static const H5std_string DATASET_NAME_UVCOORDS;
static const H5std_string DATASET_NAME_NORMALS;
static const H5std_string DATASET_NAME_INDICES;
static const H5std_string DATASET_NAME_EDGES;
static const H5std_string DATASET_NAME_MATERIAL_IDS;
static const H5std_string DATASET_NAME_ITEM_IDS;
static const H5std_string DATASET_NAME_MATERIALS;
static const H5std_string DATASET_NAME_OCCT;
static const H5std_string DATASET_NAME_PLACEMENT;
static const H5std_string GROUP_NAME_MESH;
struct surface_style_serialization {
const char* name;
const char* original_name;
// 0 if unset
unsigned int id;
// nan if unset
double diffuse[3];
double specular[3];
double transparency;
double specularity;
};
struct brep_element {
int id;
double matrix[4][4];
#ifdef USE_BINARY
hvl_t shape_serialization;
#else
const char* shape_serialization;
#endif
surface_style_serialization surface_style;
};
H5::CompType compound;
H5::CompType style_compound;
H5::StrType str_type;
H5::ArrayType double4x4, double3;
H5::DataType shape_type;
private:
std::map<std::string, boost::shared_ptr<IfcGeom::Representation::BRep>> brep_cache_;
std::map<std::string, boost::shared_ptr<IfcGeom::Representation::Triangulation>> triangulation_cache_;
std::map<std::string, std::string> group_cache_;
H5::Group createRepresentationGroup(const H5::Group& element_group, const std::string& gid);
void read_surface_style(surface_style_serialization& sss, std::shared_ptr<IfcGeom::SurfaceStyle>& style_ptr);
void write_style(surface_style_serialization& data, const IfcGeom::SurfaceStyle& s);
public:
HdfSerializer(const std::string& hdf_filename, const SerializerSettings& settings, bool read_only=false);
virtual ~HdfSerializer() {}
bool ready();
void writeHeader();
H5::Group write(const IfcGeom::Element* o);
void write(const IfcGeom::BRepElement* o);
void write(const IfcGeom::TriangulationElement* o);
void remove(const std::string& guid);
IfcGeom::Element* read(IfcParse::IfcFile& f, const std::string& guid, const std::string&, read_type rt = READ_BREP);
void finalize() {}
bool isTesselated() const { return false; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
void setFile(IfcParse::IfcFile*) {}
};
#endif
#endif