cgv
|
the data view gives access to a data array of one, two, three or four dimensions. More...
#include <data_view.h>
Public Member Functions | |
data_view () | |
construct an empty data view without format and with empty data pointer*/ | |
~data_view () | |
destruct view and delete data pointer if it is owned by the view | |
data_view (const data_format *_format) | |
construct a data view from the given format. | |
data_view (const data_format *_format, void *_data_ptr) | |
construct a data view from the given format, viewing the complete data set. | |
data_view (const data_format *_format, unsigned char *_data_ptr, bool manage_ptr) | |
construct a data view from the given format, viewing the complete data set. | |
data_view (const data_view &other) | |
construct a data view as a copy of the given data view. | |
data_view & | operator= (const data_view &dv) |
the assignment operator takes over the data format and data pointers in case they are managed by the source data view | |
data_view | copy () |
return a copy of this data_view and tha data via the copy constructor | |
void | set_ptr (unsigned char *ptr, bool manage_ptr) |
set a different data pointer that will be deleted with the delete [] operator of type (unsigned char*) on destruction if the manage_ptr flag is true | |
void | set_ptr (void *ptr) |
set a different data pointer that is not owned by the data view and will not be deleted on destruction. | |
template<typename T > | |
bool | set (int ci, const T &v) |
write access to the i-th component, return whether write was successful | |
void | reflect_horizontally () |
reflect 2D data view at horizontal axis | |
![]() | |
data_view_impl (const data_format *_format=0, typename cgv::type::func::transfer_const< unsigned char *, void * >::type _data_ptr=0) | |
construct a data view from the given format, viewing the complete data set | |
bool | empty () const |
return whether the data pointer is a null pointer | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | get_ptr () const |
return a data pointer to type S | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | get_ptr (size_t i) const |
return a pointer to type S for i-th data entry | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | get_ptr (size_t i, size_t j) const |
return a pointer to type S for (i,j)-th data entry | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | get_ptr (size_t i, size_t j, size_t k) const |
return a pointer to type S for (i,j,k)-th data entry | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | get_ptr (size_t i, size_t j, size_t k, size_t l) const |
return a pointer to type S for (i,j,k,l)-th data entry | |
S | get (unsigned ci) const |
constant access to the ci-th component | |
S | get (unsigned ci, size_t i) const |
constant access to the ci-th component of i-th data entry | |
S | get (unsigned ci, size_t i, size_t j) const |
constant access to the ci-th component of (i,j)-th data entry | |
S | get (unsigned ci, size_t i, size_t j, size_t k) const |
constant access to the ci-th component of (i,j,k)-th data entry | |
S | get (unsigned ci, size_t i, size_t j, size_t k, size_t l) const |
constant access to the ci-th component of (i,j,k,l)-th data entry | |
data_view | operator() (size_t i) const |
access to i-th data entry | |
data_view | operator() (size_t i, size_t j) const |
access to entry at (i,j) | |
data_view | operator() (size_t i, size_t j, size_t k) const |
access to entry at (i,j,k) | |
data_view | operator() (size_t i, size_t j, size_t k, size_t l) const |
access to entry at (i,j,k,l) | |
data_view | permute (const std::string &permutation) const |
permute the order of the indices, where the permutation argument "kji" implies that after the permutation the operator (i,j,k) returns the same as the operator (k,j,i) before the call to permute. | |
data_view | transpose () const |
transpose is equivalent to permute("ji") | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | step_i (S *ptr, std::ptrdiff_t n=1) const |
return a pointer that points to the n-th next location if index i is increase by n | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | step_j (S *ptr, std::ptrdiff_t n=1) const |
return a pointer that points to the n-th next location if index j is increase by n | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | step_k (S *ptr, std::ptrdiff_t n=1) const |
return a pointer that points to the n-th next location if index k is increase by n | |
cgv::type::func::transfer_const< unsigned char *, S * >::type | step_l (S *ptr, std::ptrdiff_t n=1) const |
return a pointer that points to the n-th next location if index l is increase by n | |
![]() | |
data_view_base (const data_format *_format=0) | |
construct the base of a data view from the given format, such that the step sizes and dimension are set to view the complete data set defined in the format. | |
virtual | ~data_view_base () |
delete format if it is owned | |
void | manage_format (bool enable=true) |
whether to manage the data format pointer | |
const data_format * | get_format () const |
return the component format | |
void | set_format (const data_format *_format) |
set a new data format | |
unsigned int | get_dim () const |
return the dimension of the data view, which is less or equal to the dimension of the data format | |
size_t | get_step_size (unsigned int dim) const |
return the step size in bytes in the i-th dimension | |
Static Public Member Functions | |
static bool | compose (data_view &composed_dv, const std::vector< data_view > &dvs) |
combine multiple n-dimensional data views with the same format into a (n+1)-dimensional data view by appending them | |
static bool | combine_components (data_view &dv, const std::vector< data_view >::iterator first, const std::vector< data_view >::iterator last) |
combine n data views each with one component channel into a single data view with n component channels, the format of the input data views needs to match | |
Protected Member Functions | |
data_view (const data_format *_format, unsigned char *_data_ptr, unsigned int _dim, const size_t *_step_sizes) | |
use base class for construction and don't manage data pointer | |
![]() | |
data_view_impl (const data_format *_format, unsigned char * _data_ptr, unsigned _dim, const size_t *_step_sizes) | |
constructor used to construct sub views onto the data view | |
![]() | |
data_view_base (const data_format *_format, unsigned int _dim, const size_t *_step_sizes) | |
constructor used to construct sub views onto the data view | |
Protected Attributes | |
bool | owns_ptr |
a flag telling whether the data ptr is owned by the view | |
![]() | |
unsigned char * | data_ptr |
data pointer of type unsigned char or const unsigned char | |
![]() | |
const data_format * | format |
bool | owns_format |
whether to own the data format | |
unsigned int | dim |
size_t | step_sizes [4] |
Friends | |
class | data_view_impl< data_view, unsigned char * > |
declare base as friend | |
class | const_data_view |
the data view gives access to a data array of one, two, three or four dimensions.
Each data entry can consist of several components as defined in the referenced component format. It allows to permute the dimensions, construct views of lower dimension with the ()-operators defined in the data_view_impl and to access the data components with the get- and set-method of data_view_impl. It keeps a flag that tells whether the data pointer belongs to the data view and therefore needs to be deleted on destruction.
Definition at line 152 of file data_view.h.
cgv::data::data_view::data_view | ( | ) |
construct an empty data view without format and with empty data pointer*/
Definition at line 184 of file data_view.cxx.
Referenced by combine_components(), and compose().
cgv::data::data_view::~data_view | ( | ) |
destruct view and delete data pointer if it is owned by the view
Definition at line 187 of file data_view.cxx.
References cgv::data::data_view_impl< data_view, unsigned char * >::data_ptr, and owns_ptr.
Referenced by cgv::render::gl::gl_context::read_frame_buffer().
cgv::data::data_view::data_view | ( | const data_format * | _format | ) |
construct a data view from the given format.
Allocate a new data pointer with the new [] operator of type (unsigned char) and own the pointer. The data_view will view the complete data set as defined in the format.
Definition at line 194 of file data_view.cxx.
References cgv::data::data_view_impl< data_view, unsigned char * >::data_ptr, cgv::data::data_format::get_nr_bytes(), and owns_ptr.
cgv::data::data_view::data_view | ( | const data_format * | _format, |
void * | _data_ptr | ||
) |
construct a data view from the given format, viewing the complete data set.
The passed pointer will not be owned by the view.
Definition at line 202 of file data_view.cxx.
cgv::data::data_view::data_view | ( | const data_format * | _format, |
unsigned char * | _data_ptr, | ||
bool | manage_ptr | ||
) |
construct a data view from the given format, viewing the complete data set.
The passed pointer will be owned by the view if the manage_ptr flag is true. In this case the pointer is deleted on destruction with the delete [] operator of type (unsigned char*).
Definition at line 207 of file data_view.cxx.
|
inline |
construct a data view as a copy of the given data view.
Copy the data and own the pointer. The data_view will view the complete data set as defined in the format.
Definition at line 184 of file data_view.h.
References cgv::data::data_format::get_nr_bytes(), and cgv::data::data_view_impl< D, P >::get_ptr().
|
static |
combine n data views each with one component channel into a single data view with n component channels, the format of the input data views needs to match
Definition at line 339 of file data_view.cxx.
References cgv::data::CF_R, cgv::data::CF_RG, cgv::data::CF_RGB, cgv::data::CF_RGBA, data_view(), cgv::data::data_view_impl< D, P >::empty(), cgv::data::data_format::get_component_format(), cgv::data::component_format::get_component_type(), cgv::data::data_format::get_depth(), cgv::data::data_format::get_height(), cgv::data::component_format::get_nr_components(), cgv::data::data_format::get_nr_dimensions(), cgv::data::data_format::get_nr_time_steps(), cgv::data::data_view_impl< D, P >::get_ptr(), cgv::type::info::get_type_size(), and cgv::data::data_format::get_width().
|
static |
combine multiple n-dimensional data views with the same format into a (n+1)-dimensional data view by appending them
Definition at line 290 of file data_view.cxx.
References data_view(), cgv::data::data_view_impl< D, P >::empty(), cgv::data::data_format::get_component_format(), cgv::data::data_view_base::get_format(), cgv::data::data_format::get_nr_bytes(), cgv::data::data_format::get_nr_dimensions(), cgv::data::data_view_impl< D, P >::get_ptr(), cgv::data::data_format::set_depth(), cgv::data::data_format::set_height(), and cgv::data::data_format::set_nr_time_steps().
|
inline |
return a copy of this data_view and tha data via the copy constructor
Definition at line 193 of file data_view.h.
the assignment operator takes over the data format and data pointers in case they are managed by the source data view
Definition at line 212 of file data_view.cxx.
References cgv::data::data_view_impl< D, P >::data_ptr, cgv::data::data_view_impl< data_view, unsigned char * >::data_ptr, cgv::data::data_view_base::owns_format, and owns_ptr.
void cgv::data::data_view::reflect_horizontally | ( | ) |
reflect 2D data view at horizontal axis
Definition at line 277 of file data_view.cxx.
References cgv::data::data_view_impl< data_view, unsigned char * >::data_ptr, cgv::data::data_view_base::get_format(), cgv::data::data_format::get_height(), and cgv::data::data_view_base::get_step_size().
Referenced by cgv::render::gl::gl_context::read_frame_buffer().
|
inline |
write access to the i-th component, return whether write was successful
Definition at line 205 of file data_view.h.
void cgv::data::data_view::set_ptr | ( | unsigned char * | ptr, |
bool | manage_ptr | ||
) |
set a different data pointer that will be deleted with the delete [] operator of type (unsigned char*) on destruction if the manage_ptr flag is true
Definition at line 242 of file data_view.cxx.
References cgv::data::data_view_impl< data_view, unsigned char * >::data_ptr, and owns_ptr.
Referenced by cgv::media::image::image_reader::read_line().
void cgv::data::data_view::set_ptr | ( | void * | ptr | ) |
set a different data pointer that is not owned by the data view and will not be deleted on destruction.
Definition at line 249 of file data_view.cxx.
References cgv::data::data_view_impl< data_view, unsigned char * >::data_ptr, and owns_ptr.
|
friend |
Definition at line 157 of file data_view.h.
|
friend |
declare base as friend
Definition at line 138 of file data_view.h.
|
protected |
a flag telling whether the data ptr is owned by the view
Definition at line 159 of file data_view.h.
Referenced by data_view(), operator=(), set_ptr(), set_ptr(), and ~data_view().