cgv
data_format.h
1 #pragma once
2 
3 #include "component_format.h"
4 
5 #include "lib_begin.h"
6 
7 using namespace cgv::type::info;
8 
9 namespace cgv {
10  namespace data {
11 
17 class CGV_API data_format : public component_format
18 {
19 protected:
20  struct dimension_info
21  {
22  unsigned int resolution;
23  unsigned int alignment;
24  unsigned int layout_dimension;
25  dimension_info(unsigned int n = 0, unsigned int a = 1, unsigned int ld = 0)
26  : resolution(n), alignment(a), layout_dimension(ld) {}
27  };
29  std::vector<dimension_info> dimensions;
30 public:
32  data_format();
34  explicit data_format(const std::string& description);
71  bool set_data_format(const std::string& description);
73  data_format(unsigned int _width,
74  TypeId _component_type,
75  const std::string& _component_name_list,
76  unsigned int align = 1,
77  unsigned int d0 = 0, unsigned int d1 = 0,
78  unsigned int d2 = 0, unsigned int d3 = 0);
80  data_format(unsigned int _width,
81  TypeId _component_type,
82  ComponentFormat _cf,
83  unsigned int align = 1,
84  unsigned int d0 = 0, unsigned int d1 = 0,
85  unsigned int d2 = 0, unsigned int d3 = 0);
87  data_format(unsigned int _width, unsigned int _height,
88  TypeId _component_type,
89  const std::string& _component_name_list,
90  unsigned int align = 1,
91  unsigned int d0 = 0, unsigned int d1 = 0,
92  unsigned int d2 = 0, unsigned int d3 = 0);
94  data_format(unsigned int _width, unsigned int _height,
95  TypeId _component_type,
96  ComponentFormat _cf,
97  unsigned int align = 1,
98  unsigned int d0 = 0, unsigned int d1 = 0,
99  unsigned int d2 = 0, unsigned int d3 = 0);
101  data_format(unsigned int _width, unsigned int _height, unsigned int _depth,
102  TypeId _component_type,
103  const std::string& _component_name_list,
104  unsigned int align = 1,
105  unsigned int d0 = 0, unsigned int d1 = 0,
106  unsigned int d2 = 0, unsigned int d3 = 0);
108  data_format(unsigned int _width, unsigned int _height, unsigned int _depth,
109  TypeId _component_type,
110  ComponentFormat _cf,
111  unsigned int align = 1,
112  unsigned int d0 = 0, unsigned int d1 = 0,
113  unsigned int d2 = 0, unsigned int d3 = 0);
115  data_format(unsigned int _width, unsigned int _height,
116  unsigned int _depth, unsigned int _count,
117  TypeId _component_type,
118  const std::string& _component_name_list,
119  unsigned int align = 1,
120  unsigned int d0 = 0, unsigned int d1 = 0,
121  unsigned int d2 = 0, unsigned int d3 = 0);
123  data_format(unsigned int _width, unsigned int _height,
124  unsigned int _depth, unsigned int _count,
125  TypeId _component_type,
126  ComponentFormat _cf,
127  unsigned int align = 1,
128  unsigned int d0 = 0, unsigned int d1 = 0,
129  unsigned int d2 = 0, unsigned int d3 = 0);
131  friend FRIEND_MEMBER_API std::ostream& operator << (std::ostream& os, const data_format& df);
133  void set_dimensions(unsigned _d0, unsigned _d1 = -1, unsigned _d2 = -1, unsigned _d3 = -1);
135  unsigned int get_nr_dimensions() const;
137  void set_nr_dimensions(unsigned int _d);
139  unsigned int get_resolution(unsigned int i) const;
141  unsigned int get_width() const;
143  unsigned int get_height() const;
145  unsigned int get_depth() const;
147  unsigned int get_nr_time_steps() const;
149  size_t get_nr_entries() const;
151  size_t get_nr_bytes() const;
153  void set_resolution(unsigned int i, unsigned int resolution);
155  void set_width(unsigned int _width);
157  void set_height(unsigned int _height);
159  void set_depth(unsigned int _depth);
161  void set_nr_time_steps(unsigned int _nr_time_steps);
163  unsigned int get_entry_alignment() const;
167  unsigned int get_alignment(unsigned int i) const;
169  void set_entry_alignment(unsigned int _a);
172  void set_alignment(unsigned int i, unsigned int _a);
174  unsigned int get_layout_dimension(unsigned int dim) const;
176  void get_layout_dimension(unsigned int dim, unsigned int layout_dim);
178  const component_format& get_component_format() const;
180  void set_component_format(const component_format& cf);
182  bool operator == (const data_format& df) const;
184  bool operator != (const data_format& df) const;
185 };
186 
189 extern CGV_API std::ostream& operator << (std::ostream& os, const data_format& df);
190 
191  }
192 }
193 
194 #include <cgv/config/lib_end.h>
cgv::data::component_format
Definition: component_format.h:58
cgv::type::info::TypeId
TypeId
ids for the different types and type constructs
Definition: type_id.h:12
cgv::data::data_format
Definition: data_format.h:18
cgv::type::info
namespace for templates that provide type information
Definition: type_access.h:9
cgv::data::ComponentFormat
ComponentFormat
Definition: component_format.h:18
cgv::data::data_format::dimensions
std::vector< dimension_info > dimensions
store for each dimension resolution and alignment in a dimension_info struct
Definition: data_format.h:29
cgv
the cgv namespace
Definition: vr_calib.cxx:9