PolyVox
0.3.0-dev
Open source voxel management library
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PolyVoxCore
include
PolyVoxCore
BaseVolume.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_BaseVolume_H__
25
#define __PolyVox_BaseVolume_H__
26
27
#include "
PolyVoxCore/Log.h
"
28
#include "
PolyVoxCore/Region.h
"
29
#include "
PolyVoxCore/Vector.h
"
30
31
#include <limits>
32
33
namespace
PolyVox
34
{
40
namespace
WrapModes
41
{
42
enum
WrapMode
43
{
44
Clamp
= 0,
45
Border
= 1
46
};
47
}
48
typedef
WrapModes::WrapMode
WrapMode
;
49
50
template
<
typename
_VoxelType>
51
class
BaseVolume
52
{
53
public
:
54
typedef
_VoxelType
VoxelType
;
55
56
#ifndef SWIG
57
template
<
typename
DerivedVolumeType>
58
class
Sampler
59
{
60
public
:
61
Sampler
(DerivedVolumeType* volume);
62
~Sampler
();
63
64
Vector3DInt32
getPosition
(
void
)
const
;
65
inline
VoxelType
getVoxel
(
void
)
const
;
66
67
bool
isCurrentPositionValid
(
void
)
const
;
68
69
void
setPosition
(
const
Vector3DInt32
& v3dNewPos);
70
void
setPosition
(
int32_t
xPos,
int32_t
yPos,
int32_t
zPos);
71
inline
bool
setVoxel
(
VoxelType
tValue);
72
void
setWrapMode
(
WrapMode
eWrapMode,
VoxelType
tBorder =
VoxelType
());
73
74
void
movePositiveX
(
void
);
75
void
movePositiveY
(
void
);
76
void
movePositiveZ
(
void
);
77
78
void
moveNegativeX
(
void
);
79
void
moveNegativeY
(
void
);
80
void
moveNegativeZ
(
void
);
81
82
inline
VoxelType
peekVoxel1nx1ny1nz
(
void
)
const
;
83
inline
VoxelType
peekVoxel1nx1ny0pz
(
void
)
const
;
84
inline
VoxelType
peekVoxel1nx1ny1pz
(
void
)
const
;
85
inline
VoxelType
peekVoxel1nx0py1nz
(
void
)
const
;
86
inline
VoxelType
peekVoxel1nx0py0pz
(
void
)
const
;
87
inline
VoxelType
peekVoxel1nx0py1pz
(
void
)
const
;
88
inline
VoxelType
peekVoxel1nx1py1nz
(
void
)
const
;
89
inline
VoxelType
peekVoxel1nx1py0pz
(
void
)
const
;
90
inline
VoxelType
peekVoxel1nx1py1pz
(
void
)
const
;
91
92
inline
VoxelType
peekVoxel0px1ny1nz
(
void
)
const
;
93
inline
VoxelType
peekVoxel0px1ny0pz
(
void
)
const
;
94
inline
VoxelType
peekVoxel0px1ny1pz
(
void
)
const
;
95
inline
VoxelType
peekVoxel0px0py1nz
(
void
)
const
;
96
inline
VoxelType
peekVoxel0px0py0pz
(
void
)
const
;
97
inline
VoxelType
peekVoxel0px0py1pz
(
void
)
const
;
98
inline
VoxelType
peekVoxel0px1py1nz
(
void
)
const
;
99
inline
VoxelType
peekVoxel0px1py0pz
(
void
)
const
;
100
inline
VoxelType
peekVoxel0px1py1pz
(
void
)
const
;
101
102
inline
VoxelType
peekVoxel1px1ny1nz
(
void
)
const
;
103
inline
VoxelType
peekVoxel1px1ny0pz
(
void
)
const
;
104
inline
VoxelType
peekVoxel1px1ny1pz
(
void
)
const
;
105
inline
VoxelType
peekVoxel1px0py1nz
(
void
)
const
;
106
inline
VoxelType
peekVoxel1px0py0pz
(
void
)
const
;
107
inline
VoxelType
peekVoxel1px0py1pz
(
void
)
const
;
108
inline
VoxelType
peekVoxel1px1py1nz
(
void
)
const
;
109
inline
VoxelType
peekVoxel1px1py0pz
(
void
)
const
;
110
inline
VoxelType
peekVoxel1px1py1pz
(
void
)
const
;
111
112
protected
:
113
VoxelType
getVoxelAt
(
int32_t
uXPos,
int32_t
uYPos,
int32_t
uZPos)
const
;
114
115
DerivedVolumeType*
mVolume
;
116
117
//The current position in the volume
118
int32_t
mXPosInVolume
;
119
int32_t
mYPosInVolume
;
120
int32_t
mZPosInVolume
;
121
122
WrapMode
m_eWrapMode
;
123
VoxelType
m_tBorder
;
124
125
//Whether the current position is inside the volume
126
//FIXME - Replace these with flags
127
bool
m_bIsCurrentPositionValidInX
;
128
bool
m_bIsCurrentPositionValidInY
;
129
bool
m_bIsCurrentPositionValidInZ
;
130
};
131
#endif
132
133
public
:
135
VoxelType
getBorderValue
(
void
)
const
;
137
const
Region
&
getEnclosingRegion
(
void
)
const
;
139
int32_t
getWidth
(
void
)
const
;
141
int32_t
getHeight
(
void
)
const
;
143
int32_t
getDepth
(
void
)
const
;
145
int32_t
getLongestSideLength
(
void
)
const
;
147
int32_t
getShortestSideLength
(
void
)
const
;
149
float
getDiagonalLength
(
void
)
const
;
151
VoxelType
getVoxel
(
int32_t
uXPos,
int32_t
uYPos,
int32_t
uZPos)
const
;
153
VoxelType
getVoxel
(
const
Vector3DInt32
& v3dPos)
const
;
155
VoxelType
getVoxelAt
(
int32_t
uXPos,
int32_t
uYPos,
int32_t
uZPos)
const
;
157
VoxelType
getVoxelAt
(
const
Vector3DInt32
& v3dPos)
const
;
159
VoxelType
getVoxelWithWrapping
(
int32_t
uXPos,
int32_t
uYPos,
int32_t
uZPos,
WrapMode
eWrapMode =
WrapModes::Border
,
VoxelType
tBorder =
VoxelType
())
const
;
161
VoxelType
getVoxelWithWrapping
(
const
Vector3DInt32
& v3dPos,
WrapMode
eWrapMode =
WrapModes::Border
,
VoxelType
tBorder =
VoxelType
())
const
;
162
164
void
setBorderValue
(
const
VoxelType
& tBorder);
166
bool
setVoxelAt
(
int32_t
uXPos,
int32_t
uYPos,
int32_t
uZPos,
VoxelType
tValue);
168
bool
setVoxelAt
(
const
Vector3DInt32
& v3dPos,
VoxelType
tValue);
169
171
uint32_t
calculateSizeInBytes
(
void
);
172
173
protected
:
175
BaseVolume
(
const
Region
& regValid);
176
178
BaseVolume
(
const
BaseVolume
& rhs);
179
181
~BaseVolume
();
182
184
BaseVolume
&
operator=
(
const
BaseVolume
& rhs);
185
186
//The size of the volume
187
Region
m_regValidRegion
;
188
189
//Some useful sizes
190
int32_t
m_uLongestSideLength
;
191
int32_t
m_uShortestSideLength
;
192
float
m_fDiagonalLength
;
193
194
//The border value
195
VoxelType
m_tBorderValue
;
196
};
197
}
198
199
#include "
PolyVoxCore/BaseVolume.inl
"
200
#include "
PolyVoxCore/BaseVolumeSampler.inl
"
201
202
#endif //__PolyVox_BaseVolume_H__
Generated by
1.8.2