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>
22 unsigned int step_sizes[4];
25 const unsigned int* _step_sizes);
34 void manage_format(
bool enable =
true);
40 unsigned int get_dim()
const;
42 unsigned int get_step_size(
unsigned int dim)
const;
47 template <
class D,
typename P =
unsigned char*>
55 unsigned int _dim,
const unsigned int* _step_sizes);
63 typename cgv::type::func::transfer_const<P,S*>::type
get_ptr()
const {
64 return (
typename cgv::type::func::transfer_const<P,S*>::type)(data_ptr);
68 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
int i)
const {
69 return (
typename cgv::type::func::transfer_const<P, S*>::type)(data_ptr + i*step_sizes[0]);
73 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
int i,
int j)
const {
74 return (
typename cgv::type::func::transfer_const<P, S*>::type)(data_ptr + i*step_sizes[0] + j*step_sizes[1]);
78 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
int i,
int j,
int k)
const {
79 return (
typename cgv::type::func::transfer_const<P, S*>::type)(data_ptr + i*step_sizes[0] + j*step_sizes[1] + k*step_sizes[2]);
83 typename cgv::type::func::transfer_const<P, S*>::type
get_ptr(
int i,
int j,
int k,
int l)
const {
84 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]);
89 return format->get<S>(ci, data_ptr);
92 template <
typename S> S
get(
int ci,
int i)
const {
93 return format->get<S>(ci, get_ptr<cgv::type::func::drop_pointer<P>::type>(i));
96 template <
typename S> S
get(
int ci,
int i,
int j)
const {
97 return format->get<S>(ci, get_ptr<cgv::type::func::drop_pointer<P>::type>(i, j));
100 template <
typename S> S
get(
int ci,
int i,
int j,
int k)
const {
101 return format->get<S>(ci, get_ptr<cgv::type::func::drop_pointer<P>::type>(i,j,k));
104 template <
typename S> S
get(
int ci,
int i,
int j,
int k,
int l)
const {
105 return format->get<S>(ci, get_ptr<cgv::type::func::drop_pointer<P>::type>(i, j, k, l));
108 D operator () (
unsigned int i)
const;
110 D operator () (
unsigned int i,
unsigned int j)
const;
112 D operator () (
unsigned int i,
unsigned int j,
unsigned int k)
const;
114 D operator () (
unsigned int i,
unsigned int j,
unsigned int k,
unsigned int l)
const;
121 D permute(
const std::string& permutation)
const;
126 template <
typename S>
127 typename cgv::type::func::transfer_const<P,S*>::type
128 step_i(S* ptr,
int n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+n*step_sizes[0]); }
130 template <
typename S>
131 typename cgv::type::func::transfer_const<P,S*>::type
132 step_j(S* ptr,
int n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+n*step_sizes[1]); }
134 template <
typename S>
135 typename cgv::type::func::transfer_const<P,S*>::type
136 step_k(S* ptr,
int n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+n*step_sizes[2]); }
138 template <
typename S>
139 typename cgv::type::func::transfer_const<P,S*>::type
140 step_l(S* ptr,
int n=1)
const {
return static_cast<typename cgv::type::func::transfer_const<P,S*>::type
>(
static_cast<P
>(ptr)+step_sizes[3]); }
143 class CGV_API const_data_view;
164 unsigned int _dim,
const unsigned int* _step_sizes);
189 void set_ptr(
unsigned char* ptr,
bool manage_ptr);
192 void set_ptr(
void* ptr);
194 template <
typename T>
195 bool set(
int ci,
const T& v) {
196 return format->set(ci, data_ptr, v);
199 void reflect_horizontally();
201 static bool compose(
data_view& composed_dv,
const std::vector<data_view>& dvs);
203 static bool combine_components(
data_view& dv,
const std::vector<data_view>::iterator first,
const std::vector<data_view>::iterator last);
217 unsigned int _dim,
const unsigned int* _step_sizes);
229 void set_ptr(
const void* ptr);
235 #include <cgv/config/lib_end.h>
cgv::type::func::transfer_const< P, S * >::type step_k(S *ptr, int n=1) const
return a pointer that points to the n-th next location if index k is increase by n
Definition: data_view.h:136
cgv::type::func::transfer_const< P, S * >::type get_ptr(int i) const
return a pointer to type S for i-th data entry
Definition: data_view.h:68
S get(int ci, int i, int j, int k, int l) const
constant access to the ci-th component of (i,j,k,l)-th data entry
Definition: data_view.h:104
S get(int ci, int i, int j, int k) const
constant access to the ci-th component of (i,j,k)-th data entry
Definition: data_view.h:100
Definition: data_view.h:211
Definition: data_view.h:49
bool owns_ptr
a flag telling whether the data ptr is owned by the view
Definition: data_view.h:161
cgv::type::func::transfer_const< P, S * >::type step_l(S *ptr, int n=1) const
return a pointer that points to the n-th next location if index l is increase by n
Definition: data_view.h:140
cgv::type::func::transfer_const< P, S * >::type get_ptr(int i, int j, int k, int l) const
return a pointer to type S for (i,j,k,l)-th data entry
Definition: data_view.h:83
Definition: data_view.h:155
Definition: data_view.h:16
cgv::type::func::transfer_const< P, S * >::type step_j(S *ptr, int n=1) const
return a pointer that points to the n-th next location if index j is increase by n
Definition: data_view.h:132
P data_ptr
data pointer of type unsigned char or const unsigned char
Definition: data_view.h:52
cgv::type::func::transfer_const< P, S * >::type get_ptr() const
return a data pointer to type S
Definition: data_view.h:63
S get(int ci, int i) const
constant access to the ci-th component of i-th data entry
Definition: data_view.h:92
bool set(int ci, const T &v)
write access to the i-th component, return whether write was successful
Definition: data_view.h:195
S get(int ci) const
constant access to the ci-th component
Definition: data_view.h:88
D transpose() const
transpose is equivalent to permute("ji")
Definition: data_view.h:123
cgv::type::func::transfer_const< P, S * >::type step_i(S *ptr, int n=1) const
return a pointer that points to the n-th next location if index i is increase by n
Definition: data_view.h:128
bool owns_format
whether to own the data format
Definition: data_view.h:20
S get(int ci, int i, int j) const
constant access to the ci-th component of (i,j)-th data entry
Definition: data_view.h:96
cgv::type::func::transfer_const< P, S * >::type get_ptr(int i, int j) const
return a pointer to type S for (i,j)-th data entry
Definition: data_view.h:73
cgv::type::func::transfer_const< P, S * >::type get_ptr(int i, int j, int k) const
return a pointer to type S for (i,j,k)-th data entry
Definition: data_view.h:78
the cgv namespace
Definition: vr_calib.cxx:9