PolyVox
0.2.1
Open source voxel management library
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PolyVoxCore
include
PolyVoxCore
RawVolume.h
Go to the documentation of this file.
1
/*******************************************************************************
2
Copyright (c) 2005-2009 David Williams
3
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
7
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
11
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
20
3. This notice may not be removed or altered from any source
21
distribution.
22
*******************************************************************************/
23
24
#ifndef __PolyVox_RawVolume_H__
25
#define __PolyVox_RawVolume_H__
26
27
#include "
PolyVoxCore/BaseVolume.h
"
28
#include "
PolyVoxCore/Log.h
"
29
#include "
PolyVoxCore/Region.h
"
30
#include "
PolyVoxCore/Vector.h
"
31
32
#include <cassert>
33
#include <cstdlib>
//For abort()
34
#include <limits>
35
#include <memory>
36
#include <stdexcept>
//For invalid_argument
37
38
namespace
PolyVox
39
{
40
template
<
typename
VoxelType>
41
class
RawVolume
:
public
BaseVolume
<VoxelType>
42
{
43
public
:
44
#ifndef SWIG
45
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
46
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
47
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
48
//option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated
49
//in the future
50
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
51
//class Sampler : public VolumeOfVoxelType::template Sampler< RawVolume<VoxelType> >
52
#if defined(_MSC_VER)
53
class
Sampler
:
public
BaseVolume
<VoxelType>
::Sampler
< RawVolume<VoxelType> >
//This line works on VS2010
54
#else
55
class
Sampler
:
public
BaseVolume
<VoxelType>::template
Sampler
< RawVolume<VoxelType> >
//This line works on GCC
56
#endif
57
{
58
public
:
59
Sampler
(
RawVolume<VoxelType>
* volume);
60
~Sampler
();
61
62
inline
VoxelType
getVoxel
(
void
)
const
;
63
64
void
setPosition
(
const
Vector3DInt32
& v3dNewPos);
65
void
setPosition
(
int32_t
xPos,
int32_t
yPos,
int32_t
zPos);
66
inline
bool
setVoxel
(
VoxelType
tValue);
67
68
void
movePositiveX
(
void
);
69
void
movePositiveY
(
void
);
70
void
movePositiveZ
(
void
);
71
72
void
moveNegativeX
(
void
);
73
void
moveNegativeY
(
void
);
74
void
moveNegativeZ
(
void
);
75
76
inline
VoxelType
peekVoxel1nx1ny1nz
(
void
)
const
;
77
inline
VoxelType
peekVoxel1nx1ny0pz
(
void
)
const
;
78
inline
VoxelType
peekVoxel1nx1ny1pz
(
void
)
const
;
79
inline
VoxelType
peekVoxel1nx0py1nz
(
void
)
const
;
80
inline
VoxelType
peekVoxel1nx0py0pz
(
void
)
const
;
81
inline
VoxelType
peekVoxel1nx0py1pz
(
void
)
const
;
82
inline
VoxelType
peekVoxel1nx1py1nz
(
void
)
const
;
83
inline
VoxelType
peekVoxel1nx1py0pz
(
void
)
const
;
84
inline
VoxelType
peekVoxel1nx1py1pz
(
void
)
const
;
85
86
inline
VoxelType
peekVoxel0px1ny1nz
(
void
)
const
;
87
inline
VoxelType
peekVoxel0px1ny0pz
(
void
)
const
;
88
inline
VoxelType
peekVoxel0px1ny1pz
(
void
)
const
;
89
inline
VoxelType
peekVoxel0px0py1nz
(
void
)
const
;
90
inline
VoxelType
peekVoxel0px0py0pz
(
void
)
const
;
91
inline
VoxelType
peekVoxel0px0py1pz
(
void
)
const
;
92
inline
VoxelType
peekVoxel0px1py1nz
(
void
)
const
;
93
inline
VoxelType
peekVoxel0px1py0pz
(
void
)
const
;
94
inline
VoxelType
peekVoxel0px1py1pz
(
void
)
const
;
95
96
inline
VoxelType
peekVoxel1px1ny1nz
(
void
)
const
;
97
inline
VoxelType
peekVoxel1px1ny0pz
(
void
)
const
;
98
inline
VoxelType
peekVoxel1px1ny1pz
(
void
)
const
;
99
inline
VoxelType
peekVoxel1px0py1nz
(
void
)
const
;
100
inline
VoxelType
peekVoxel1px0py0pz
(
void
)
const
;
101
inline
VoxelType
peekVoxel1px0py1pz
(
void
)
const
;
102
inline
VoxelType
peekVoxel1px1py1nz
(
void
)
const
;
103
inline
VoxelType
peekVoxel1px1py0pz
(
void
)
const
;
104
inline
VoxelType
peekVoxel1px1py1pz
(
void
)
const
;
105
106
private
:
107
//Other current position information
108
VoxelType
* mCurrentVoxel;
109
110
//Whether the current position is inside the volume
111
//FIXME - Replace these with flags
112
bool
m_bIsCurrentPositionValidInX;
113
bool
m_bIsCurrentPositionValidInY;
114
bool
m_bIsCurrentPositionValidInZ;
115
};
116
#endif
117
118
public
:
120
RawVolume
(
const
Region
& regValid);
121
123
~RawVolume
();
124
126
VoxelType
getBorderValue
(
void
)
const
;
128
VoxelType
getVoxelAt
(
int32_t
uXPos,
int32_t
uYPos,
int32_t
uZPos)
const
;
130
VoxelType
getVoxelAt
(
const
Vector3DInt32
& v3dPos)
const
;
131
133
void
setBorderValue
(
const
VoxelType
& tBorder);
135
bool
setVoxelAt
(
int32_t
uXPos,
int32_t
uYPos,
int32_t
uZPos,
VoxelType
tValue);
137
bool
setVoxelAt
(
const
Vector3DInt32
& v3dPos,
VoxelType
tValue);
138
140
uint32_t
calculateSizeInBytes
(
void
);
141
142
protected
:
144
RawVolume
(
const
RawVolume
& rhs);
145
147
RawVolume
&
operator=
(
const
RawVolume
& rhs);
148
149
private
:
150
void
initialise(
const
Region
& regValidRegion);
151
152
//The block data
153
VoxelType
* m_pData;
154
155
//The border value
156
VoxelType
m_tBorderValue;
157
};
158
}
159
160
#include "
PolyVoxCore/RawVolume.inl
"
161
#include "
PolyVoxCore/RawVolumeSampler.inl
"
162
163
#endif //__PolyVox_RawVolume_H__
Generated by
1.8.1