PolyVox
0.2.1
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 <cassert>
32
#include <limits>
33
34
namespace
PolyVox
35
{
41
template
<
typename
_VoxelType>
42
class
BaseVolume
43
{
44
public
:
45
typedef
_VoxelType
VoxelType
;
46
47
#ifndef SWIG
48
template
<
typename
DerivedVolumeType>
49
class
Sampler
50
{
51
public
:
52
Sampler
(DerivedVolumeType* volume);
53
~Sampler
();
54
55
Vector3DInt32
getPosition
(
void
)
const
;
56
inline
VoxelType
getVoxel
(
void
)
const
;
57
58
void
setPosition
(
const
Vector3DInt32
& v3dNewPos);
59
void
setPosition
(
int32_t
xPos,
int32_t
yPos,
int32_t
zPos);
60
inline
bool
setVoxel
(
VoxelType
tValue);
61
62
void
movePositiveX
(
void
);
63
void
movePositiveY
(
void
);
64
void
movePositiveZ
(
void
);
65
66
void
moveNegativeX
(
void
);
67
void
moveNegativeY
(
void
);
68
void
moveNegativeZ
(
void
);
69
70
inline
VoxelType
peekVoxel1nx1ny1nz
(
void
)
const
;
71
inline
VoxelType
peekVoxel1nx1ny0pz
(
void
)
const
;
72
inline
VoxelType
peekVoxel1nx1ny1pz
(
void
)
const
;
73
inline
VoxelType
peekVoxel1nx0py1nz
(
void
)
const
;
74
inline
VoxelType
peekVoxel1nx0py0pz
(
void
)
const
;
75
inline
VoxelType
peekVoxel1nx0py1pz
(
void
)
const
;
76
inline
VoxelType
peekVoxel1nx1py1nz
(
void
)
const
;
77
inline
VoxelType
peekVoxel1nx1py0pz
(
void
)
const
;
78
inline
VoxelType
peekVoxel1nx1py1pz
(
void
)
const
;
79
80
inline
VoxelType
peekVoxel0px1ny1nz
(
void
)
const
;
81
inline
VoxelType
peekVoxel0px1ny0pz
(
void
)
const
;
82
inline
VoxelType
peekVoxel0px1ny1pz
(
void
)
const
;
83
inline
VoxelType
peekVoxel0px0py1nz
(
void
)
const
;
84
inline
VoxelType
peekVoxel0px0py0pz
(
void
)
const
;
85
inline
VoxelType
peekVoxel0px0py1pz
(
void
)
const
;
86
inline
VoxelType
peekVoxel0px1py1nz
(
void
)
const
;
87
inline
VoxelType
peekVoxel0px1py0pz
(
void
)
const
;
88
inline
VoxelType
peekVoxel0px1py1pz
(
void
)
const
;
89
90
inline
VoxelType
peekVoxel1px1ny1nz
(
void
)
const
;
91
inline
VoxelType
peekVoxel1px1ny0pz
(
void
)
const
;
92
inline
VoxelType
peekVoxel1px1ny1pz
(
void
)
const
;
93
inline
VoxelType
peekVoxel1px0py1nz
(
void
)
const
;
94
inline
VoxelType
peekVoxel1px0py0pz
(
void
)
const
;
95
inline
VoxelType
peekVoxel1px0py1pz
(
void
)
const
;
96
inline
VoxelType
peekVoxel1px1py1nz
(
void
)
const
;
97
inline
VoxelType
peekVoxel1px1py0pz
(
void
)
const
;
98
inline
VoxelType
peekVoxel1px1py1pz
(
void
)
const
;
99
100
protected
:
101
DerivedVolumeType*
mVolume
;
102
103
//The current position in the volume
104
int32_t
mXPosInVolume
;
105
int32_t
mYPosInVolume
;
106
int32_t
mZPosInVolume
;
107
};
108
#endif
109
110
public
:
112
VoxelType
getBorderValue
(
void
)
const
;
114
Region
getEnclosingRegion
(
void
)
const
;
116
int32_t
getWidth
(
void
)
const
;
118
int32_t
getHeight
(
void
)
const
;
120
int32_t
getDepth
(
void
)
const
;
122
int32_t
getLongestSideLength
(
void
)
const
;
124
int32_t
getShortestSideLength
(
void
)
const
;
126
float
getDiagonalLength
(
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
BaseVolume
(
const
Region
& regValid);
145
147
BaseVolume
(
const
BaseVolume
& rhs);
148
150
~BaseVolume
();
151
153
BaseVolume
&
operator=
(
const
BaseVolume
& rhs);
154
155
//The size of the volume
156
Region
m_regValidRegion
;
157
158
//Some useful sizes
159
int32_t
m_uLongestSideLength
;
160
int32_t
m_uShortestSideLength
;
161
float
m_fDiagonalLength
;
162
};
163
}
164
165
#include "
PolyVoxCore/BaseVolume.inl
"
166
#include "
PolyVoxCore/BaseVolumeSampler.inl
"
167
168
#endif //__PolyVox_BaseVolume_H__
Generated by
1.8.1