PolyVox
0.3.0-dev
Open source voxel management library
|
Represents a part of a Volume. More...
#include <Region.h>
Public Member Functions | |
Region () | |
Constructor. | |
Region (const Vector3DInt32 &v3dLowerCorner, const Vector3DInt32 &v3dUpperCorner) | |
Constructor. | |
Region (int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ) | |
Constructor. | |
bool | operator== (const Region &rhs) const |
Equality Operator. | |
bool | operator!= (const Region &rhs) const |
Inequality Operator. | |
int32_t | getLowerX (void) const |
Gets the 'x' position of the lower corner. | |
int32_t | getLowerY (void) const |
Gets the 'y' position of the lower corner. | |
int32_t | getLowerZ (void) const |
Gets the 'z' position of the lower corner. | |
int32_t | getUpperX (void) const |
Gets the 'x' position of the upper corner. | |
int32_t | getUpperY (void) const |
Gets the 'y' position of the upper corner. | |
int32_t | getUpperZ (void) const |
Gets the 'z' position of the upper corner. | |
Vector3DInt32 | getLowerCorner (void) const |
Gets the position of the lower corner. | |
Vector3DInt32 | getUpperCorner (void) const |
Gets the position of the upper corner. | |
int32_t | getWidthInVoxels (void) const |
Gets the width of the region measured in voxels. | |
int32_t | getHeightInVoxels (void) const |
Gets the height of the region measured in voxels. | |
int32_t | getDepthInVoxels (void) const |
Gets the depth of the region measured in voxels. | |
Vector3DInt32 | getDimensionsInVoxels (void) const |
Gets the dimensions of the region measured in voxels. | |
int32_t | getWidthInCells (void) const |
Gets the width of the region measured in cells. | |
int32_t | getHeightInCells (void) const |
Gets the height of the region measured in cells. | |
int32_t | getDepthInCells (void) const |
Gets the depth of the region measured in cells. | |
Vector3DInt32 | getDimensionsInCells (void) const |
Gets the dimensions of the region measured in cells. | |
void | setLowerX (int32_t iX) |
Sets the 'x' position of the lower corner. | |
void | setLowerY (int32_t iY) |
Sets the 'y' position of the lower corner. | |
void | setLowerZ (int32_t iZ) |
Sets the 'z' position of the lower corner. | |
void | setUpperX (int32_t iX) |
Sets the 'x' position of the upper corner. | |
void | setUpperY (int32_t iY) |
Sets the 'y' position of the upper corner. | |
void | setUpperZ (int32_t iZ) |
Sets the 'z' position of the upper corner. | |
void | setLowerCorner (const Vector3DInt32 &v3dLowerCorner) |
Sets the position of the lower corner. | |
void | setUpperCorner (const Vector3DInt32 &v3dUpperCorner) |
Sets the position of the upper corner. | |
bool | containsPoint (float fX, float fY, float fZ, float boundary=0.0f) const |
Tests whether the given point is contained in this Region. | |
bool | containsPoint (const Vector3DFloat &pos, float boundary=0.0f) const |
Tests whether the given point is contained in this Region. | |
bool | containsPoint (int32_t iX, int32_t iY, int32_t iZ, uint8_t boundary=0) const |
Tests whether the given point is contained in this Region. | |
bool | containsPoint (const Vector3DInt32 &pos, uint8_t boundary=0) const |
Tests whether the given point is contained in this Region. | |
bool | containsPointInX (float pos, float boundary=0.0f) const |
Tests whether the given position is contained in the 'x' range of this Region. | |
bool | containsPointInX (int32_t pos, uint8_t boundary=0) const |
Tests whether the given position is contained in the 'x' range of this Region. | |
bool | containsPointInY (float pos, float boundary=0.0f) const |
Tests whether the given position is contained in the 'y' range of this Region. | |
bool | containsPointInY (int32_t pos, uint8_t boundary=0) const |
Tests whether the given position is contained in the 'y' range of this Region. | |
bool | containsPointInZ (float pos, float boundary=0.0f) const |
Tests whether the given position is contained in the 'z' range of this Region. | |
bool | containsPointInZ (int32_t pos, uint8_t boundary=0) const |
Tests whether the given position is contained in the 'z' range of this Region. | |
void | accumulate (int32_t iX, int32_t iY, int32_t iZ) |
Enlarges the Region so that it contains the specified position. | |
void | accumulate (const Vector3DInt32 &v3dPos) |
Enlarges the Region so that it contains the specified position. | |
void | accumulate (const Region ®) |
Enlarges the Region so that it contains the specified Region. | |
void | cropTo (const Region &other) |
Crops the extents of this Region accoring to another Region. | |
void | grow (int32_t iAmount) |
Grows this region by the amount specified. | |
void | grow (int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ) |
Grows this region by the amounts specified. | |
void | grow (const Vector3DInt32 &v3dAmount) |
Grows this region by the amounts specified. | |
bool | isValid (void) const |
Tests whether all components of the upper corner are at least as great as the corresponding components of the lower corner. | |
void | shift (int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ) |
Moves the Region by the amount specified. | |
void | shift (const Vector3DInt32 &v3dAmount) |
Moves the Region by the amount specified. | |
void | shiftLowerCorner (int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ) |
Moves the lower corner of the Region by the amount specified. | |
void | shiftLowerCorner (const Vector3DInt32 &v3dAmount) |
Moves the lower corner of the Region by the amount specified. | |
void | shiftUpperCorner (int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ) |
Moves the upper corner of the Region by the amount specified. | |
void | shiftUpperCorner (const Vector3DInt32 &v3dAmount) |
Moves the upper corner of the Region by the amount specified. | |
void | shrink (int32_t iAmount) |
Shrinks this region by the amount specified. | |
void | shrink (int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ) |
Shrinks this region by the amounts specified. | |
void | shrink (const Vector3DInt32 &v3dAmount) |
Shrinks this region by the amounts specified. | |
Static Public Attributes | |
static const Region | MaxRegion |
A Region with the lower corner set as low as possible and the upper corner set as high as possible. | |
static const Region | InvertedRegion |
A Region with the lower corner set as high as possible and the upper corner set as low as possible. | |
Represents a part of a Volume.
Many operations in PolyVox are constrained to only part of a volume. For example, when running the surface extractors it is unlikely that you will want to run it on the whole volume at once, as this will give a very large mesh which may be too much to render. Instead you will probably want to run a surface extractor a number of times on different parts of the volume, there by giving a number of meshes which can be culled and rendered seperately.
The Region class is used to define these parts (regions) of the volume. Essentially it consists of an upper and lower bound which specify the range of voxels positions considered to be part of the region. Note that these bounds are inclusive.
As well as the expected set of getters and setters, this class also provide utility functions for increasing and decresing the size of the Region, shifting the Region in 3D space, testing whether it contains a given position, enlarging it so that it does contain a given position, croppng it to another Region, and various other utility functions.
The dimensions of a region can be measured either in voxels or in cells. See the manual for more information about these definitions.
PolyVox::Region::Region | ( | ) |
Constructor.
Constructs a Region and clears all extents to zero.
Definition at line 94 of file Region.cpp.
PolyVox::Region::Region | ( | const Vector3DInt32 & | v3dLowerCorner, |
const Vector3DInt32 & | v3dUpperCorner | ||
) |
Constructor.
Constructs a Region and sets the lower and upper corners to the specified values.
v3dLowerCorner | The desired lower corner of the Region. |
v3dUpperCorner | The desired upper corner of the Region. |
Definition at line 109 of file Region.cpp.
PolyVox::Region::Region | ( | int32_t | iLowerX, |
int32_t | iLowerY, | ||
int32_t | iLowerZ, | ||
int32_t | iUpperX, | ||
int32_t | iUpperY, | ||
int32_t | iUpperZ | ||
) |
Constructor.
Constructs a Region and sets the extents to the specified values.
iLowerX | The desired lower 'x' extent of the Region. |
iLowerY | The desired lower 'y' extent of the Region. |
iLowerZ | The desired lower 'z' extent of the Region. |
iUpperX | The desired upper 'x' extent of the Region. |
iUpperY | The desired upper 'y' extent of the Region. |
iUpperZ | The desired upper 'z' extent of the Region. |
Definition at line 128 of file Region.cpp.
Enlarges the Region so that it contains the specified position.
iX | The 'x' component of the position to accumulate. |
iY | The 'y' component of the position to accumulate. |
iZ | The 'z' component of the position to accumulate. |
Definition at line 54 of file Region.cpp.
Referenced by accumulate().
void PolyVox::Region::accumulate | ( | const Vector3DInt32 & | v3dPos | ) |
Enlarges the Region so that it contains the specified position.
v3dPos | The position to accumulate. |
Definition at line 67 of file Region.cpp.
void PolyVox::Region::accumulate | ( | const Region & | reg | ) |
Enlarges the Region so that it contains the specified Region.
Note that this is not the same as computing the union of two Regions (as the result of such a union may not be a shape which can be exactly represented by a Region).
Instead, the result is simply big enough to contain both this Region and the one passed as a parameter.
Definition at line 79 of file Region.cpp.
Tests whether the given point is contained in this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in all directions.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
fX | The 'x' position of the point to test. |
fY | The 'y' position of the point to test. |
fZ | The 'z' position of the point to test. |
boundary | The desired boundary value. |
Definition at line 170 of file Region.cpp.
Referenced by containsPoint(), PolyVox::ConstVolumeProxy< VoxelType >::getVoxelAt(), and PolyVox::ConstVolumeProxy< VoxelType >::setVoxelAt().
bool PolyVox::Region::containsPoint | ( | const Vector3DFloat & | pos, |
float | boundary = 0.0f |
||
) | const |
Tests whether the given point is contained in this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in all directions.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 187 of file Region.cpp.
bool PolyVox::Region::containsPoint | ( | int32_t | iX, |
int32_t | iY, | ||
int32_t | iZ, | ||
uint8_t | boundary = 0 |
||
) | const |
Tests whether the given point is contained in this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in all directions.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
iX | The 'x' position of the point to test. |
iY | The 'y' position of the point to test. |
iZ | The 'z' position of the point to test. |
boundary | The desired boundary value. |
Definition at line 201 of file Region.cpp.
bool PolyVox::Region::containsPoint | ( | const Vector3DInt32 & | pos, |
uint8_t | boundary = 0 |
||
) | const |
Tests whether the given point is contained in this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in all directions.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 218 of file Region.cpp.
Tests whether the given position is contained in the 'x' range of this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in the 'x' direction.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 230 of file Region.cpp.
Referenced by PolyVox::BaseVolume< _VoxelType >::Sampler< DerivedVolumeType >::moveNegativeX(), and PolyVox::BaseVolume< _VoxelType >::Sampler< DerivedVolumeType >::movePositiveX().
Tests whether the given position is contained in the 'x' range of this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in the 'x' direction.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 243 of file Region.cpp.
Tests whether the given position is contained in the 'y' range of this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in the 'y' direction.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 256 of file Region.cpp.
Referenced by PolyVox::BaseVolume< _VoxelType >::Sampler< DerivedVolumeType >::moveNegativeY(), and PolyVox::BaseVolume< _VoxelType >::Sampler< DerivedVolumeType >::movePositiveY().
Tests whether the given position is contained in the 'y' range of this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in the 'y' direction.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 269 of file Region.cpp.
Tests whether the given position is contained in the 'z' range of this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in the 'z' direction.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 282 of file Region.cpp.
Referenced by PolyVox::BaseVolume< _VoxelType >::Sampler< DerivedVolumeType >::moveNegativeZ(), and PolyVox::BaseVolume< _VoxelType >::Sampler< DerivedVolumeType >::movePositiveZ().
Tests whether the given position is contained in the 'z' range of this Region.
The boundary value can be used to ensure a position is only considered to be inside the Region if it is that far in in the 'z' direction.
Also, the test is inclusive such that positions lying exactly on the edge of the Region are considered to be inside it.
pos | The position to test. |
boundary | The desired boundary value. |
Definition at line 295 of file Region.cpp.
void PolyVox::Region::cropTo | ( | const Region & | other | ) |
|
inline |
Gets the depth of the region measured in cells.
Definition at line 328 of file Region.h.
Referenced by getDepthInVoxels(), and getDimensionsInCells().
|
inline |
Gets the depth of the region measured in voxels.
Definition at line 292 of file Region.h.
|
inline |
Gets the dimensions of the region measured in cells.
Definition at line 337 of file Region.h.
Referenced by getDimensionsInVoxels().
|
inline |
Gets the dimensions of the region measured in voxels.
Definition at line 301 of file Region.h.
|
inline |
Gets the height of the region measured in cells.
Definition at line 319 of file Region.h.
Referenced by getDimensionsInCells(), and getHeightInVoxels().
|
inline |
Gets the height of the region measured in voxels.
Definition at line 283 of file Region.h.
|
inline |
Gets the position of the lower corner.
Definition at line 257 of file Region.h.
Referenced by PolyVox::LargeVolume< VoxelType >::flush(), and PolyVox::LargeVolume< VoxelType >::prefetch().
|
inline |
Gets the 'x' position of the lower corner.
Definition at line 209 of file Region.h.
Referenced by accumulate(), and PolyVox::calculateAmbientOcclusion().
|
inline |
Gets the 'y' position of the lower corner.
Definition at line 217 of file Region.h.
Referenced by accumulate(), and PolyVox::calculateAmbientOcclusion().
|
inline |
Gets the 'z' position of the lower corner.
Definition at line 225 of file Region.h.
Referenced by accumulate(), and PolyVox::calculateAmbientOcclusion().
|
inline |
Gets the position of the upper corner.
Definition at line 265 of file Region.h.
Referenced by PolyVox::LargeVolume< VoxelType >::flush(), PolyVox::MarchingCubesSurfaceExtractor< VolumeType, Controller >::MarchingCubesSurfaceExtractor(), and PolyVox::LargeVolume< VoxelType >::prefetch().
|
inline |
Gets the 'x' position of the upper corner.
Definition at line 233 of file Region.h.
Referenced by accumulate(), and PolyVox::calculateAmbientOcclusion().
|
inline |
Gets the 'y' position of the upper corner.
Definition at line 241 of file Region.h.
Referenced by accumulate(), and PolyVox::calculateAmbientOcclusion().
|
inline |
Gets the 'z' position of the upper corner.
Definition at line 249 of file Region.h.
Referenced by accumulate(), and PolyVox::calculateAmbientOcclusion().
|
inline |
Gets the width of the region measured in cells.
Definition at line 310 of file Region.h.
Referenced by getDimensionsInCells(), and getWidthInVoxels().
|
inline |
Gets the width of the region measured in voxels.
Definition at line 274 of file Region.h.
void PolyVox::Region::grow | ( | int32_t | iAmount | ) |
Grows this region by the amount specified.
The same amount of growth is applied in all directions.
Negative growth is possible but you should prefer the shrink() function for clarity.
iAmount | The amount to grow by. |
Definition at line 321 of file Region.cpp.
Referenced by grow().
Grows this region by the amounts specified.
The amount can be specified seperatly for each direction.
Negative growth is possible but you should prefer the shrink() function for clarity.
iAmountX | The amount to grow by in 'x'. |
iAmountY | The amount to grow by in 'y'. |
iAmountZ | The amount to grow by in 'z'. |
Definition at line 339 of file Region.cpp.
void PolyVox::Region::grow | ( | const Vector3DInt32 & | v3dAmount | ) |
Grows this region by the amounts specified.
The amount can be specified seperatly for each direction.
Negative growth is possible but you should prefer the shrink() function for clarity.
v3dAmount | The amount to grow by (one component for each direction). |
Definition at line 355 of file Region.cpp.
bool PolyVox::Region::isValid | ( | void | ) | const |
Tests whether all components of the upper corner are at least as great as the corresponding components of the lower corner.
Definition at line 362 of file Region.cpp.
Referenced by accumulate().
bool PolyVox::Region::operator!= | ( | const Region & | rhs | ) | const |
Inequality Operator.
Two regions are considered different if any of their extents differ.
rhs | The Region to compare to. |
Definition at line 156 of file Region.cpp.
bool PolyVox::Region::operator== | ( | const Region & | rhs | ) | const |
Equality Operator.
Two regions are considered equal if all their extents match.
rhs | The Region to compare to. |
Definition at line 144 of file Region.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Sets the position of the upper corner.
v3dUpperCorner | The new position of the upper corner. |
Definition at line 403 of file Region.h.
Referenced by PolyVox::MarchingCubesSurfaceExtractor< VolumeType, Controller >::MarchingCubesSurfaceExtractor().
|
inline |
|
inline |
|
inline |
void PolyVox::Region::shift | ( | const Vector3DInt32 & | v3dAmount | ) |
Moves the Region by the amount specified.
v3dAmount | The amount to move the Region by. |
Definition at line 381 of file Region.cpp.
Moves the lower corner of the Region by the amount specified.
iAmountX | The amount to move the lower corner by in 'x'. |
iAmountY | The amount to move the lower corner by in 'y'. |
iAmountZ | The amount to move the lower corner by in 'z'. |
Definition at line 392 of file Region.cpp.
Referenced by shift(), and shiftLowerCorner().
void PolyVox::Region::shiftLowerCorner | ( | const Vector3DInt32 & | v3dAmount | ) |
Moves the lower corner of the Region by the amount specified.
v3dAmount | The amount to move the lower corner by. |
Definition at line 402 of file Region.cpp.
Moves the upper corner of the Region by the amount specified.
iAmountX | The amount to move the upper corner by in 'x'. |
iAmountY | The amount to move the upper corner by in 'y'. |
iAmountZ | The amount to move the upper corner by in 'z'. |
Definition at line 412 of file Region.cpp.
Referenced by shift(), and shiftUpperCorner().
void PolyVox::Region::shiftUpperCorner | ( | const Vector3DInt32 & | v3dAmount | ) |
Moves the upper corner of the Region by the amount specified.
v3dAmount | The amount to move the upper corner by. |
Definition at line 422 of file Region.cpp.
void PolyVox::Region::shrink | ( | int32_t | iAmount | ) |
Shrinks this region by the amount specified.
The same amount of shrinkage is applied in all directions.
Negative shrinkage is possible but you should prefer the grow() function for clarity.
iAmount | The amount to shrink by. |
Definition at line 432 of file Region.cpp.
Referenced by shrink().
Shrinks this region by the amounts specified.
The amount can be specified seperatly for each direction.
Negative shrinkage is possible but you should prefer the grow() function for clarity.
iAmountX | The amount to shrink by in 'x'. |
iAmountY | The amount to shrink by in 'y'. |
iAmountZ | The amount to shrink by in 'z'. |
Definition at line 450 of file Region.cpp.
void PolyVox::Region::shrink | ( | const Vector3DInt32 & | v3dAmount | ) |
Shrinks this region by the amounts specified.
The amount can be specified seperatly for each direction.
Negative shrinkage is possible but you should prefer the grow() function for clarity.
v3dAmount | The amount to shrink by (one component for each direction). |
Definition at line 466 of file Region.cpp.
|
static |
A Region with the lower corner set as high as possible and the upper corner set as low as possible.
This Region is not considered valid as defined by isValid().
It's main application is to initialise a Region to this value and then() accumulate positions. The result of this will be a Region which encompasses all positions specified.
|
static |
A Region with the lower corner set as low as possible and the upper corner set as high as possible.
Definition at line 61 of file Region.h.
Referenced by PolyVox::LargeVolume< VoxelType >::LargeVolume().