MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
volume.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef MVE_VOLUME_HEADER
11#define MVE_VOLUME_HEADER
12
13#include <vector>
14#include <limits>
15#include <memory>
16
17#include "math/vector.h"
18#include "mve/defines.h"
19
21
22template <typename T> class Volume;
24
28template <typename T>
29class Volume
30{
31public:
32 typedef std::shared_ptr<Volume<T> > Ptr;
33 typedef std::shared_ptr<Volume<T> const> ConstPtr;
34 typedef std::vector<T> Voxels;
35
36public:
37 Volume (void);
38 static Ptr create (int width, int height, int depth);
39
41 void allocate (int width, int height, int depth);
42
44 Voxels& get_data (void);
46 Voxels const& get_data (void) const;
47
49 int width (void) const;
51 int height (void) const;
53 int depth (void) const;
54
55private:
56 int w;
57 int h;
58 int d;
59 Voxels data;
60};
61
62/* ---------------------------------------------------------------- */
63
65{
66private:
67 std::size_t iter;
68
69public:
71 float sdf[8];
72 std::size_t vid[8];
74 math::Vec3f color[8];
75
76public:
77 VolumeMCAccessor (void);
78 bool next (void);
79 bool has_colors (void) const;
80};
81
82/* ---------------------------------------------------------------- */
83
84/* Currently only for float volumes. */
86{
87private:
88 std::size_t iter;
89 math::Vec3f cube_pos[8];
90 std::size_t cube_vids[8];
91
92public:
94 float sdf[4];
95 std::size_t vid[4];
97
98public:
99 VolumeMTAccessor (void);
100 bool next (void);
101 void load_new_cube (void);
102};
103
104/* -------------------------- Implementation ---------------------- */
105
106template <typename T>
107inline
109 : w(0), h(0), d(0)
110{
111}
112
113template <typename T>
114inline typename Volume<T>::Ptr
115Volume<T>::create (int width, int height, int depth)
116{
117 typename Volume<T>::Ptr v(new Volume());
118 v->allocate(width, height, depth);
119 return v;
120}
121
122template <typename T>
123inline void
124Volume<T>::allocate (int width, int height, int depth)
125{
126 this->w = width;
127 this->h = height;
128 this->d = depth;
129 this->data.resize(width * height * depth);
130}
131
132template <typename T>
133inline typename Volume<T>::Voxels&
135{
136 return this->data;
137}
138
139template <typename T>
140inline typename Volume<T>::Voxels const&
142{
143 return this->data;
144}
145
146template <typename T>
147inline int
149{
150 return this->w;
151}
152
153template <typename T>
154inline int
156{
157 return this->h;
158}
159
160template <typename T>
161inline int
163{
164 return this->d;
165}
166
168
169#endif /* MVE_VOLUME_HEADER */
Vector class for arbitrary dimensions and types.
Definition vector.h:87
A volume with regular grid layout.
Definition volume.h:30
int depth(void) const
Returns depth of the image.
Definition volume.h:162
void allocate(int width, int height, int depth)
Allocates new volume space, clearing previous contents.
Definition volume.h:124
Voxels & get_data(void)
Returns data vector for the volume.
Definition volume.h:134
std::shared_ptr< Volume< T > > Ptr
Definition volume.h:32
static Ptr create(int width, int height, int depth)
Definition volume.h:115
std::vector< T > Voxels
Definition volume.h:34
int height(void) const
Returns height of the image.
Definition volume.h:155
int width(void) const
Returns width of the image.
Definition volume.h:148
std::shared_ptr< Volume< T > const > ConstPtr
Definition volume.h:33
mve::FloatVolume::Ptr vol
Definition volume.h:70
mve::FloatVolume::Ptr vol
Definition volume.h:93
#define MVE_NAMESPACE_BEGIN
Definition defines.h:13
#define MVE_NAMESPACE_END
Definition defines.h:14