3 #include <cgv/type/info/type_id.h>
4 #include <cgv/type/info/type_access.h>
5 #include "packing_info.h"
69 void extract_components();
115 bool set_component_format(
const std::string& description);
117 void set_components(
const std::string& _components);
119 static const std::string& get_last_error();
124 const std::string& _component_name_list =
"",
125 unsigned int align = 1,
126 unsigned int d0 = 0,
unsigned int d1 = 0,
127 unsigned int d2 = 0,
unsigned int d3 = 0);
131 unsigned int align = 1,
132 unsigned int d0 = 0,
unsigned int d1 = 0,
133 unsigned int d2 = 0,
unsigned int d3 = 0);
139 friend FRIEND_MEMBER_API std::ostream& operator << (std::ostream& os,
const component_format& cf);
141 template <
typename T>
142 T
get(
int ci,
const void* ptr)
const {
144 if (get_component_type() <=
TI_INT64) {
145 int i = packing_info::get_signed(ci, ptr);
149 unsigned int i = packing_info::get_unsigned(ci, ptr);
154 return type_access<T>::get(
static_cast<const unsigned char*
>(ptr)+ci*align(
get_type_size(get_component_type()),get_component_alignment()), get_component_type());
157 template <
typename T>
158 bool set(
int ci,
void* ptr,
const T& v)
const {
160 if (get_component_type() <=
TI_INT64) {
162 return type_access<T>::set(&i, get_component_type(), v) && packing_info::set_signed(ci, ptr, i);
166 return type_access<T>::set(&i, get_component_type(), v) && packing_info::set_unsigned(ci, ptr, i);
170 return type_access<T>::set(
static_cast<unsigned char*
>(ptr)+ci*align(
get_type_size(get_component_type()),get_component_alignment()), get_component_type(), v);
181 unsigned int get_nr_components()
const;
183 unsigned int get_component_index(
const std::string& name)
const;
185 std::string get_component_name(
unsigned int i)
const;
189 void set_component_names(
const std::string& _component_name_list);
193 TypeId get_component_type()
const;
195 void set_component_type(
TypeId _type_id);
197 unsigned int get_entry_size()
const;
206 extern CGV_API std::ostream& operator << (std::ostream& os,
const component_format& cf);
209 extern CGV_API
bool fmt1_compares_better(
const component_format& fmt,
210 const component_format& fmt1,
211 const component_format& fmt2);
215 extern CGV_API
unsigned int find_best_match(
216 const component_format& fmt,
217 const char** format_descriptions,
218 const component_format* fmt0 = 0,
219 bool (*fmt1_better_match)(
220 const component_format& fmt,
221 const component_format& fmt1,
222 const component_format& fmt2) = fmt1_compares_better);
227 #include <cgv/config/lib_end.h>
@ CF_P4D
point format with components px, py and pz
Definition: component_format.h:37
@ CF_P2D
stencil component
Definition: component_format.h:35
@ CF_RGB
color format with two components R and G
Definition: component_format.h:29
@ CF_BGRA
color format with components B, G and R
Definition: component_format.h:32
TypeId
ids for the different types and type constructs
Definition: type_id.h:12
@ CF_N3D
normal format with components nx and ny
Definition: component_format.h:39
@ CF_P3D
point format with components px and py
Definition: component_format.h:36
@ CF_S
depth component
Definition: component_format.h:34
@ CF_I
color format with luminance component L
Definition: component_format.h:25
@ CF_B
green channel of color format
Definition: component_format.h:22
@ CF_RG
color format with intensity and alpha components: I and A
Definition: component_format.h:28
@ CF_N2D
point format with components px, py, pz and pw
Definition: component_format.h:38
@ CF_A
blue channel of color format
Definition: component_format.h:23
@ CF_T2D
normal format with components nx, ny and nz
Definition: component_format.h:40
@ CF_T3D
texture coordinats format with components ts and tt
Definition: component_format.h:41
@ CF_L
alpha format
Definition: component_format.h:24
static bool set(void *ptr, TypeId tid, const T &v)
convert value from type T and store it
Definition: type_access.h:37
unsigned int get_type_size(TypeId tid)
function that returns the size of a type specified through TypeId
Definition: type_id.cxx:18
@ TI_INT64
signed integer stored in 32 bits
Definition: type_id.h:22
@ CF_R
undefinded format with no component
Definition: component_format.h:20
ComponentIntegerInterpretation
Definition: component_format.h:48
@ CF_G
red channel of color format
Definition: component_format.h:21
@ CF_LA
color format with intensity component I
Definition: component_format.h:26
@ CF_LAST
texture coordinats format with components ts, tt, tr and tq
Definition: component_format.h:43
namespace for templates that provide type information
Definition: type_access.h:9
@ CF_D
color format with components B, G, R and A
Definition: component_format.h:33
@ CF_T4D
texture coordinats format with components ts, tt and tr
Definition: component_format.h:42
Definition: packing_info.h:23
ComponentFormat
Definition: component_format.h:18
@ CF_IA
color format with luminance and alpha components: L and A
Definition: component_format.h:27
the cgv namespace
Definition: vr_calib.cxx:9
static T get(const void *ptr, TypeId tid)
return stored value converted into type T
Definition: type_access.h:16
@ CF_RGBA
color format with components R, G and B
Definition: component_format.h:30
@ CF_BGR
color format with components R, G, B and A
Definition: component_format.h:31