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:
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 };
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);
143 const component_format& get_component_format() const;
145 void set_component_format(const component_format& cf);
147 bool operator == (const data_format& df) const;
149 bool operator != (const data_format& df) const;
150};
153extern CGV_API std::ostream& operator << (std::ostream& os, const data_format& df);
154
155 }
156}
157
158#include <cgv/config/lib_end.h>
the component format inherits the information of a packing_info and adds information on the component...
A data_format describes a multidimensional data block of data entries.
Definition data_format.h:17
std::vector< dimension_info > dimensions
store for each dimension resolution and alignment in a dimension_info struct
Definition data_format.h:28
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
the cgv namespace
Definition print.h:11