cgv
|
the component format inherits the information of a packing_info and adds information on the component type, which components are present in the data and in which order they appear More...
#include <component_format.h>
Public Member Functions | |
component_format (const std::string &description) | |
construct from description string, see set_component_format for docu | |
bool | set_component_format (const std::string &description) |
set component format from description string, which has the following syntax. | |
void | set_components (const std::string &_components) |
comma separated list of component descriptors, for example "R,G,B" | |
component_format (cgv::type::info::TypeId _component_type=cgv::type::info::TypeId::TI_UNDEF, const std::string &_component_name_list="", unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct component format from component type, comma or colon separated list of component names, component alignment and bit depths for packed formats | |
component_format (cgv::type::info::TypeId _component_type, ComponentFormat cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct component format from component type, standard component format, component alignment and bit depths for packed formats | |
void | set_integer_interpretation (ComponentIntegerInterpretation cii) |
set the integer interpretation | |
ComponentIntegerInterpretation | get_integer_interpretation () const |
return current integer interpretation | |
template<typename T > | |
T | get (int ci, const void *ptr) const |
constant access to the i-th component stored at the given location | |
template<typename T > | |
bool | set (int ci, void *ptr, const T &v) const |
write access to the i-th component, return whether write was successful | |
bool | empty () const |
return whether the component format is defined | |
void | clear () |
clear the component format | |
const packing_info & | get_packing_info () const |
return the packing info by simple conversion of the this pointer | |
void | set_packing_info (const packing_info &pi) |
set packing info by simply assigning to a converted this pointer | |
unsigned int | get_nr_components () const |
return the number of components | |
unsigned int | get_component_index (const std::string &name) const |
return the index of a component given by name or -1 if not found | |
std::string | get_component_name (unsigned int i) const |
return the name of the component with index i | |
ComponentFormat | get_standard_component_format () const |
return whether the component format is one of the standard formats | |
void | set_component_names (const std::string &_component_name_list) |
set component names from a comma or colon separated list of names | |
void | set_component_format (ComponentFormat _cf) |
set the component names from a standard component format | |
cgv::type::info::TypeId | get_component_type () const |
return the component type | |
void | set_component_type (cgv::type::info::TypeId _type_id) |
set the component type | |
unsigned int | get_entry_size () const |
return the size of one entry of components in bytes | |
bool | operator== (const component_format &cf) const |
comparison between component formats | |
bool | operator!= (const component_format &cf) const |
comparison between component formats | |
![]() | |
packing_info (unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct packing information from alignment and bit depths. | |
void | clear () |
clear packing info information | |
unsigned | get_bit_depth (unsigned ci) const |
return the bit depth of the ci-th component | |
void | set_bit_depth (unsigned ci, unsigned depth) |
set the bit depth of the ci-th component | |
bool | is_packing () const |
return whether packing is enabled | |
void | set_packing (bool enable=true) |
set the packing flag | |
unsigned int | get_component_alignment () const |
return the component alignment in bits in the packed case and in bytes in the unpacked case | |
void | set_component_alignment (unsigned a) |
set the component alignment in bits in the packed case and in bytes in the unpacked case | |
int | get_signed (unsigned ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
unsigned int | get_unsigned (unsigned ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | set_signed (unsigned ci, void *ptr, int v) const |
set the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
bool | set_unsigned (unsigned ci, void *ptr, unsigned v) const |
set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | operator== (const packing_info &pi) const |
equal comparison | |
bool | operator!= (const packing_info &pi) const |
unequal comparison | |
Static Public Member Functions | |
static const std::string & | get_last_error () |
returns an error string after parsing of description string has failed | |
![]() | |
static size_t | align (size_t v, unsigned a) |
return the next integer larger or equal to v which is dividable by a | |
Protected Member Functions | |
void | extract_components () |
extract components from component string | |
![]() | |
bool | prepare_bit_operation (unsigned ci, void *ptr, unsigned &off, unsigned &bd, unsigned *&iptr) const |
bool | prepare_bit_operation (unsigned ci, const void *ptr, unsigned &off, unsigned &bd, const unsigned *&iptr) const |
unsigned int | get_bit_offset (unsigned ci) const |
Protected Attributes | |
cgv::type::info::TypeId | component_type |
store the type id of the component type | |
ComponentIntegerInterpretation | component_interpretation |
interpretation of integer typed components | |
std::string | component_string |
store all component names in one string separated with 0-chars | |
std::vector< unsigned short > | component_positions |
store the position of each component in the component string | |
![]() | |
bool | is_packed: 1 |
unsigned | bd0: 6 |
unsigned | bd1: 6 |
unsigned | bd2: 6 |
unsigned | bd3: 6 |
unsigned | ca: 6 |
Static Protected Attributes | |
static std::string | last_error |
store the last error that appeared during parsing of a description | |
Friends | |
FRIEND_MEMBER_API std::ostream & | operator<< (std::ostream &os, const component_format &cf) |
define stream out operator | |
the component format inherits the information of a packing_info and adds information on the component type, which components are present in the data and in which order they appear
Definition at line 55 of file component_format.h.
|
explicit |
construct from description string, see set_component_format for docu
construct from description string
Definition at line 85 of file component_format.cxx.
References extract_components(), and set_component_format().
cgv::data::component_format::component_format | ( | cgv::type::info::TypeId | _component_type = cgv::type::info::TypeId::TI_UNDEF , |
const std::string & | _component_name_list = "" , |
||
unsigned | align = 1 , |
||
unsigned | d0 = 0 , |
||
unsigned | d1 = 0 , |
||
unsigned | d2 = 0 , |
||
unsigned | d3 = 0 |
||
) |
construct component format from component type, comma or colon separated list of component names, component alignment and bit depths for packed formats
construct packed component format from component type, component sequence, and common component bit depth
Definition at line 66 of file component_format.cxx.
References component_interpretation, and extract_components().
cgv::data::component_format::component_format | ( | cgv::type::info::TypeId | _component_type, |
ComponentFormat | cf, | ||
unsigned | align = 1 , |
||
unsigned | d0 = 0 , |
||
unsigned | d1 = 0 , |
||
unsigned | d2 = 0 , |
||
unsigned | d3 = 0 |
||
) |
construct component format from component type, standard component format, component alignment and bit depths for packed formats
Definition at line 75 of file component_format.cxx.
References component_interpretation, and extract_components().
void cgv::data::component_format::clear | ( | ) |
clear the component format
Definition at line 307 of file component_format.cxx.
References cgv::data::packing_info::clear(), component_positions, component_string, and component_type.
Referenced by cgv::data::data_format::set_data_format().
bool cgv::data::component_format::empty | ( | ) | const |
return whether the component format is defined
Definition at line 316 of file component_format.cxx.
References component_type.
Referenced by cgv::render::texture::create_from_image(), cgv::media::image::image_reader::read_image(), and cgv::media::image::image_reader::read_image().
|
protected |
extract components from component string
extract component_positions from component string
Definition at line 42 of file component_format.cxx.
References component_positions, and component_string.
Referenced by component_format(), component_format(), component_format(), set_component_format(), set_component_format(), set_component_names(), and set_components().
|
inline |
constant access to the i-th component stored at the given location
Definition at line 134 of file component_format.h.
References cgv::type::info::type_access< T >::get(), and cgv::type::info::TI_INT64.
unsigned int cgv::data::component_format::get_component_index | ( | const std::string & | name | ) | const |
return the index of a component given by name or -1 if not found
Definition at line 328 of file component_format.cxx.
References get_component_name(), and get_nr_components().
Referenced by cgv::render::gl::read_image_to_texture(), and cgv::render::gl::read_image_to_textures().
std::string cgv::data::component_format::get_component_name | ( | unsigned int | i | ) | const |
return the name of the component with index i
Definition at line 339 of file component_format.cxx.
References component_positions, component_string, and get_nr_components().
Referenced by cgv::render::gl::find_best_texture_format(), get_component_index(), get_standard_component_format(), operator==(), cgv::render::gl::read_image_to_texture(), cgv::render::gl::read_image_to_textures(), and cgv::media::image::bmp_writer::write_image().
TypeId cgv::data::component_format::get_component_type | ( | ) | const |
return the component type
Definition at line 381 of file component_format.cxx.
References component_type.
Referenced by cgv::media::volume::volume::add_new_component(), cgv::data::data_view::combine_components(), cgv::data::fmt1_compares_better(), cgv::media::volume::volume::get_component_type(), get_entry_size(), cgv::media::image::bmp_writer::is_format_supported(), operator==(), cgv::render::gl::gl_context::read_frame_buffer(), cgv::media::volume::volume::replace_component(), and cgv::media::volume::volume::set_component_format().
unsigned cgv::data::component_format::get_entry_size | ( | ) | const |
return the size of one entry of components in bytes
Definition at line 391 of file component_format.cxx.
References cgv::data::packing_info::align(), cgv::data::packing_info::get_bit_depth(), cgv::data::packing_info::get_component_alignment(), get_component_type(), get_nr_components(), cgv::type::info::get_type_size(), and cgv::data::packing_info::is_packing().
Referenced by cgv::media::image::image::copy(), cgv::render::texture::create_from_image(), cgv::data::data_view_base::data_view_base(), cgv::media::image::image::downscale(), cgv::data::data_format::get_nr_bytes(), cgv::media::volume::volume::get_voxel_size(), cgv::media::image::image_reader::read_line(), and cgv::media::image::image::upscale().
ComponentIntegerInterpretation cgv::data::component_format::get_integer_interpretation | ( | ) | const |
return current integer interpretation
Definition at line 293 of file component_format.cxx.
References component_interpretation.
Referenced by cgv::data::fmt1_compares_better().
|
static |
returns an error string after parsing of description string has failed
Definition at line 301 of file component_format.cxx.
References last_error.
Referenced by cgv::render::textured_material::ensure_textures().
unsigned int cgv::data::component_format::get_nr_components | ( | ) | const |
return the number of components
return the number of component_positions
Definition at line 322 of file component_format.cxx.
References component_positions.
Referenced by cgv::media::volume::volume::add_new_component(), cgv::media::image::image::combine(), cgv::data::data_view::combine_components(), cgv::render::texture::create(), cgv::media::image::image::downscale(), cgv::render::gl::find_best_texture_format(), cgv::data::fmt1_compares_better(), get_component_index(), get_component_name(), get_entry_size(), cgv::media::volume::volume::get_nr_components(), get_standard_component_format(), cgv::media::image::bmp_writer::is_format_supported(), operator==(), cgv::render::gl::read_image_to_texture(), cgv::render::gl::read_image_to_textures(), cgv::media::image::bmp_reader::read_line(), cgv::media::volume::volume::replace_component(), cgv::media::image::image::upscale(), and cgv::media::image::bmp_writer::write_image().
const packing_info & cgv::data::component_format::get_packing_info | ( | ) | const |
return the packing info by simple conversion of the this pointer
Definition at line 401 of file component_format.cxx.
Referenced by operator==().
ComponentFormat cgv::data::component_format::get_standard_component_format | ( | ) | const |
return whether the component format is one of the standard formats
Definition at line 351 of file component_format.cxx.
References cgv::data::CF_LAST, get_component_name(), and get_nr_components().
Referenced by cgv::render::frame_buffer::attach(), cgv::render::frame_buffer::attach(), cgv::data::fmt1_compares_better(), cgv::media::volume::volume::get_component_format(), cgv::render::render_buffer::is_color_buffer(), cgv::render::render_buffer::is_depth_buffer(), cgv::media::image::bmp_writer::is_format_supported(), cgv::render::gl::gl_context::read_frame_buffer(), cgv::media::image::bmp_writer::write_image(), and cgv::render::texture::write_to_file().
bool cgv::data::component_format::operator!= | ( | const component_format & | cf | ) | const |
comparison between component formats
Definition at line 423 of file component_format.cxx.
bool cgv::data::component_format::operator== | ( | const component_format & | cf | ) | const |
comparison between component formats
Definition at line 409 of file component_format.cxx.
References get_component_name(), get_component_type(), get_nr_components(), and get_packing_info().
|
inline |
write access to the i-th component, return whether write was successful
Definition at line 150 of file component_format.h.
References cgv::type::info::type_access< T >::set(), and cgv::type::info::TI_INT64.
Referenced by cgv::render::texture::write_to_file().
void cgv::data::component_format::set_component_format | ( | ComponentFormat | _cf | ) |
set the component names from a standard component format
set the component names from a given component format
Definition at line 374 of file component_format.cxx.
References component_string, and extract_components().
bool cgv::data::component_format::set_component_format | ( | const std::string & | description | ) |
set component format from description string, which has the following syntax.
set the component format from a description string
If a parse error arises, return false and set the static last_error member, which can be queried with get_last_error():
component_format <- [type] [attributes] '[' component [',' component]* ']' component <- component_name [attributes] attributes <- [':' bit_depth]['|' alignment] type <- "undef" | "bool" | "int8" | "int16" | "int32" | "int64" | "uint8" | "uint16" | "uint32" | "uint64" | "sint8" | "sint16" | "sint32" | "sint64" | // same as int* types but in snorm interpretation "_int8" | "_int16" | "_int32" | "_int64" | "_uint8" | "_uint16" | "_uint32" | "_uint64" | // same as [u]int* but in integer interpretation "flt16" | "flt32" | "flt64" | "string" component_name : string ... name of component, i.e. "R", "Cb", "px", ... bit_depth : unsigned int ... number of bits used to represent a component alignment : unsigned int ... number of bits to which a component is aligned
Some examples of valid component format description strings:
"uint8:3|4[R,G,B,A]"
... four components represented as unsigned integers with no more than 8 bits. Actually, each component is stored with 3 bits and aligned to a bit index which is a multiple of 4"uint8[R:5,G:6,B:5]"
... three components packed into 16 bits with 5 bits for R, 6 for G and 5 for B."sint8[R,G]"
... two component format of type int8 in snorm interpretation,"_uint16[R]"
... one component format of type uint16 in integer interpretation,"flt32[px,py]"
... two components of 32 bit floats"[D]"
... one depth component without specified type, which defaults to "undef" and implies that the default depth format should be used. Definition at line 166 of file component_format.cxx.
References cgv::data::packing_info::align(), component_interpretation, component_string, component_type, extract_components(), cgv::type::info::get_type_id(), cgv::utils::is_integer(), last_error, cgv::data::packing_info::set_bit_depth(), cgv::data::packing_info::set_component_alignment(), cgv::data::packing_info::set_packing(), cgv::utils::tokenizer::set_sep(), and cgv::utils::to_string().
Referenced by component_format(), cgv::render::texture::set_component_format(), and cgv::data::data_format::set_data_format().
void cgv::data::component_format::set_component_names | ( | const std::string & | _component_name_list | ) |
set component names from a comma or colon separated list of names
Definition at line 367 of file component_format.cxx.
References component_string, and extract_components().
Referenced by cgv::render::gl::find_best_texture_format().
void cgv::data::component_format::set_component_type | ( | cgv::type::info::TypeId | _type_id | ) |
set the component type
Definition at line 387 of file component_format.cxx.
References component_type.
Referenced by cgv::media::volume::volume::set_component_type().
void cgv::data::component_format::set_components | ( | const std::string & | _components | ) |
comma separated list of component descriptors, for example "R,G,B"
Definition at line 59 of file component_format.cxx.
References component_string, and extract_components().
void cgv::data::component_format::set_integer_interpretation | ( | ComponentIntegerInterpretation | cii | ) |
set the integer interpretation
Definition at line 287 of file component_format.cxx.
References component_interpretation.
void cgv::data::component_format::set_packing_info | ( | const packing_info & | pi | ) |
set packing info by simply assigning to a converted this pointer
Definition at line 405 of file component_format.cxx.
|
friend |
define stream out operator
Definition at line 427 of file component_format.cxx.
|
protected |
interpretation of integer typed components
Definition at line 61 of file component_format.h.
Referenced by component_format(), component_format(), get_integer_interpretation(), set_component_format(), and set_integer_interpretation().
|
protected |
store the position of each component in the component string
Definition at line 65 of file component_format.h.
Referenced by clear(), extract_components(), get_component_name(), and get_nr_components().
|
protected |
store all component names in one string separated with 0-chars
Definition at line 63 of file component_format.h.
Referenced by clear(), extract_components(), get_component_name(), set_component_format(), set_component_format(), set_component_names(), and set_components().
|
protected |
store the type id of the component type
Definition at line 59 of file component_format.h.
Referenced by clear(), empty(), get_component_type(), set_component_format(), and set_component_type().
|
staticprotected |
store the last error that appeared during parsing of a description
Definition at line 69 of file component_format.h.
Referenced by get_last_error(), set_component_format(), and cgv::data::data_format::set_data_format().