3#include <cgv/type/info/type_ptr.h>
4#include <cgv/type/func/transfer_const.h>
5#include <cgv/type/func/drop_pointer.h>
6#include <cgv/data/data_format.h>
33 void manage_format(
bool enable =
true);
39 unsigned int get_dim()
const;
41 size_t get_step_size(
unsigned int dim)
const;
46template <
class D,
typename P =
unsigned char*>
61 typename cgv::type::func::transfer_const<P,S*>::type
get_ptr()
const {
62 return (
typename cgv::type::func::transfer_const<P,S*>::type)(data_ptr);
66 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
size_t i)
const {
67 return (
typename cgv::type::func::transfer_const<P, S*>::type)(data_ptr + i*step_sizes[0]);
71 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
size_t i,
size_t j)
const {
72 return (
typename cgv::type::func::transfer_const<P, S*>::type)(data_ptr + i*step_sizes[0] + j*step_sizes[1]);
76 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
size_t i,
size_t j,
size_t k)
const {
77 return (
typename cgv::type::func::transfer_const<P, S*>::type)(data_ptr + i*step_sizes[0] + j*step_sizes[1] + k*step_sizes[2]);
81 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
size_t i,
size_t j,
size_t k,
size_t l)
const {
82 return (
typename cgv::type::func::transfer_const<P, S*>::type)(data_ptr + i*step_sizes[0] + j*step_sizes[1] + k*step_sizes[2] + l*step_sizes[3]);
86 S
get(
unsigned ci)
const {
87 return format->get<S>(ci, data_ptr);
90 template <
typename S> S
get(
unsigned ci,
size_t i)
const {
91 return format->get<S>(ci, get_ptr<typename cgv::type::func::drop_pointer<P>::type>(i));
94 template <
typename S> S
get(
unsigned ci,
size_t i,
size_t j)
const {
95 return format->get<S>(ci, get_ptr<typename cgv::type::func::drop_pointer<P>::type>(i, j));
98 template <
typename S> S
get(
unsigned ci,
size_t i,
size_t j,
size_t k)
const {
99 return format->get<S>(ci, get_ptr<typename cgv::type::func::drop_pointer<P>::type>(i, j, k));
102 template <
typename S> S
get(
unsigned ci,
size_t i,
size_t j,
size_t k,
size_t l)
const {
103 return format->get<S>(ci, get_ptr<typename cgv::type::func::drop_pointer<P>::type>(i, j, k, l));
106 D operator () (
size_t i)
const;
108 D operator () (
size_t i,
size_t j)
const;
110 D operator () (
size_t i,
size_t j,
size_t k)
const;
112 D operator () (
size_t i,
size_t j,
size_t k,
size_t l)
const;
119 D permute(
const std::string& permutation)
const;
124 template <
typename S>
125 typename cgv::type::func::transfer_const<P,S*>::type
126 step_i(S* ptr, std::ptrdiff_t n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+n*step_sizes[0]); }
128 template <
typename S>
129 typename cgv::type::func::transfer_const<P,S*>::type
130 step_j(S* ptr, std::ptrdiff_t n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+n*step_sizes[1]); }
132 template <
typename S>
133 typename cgv::type::func::transfer_const<P,S*>::type
134 step_k(S* ptr, std::ptrdiff_t n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+n*step_sizes[2]); }
136 template <
typename S>
137 typename cgv::type::func::transfer_const<P,S*>::type
138 step_l(S* ptr, std::ptrdiff_t n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+n*step_sizes[3]); }
141class CGV_API const_data_view;
162 unsigned int _dim,
const size_t* _step_sizes);
199 void set_ptr(
unsigned char* ptr,
bool manage_ptr);
202 void set_ptr(
void* ptr);
204 template <
typename T>
205 bool set(
int ci,
const T& v) {
206 return format->set(ci, data_ptr, v);
209 void reflect_horizontally();
211 static bool compose(
data_view& composed_dv,
const std::vector<data_view>& dvs);
213 static bool combine_components(
data_view& dv,
const std::vector<data_view>::iterator first,
const std::vector<data_view>::iterator last);
227 unsigned _dim,
const size_t* _step_sizes);
239 void set_ptr(
const void* ptr);
245#include <cgv/config/lib_end.h>
The const_data_view has the functionality of the data_view but uses a const pointer and therefore doe...
base class of both implementations of the data view managing the component format,...
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
bool owns_format
whether to own the data format
template class implementing the part of the view that depends on whether the pointer is const or not ...
S get(unsigned ci) const
constant access to the ci-th component
P data_ptr
data pointer of type unsigned char or const unsigned char
cgv::type::func::transfer_const< P, S * >::type get_ptr(size_t i) const
return a pointer to type S for i-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
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
cgv::type::func::transfer_const< P, 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< P, 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
D transpose() const
transpose is equivalent to permute("ji")
S get(unsigned ci, size_t i, size_t j) const
constant access to the ci-th component of (i,j)-th data entry
cgv::type::func::transfer_const< P, S * >::type get_ptr() const
return a data pointer to type S
cgv::type::func::transfer_const< P, 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
cgv::type::func::transfer_const< P, 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< P, 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< P, 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
S get(unsigned ci, size_t i) const
constant access to the ci-th component of i-th data entry
the data view gives access to a data array of one, two, three or four dimensions.
bool owns_ptr
a flag telling whether the data ptr is owned by the view
data_view copy()
return a copy of this data_view and tha data via the copy constructor
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(const data_view &other)
construct a data view as a copy of the given data view.
bool set(int ci, const T &v)
write access to the i-th component, return whether write was successful
unsigned char uint8_type
this type provides an 8 bit unsigned integer type