cgv
Loading...
Searching...
No Matches
data_format.h
1#pragma once
2
3#include "component_format.h"
4#include <cstring>
5
6#include "lib_begin.h"
7
8namespace cgv {
9 namespace data {
10
16class CGV_API data_format : public component_format
17{
18protected:
19 struct dimension_info
20 {
21 size_t resolution;
22 unsigned int alignment;
23 unsigned int layout_dimension;
24 dimension_info(size_t n = 0, unsigned int a = 1, unsigned int ld = 0)
25 : resolution(n), alignment(a), layout_dimension(ld) {}
26 };
27
28 std::vector<dimension_info> dimensions;
29public:
33 explicit data_format(const std::string& description);
70 bool set_data_format(const std::string& description);
72 data_format(size_t _width, cgv::type::info::TypeId _component_type, const std::string& _component_name_list,
73 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
75 data_format(size_t _width, cgv::type::info::TypeId _component_type, ComponentFormat _cf,
76 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
78 data_format(size_t _width, size_t _height, cgv::type::info::TypeId _component_type, const std::string& _component_name_list,
79 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
81 data_format(size_t _width, size_t _height, cgv::type::info::TypeId _component_type, ComponentFormat _cf,
82 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
84 data_format(size_t _width, size_t _height, size_t _depth, cgv::type::info::TypeId _component_type, const std::string& _component_name_list,
85 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
87 data_format(size_t _width, size_t _height, size_t _depth, cgv::type::info::TypeId _component_type, ComponentFormat _cf,
88 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
90 data_format(size_t _width, size_t _height, size_t _depth, size_t _count, cgv::type::info::TypeId _component_type, const std::string& _component_name_list,
91 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
93 data_format(size_t _width, size_t _height, size_t _depth, size_t _count, cgv::type::info::TypeId _component_type, ComponentFormat _cf,
94 unsigned align = 1, unsigned d0 = 0, unsigned d1 = 0, unsigned d2 = 0, unsigned d3 = 0);
96 friend FRIEND_MEMBER_API std::ostream& operator << (std::ostream& os, const data_format& df);
98 void set_dimensions(size_t _d0, size_t _d1 = -1, size_t _d2 = -1, size_t _d3 = -1);
100 unsigned get_nr_dimensions() const;
102 void set_nr_dimensions(unsigned _d);
104 size_t get_resolution(unsigned i) const;
106 size_t get_width() const;
108 size_t get_height() const;
110 size_t get_depth() const;
112 size_t get_nr_time_steps() const;
114 size_t get_nr_entries() const;
116 size_t get_nr_bytes() const;
118 void set_resolution(unsigned i, size_t resolution);
120 void set_width(size_t _width);
122 void set_height(size_t _height);
124 void set_depth(size_t _depth);
126 void set_nr_time_steps(size_t _nr_time_steps);
128 unsigned get_entry_alignment() const;
132 unsigned get_alignment(unsigned i) const;
134 void set_entry_alignment(unsigned _a);
137 void set_alignment(unsigned i, unsigned _a);
139 unsigned get_layout_dimension(unsigned dim) const;
141 void set_layout_dimension(unsigned dim, unsigned layout_dim);
147 bool operator == (const data_format& df) const;
149 bool operator != (const data_format& df) const;
150};
151
153extern CGV_API std::ostream& operator << (std::ostream& os, const data_format& df);
154
155 }
156}
157
158#include <cgv/config/lib_end.h>
component_format(const std::string &description)
construct from description string, see set_component_format for docu
A data_format describes a multidimensional data block of data entries.
Definition data_format.h:17
unsigned get_nr_dimensions() const
return the number of dimensions of the data set
void set_layout_dimension(unsigned dim, unsigned layout_dim)
set the layout dimension of a given dimension, add dimensions if necessary
size_t get_depth() const
return the resolution in the third dimension, or 1 if not defined
void set_component_format(const component_format &cf)
set component_format by simply assigning to a converted this pointer
void set_nr_time_steps(size_t _nr_time_steps)
set the resolution in the last dimension, add dimensions if necessary
void set_resolution(unsigned i, size_t resolution)
set the resolution in the i-th dimension, add dimensions if necessary
void set_height(size_t _height)
set the resolution in the second dimension, add dimensions if necessary
std::vector< dimension_info > dimensions
store for each dimension resolution and alignment in a dimension_info struct
Definition data_format.h:28
unsigned get_alignment(unsigned i) const
return the alignment of a given dimension, where the alignment of the last dimension is always 1 and ...
void set_width(size_t _width)
set the resolution in the first dimension, add dimensions if necessary
size_t get_nr_time_steps() const
return the resolution in the highest dimension, or 1 if not defined
void set_entry_alignment(unsigned _a)
set the alignment of entries
unsigned get_layout_dimension(unsigned dim) const
return the layout dimension of a given dimension
size_t get_width() const
return the resolution in the first dimension, or 1 if not defined
unsigned get_entry_alignment() const
return the alignment of entries
void set_depth(size_t _depth)
set the resolution in the third dimension, add dimensions if necessary
size_t get_height() const
return the resolution in the second dimension, or 1 if not defined
void set_nr_dimensions(unsigned _d)
set the number of dimensions of the data set
void set_alignment(unsigned i, unsigned _a)
set the alignment of a given dimension, add dimensions if necessary.
size_t get_nr_bytes() const
return the total number of bytes necessary to store the data
const component_format & get_component_format() const
return the component_format info by simple conversion of the this pointer
data_format()
construct an undefined data format
void set_dimensions(size_t _d0, size_t _d1=-1, size_t _d2=-1, size_t _d3=-1)
set the dimensions to the given values
size_t get_nr_entries() const
return the total number of data entries
bool set_data_format(const std::string &description)
Set data format from description string, which adds information to the description string of the comp...
size_t get_resolution(unsigned i) const
return the resolution in the i-th dimension, or 0 if not defined
static size_t align(size_t v, unsigned a)
return the next integer larger or equal to v which is dividable by a
namespace for data management components
ComponentFormat
define standard formats, which should be used to avoid wrong assignment of component names
std::ostream & operator<<(std::ostream &os, const component_format &cf)
stream out operator writes the component format in the syntax of description strings as defined in th...
TypeId
ids for the different types and type constructs
Definition type_id.h:12
this header is dependency free
Definition print.h:11