OpenWalnut
1.5.0dev
|
A grid that has parallelepiped cells which all have the same proportion. More...
#include <WGridRegular3D.h>
Public Types | |
typedef WMatrixFixed< T, 3, 1 > | Vector3Type |
Convenience typedef for 3d vectors of the appropriate numerical type. More... | |
typedef std::shared_ptr< WGridRegular3DTemplate > | SPtr |
Convenience typedef for a std::shared_ptr< WGridRegular3DTemplate >. More... | |
typedef std::shared_ptr< const WGridRegular3DTemplate > | ConstSPtr |
Convenience typedef for a std::shared_ptr< const WGridRegular3DTemplate >. More... | |
typedef boost::array< size_t, 8 > | CellVertexArray |
Convenience typedef for a boost::array< size_t, 8 >. More... | |
Public Member Functions | |
template<typename InputType > | |
WGridRegular3DTemplate (WGridRegular3DTemplate< InputType > const &rhs) | |
Copy constructor. More... | |
WGridRegular3DTemplate (unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ, WGridTransformOrthoTemplate< T > const transform=WGridTransformOrthoTemplate< T >()) | |
Defines the number of samples in each coordinate direction as ints, and the transformation of the grid via a grid transform. More... | |
WGridRegular3DTemplate (unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ, double scaleX, double scaleY, double scaleZ) | |
Defines the number of samples in each coordinate direction as ints, and the transformation of the grid via a grid transform. More... | |
unsigned int | getNbCoordsX () const |
Returns the number of samples in x direction. More... | |
unsigned int | getNbCoordsY () const |
Returns the number of samples in y direction. More... | |
unsigned int | getNbCoordsZ () const |
Returns the number of samples in z direction. More... | |
T | getOffsetX () const |
Returns the distance between samples in x direction. More... | |
T | getOffsetY () const |
Returns the distance between samples in y direction. More... | |
T | getOffsetZ () const |
Returns the distance between samples in z direction. More... | |
Vector3Type | getDirectionX () const |
Returns the vector determining the direction of samples in x direction. More... | |
Vector3Type | getDirectionY () const |
Returns the vector determining the direction of samples in y direction. More... | |
Vector3Type | getDirectionZ () const |
Returns the vector determining the direction of samples in z direction. More... | |
Vector3Type | getUnitDirectionX () const |
Returns the vector determining the unit (normalized) direction of samples in x direction. More... | |
Vector3Type | getUnitDirectionY () const |
Returns the vector determining the unit (normalized) direction of samples in y direction. More... | |
Vector3Type | getUnitDirectionZ () const |
Returns the vector determining the unit (normalized) direction of samples in z direction. More... | |
Vector3Type | getOrigin () const |
Returns the position of the origin of the grid. More... | |
WMatrix< T > | getTransformationMatrix () const |
Returns a 4x4 matrix that represents the grid's transformation. More... | |
WBoundingBox | getBoundingBox () const |
Axis aligned Bounding Box that encloses this grid. More... | |
WBoundingBox | getBoundingBoxIncludingBorder () const |
Calculates the bounding box but includes the border voxel associated cell too. More... | |
WBoundingBox | getVoxelBoundingBox () const |
Calculate the bounding box in voxel space. More... | |
Vector3Type | getPosition (unsigned int i) const |
Returns the i-th position on the grid. More... | |
Vector3Type | getPosition (unsigned int iX, unsigned int iY, unsigned int iZ) const |
Returns the position that is the iX-th in x direction, the iY-th in y direction and the iZ-th in z direction. More... | |
Vector3Type | worldCoordToTexCoord (Vector3Type point) |
Transforms world coordinates to texture coordinates. More... | |
int | getVoxelNum (const Vector3Type &pos) const |
Returns the i'th voxel where the given position belongs too. More... | |
int | getVoxelNum (const size_t x, const size_t y, const size_t z) const |
returns the voxel index for a given discrete position in the grid More... | |
int | getXVoxelCoord (const Vector3Type &pos) const |
Computes the X coordinate of that voxel that contains the position pos. More... | |
int | getYVoxelCoord (const Vector3Type &pos) const |
Computes the Y coordinate of that voxel that contains the position pos. More... | |
int | getZVoxelCoord (const Vector3Type &pos) const |
Computes the Z coordinate of that voxel that contains the position pos. More... | |
WVector3i | getVoxelCoord (const Vector3Type &pos) const |
Computes the voxel coordinates of that voxel which contains the position pos. More... | |
size_t | getCellId (const Vector3Type &pos, bool *success) const |
Computes the id of the cell containing the position pos. More... | |
CellVertexArray | getCellVertexIds (size_t cellId) const |
Computes the ids of the vertices of a cell given by its id. More... | |
std::shared_ptr< std::vector< Vector3Type > > | getVoxelVertices (const Vector3Type &point, const T margin=0.0) const |
Computes the vertices for a voxel cuboid around the given point: More... | |
std::vector< size_t > | getNeighbours (size_t id) const |
Return the list of neighbour voxels. More... | |
std::vector< size_t > | getNeighbours27 (size_t id) const |
Return the list of all neighbour voxels. More... | |
std::vector< size_t > | getNeighboursRange (size_t id, size_t range) const |
Return the list of all neighbour voxels. More... | |
std::vector< size_t > | getNeighbours9XY (size_t id) const |
Return the list of all neighbour voxels. More... | |
std::vector< size_t > | getNeighbours9YZ (size_t id) const |
Return the list of all neighbour voxels. More... | |
std::vector< size_t > | getNeighbours9XZ (size_t id) const |
Return the list of all neighbour voxels. More... | |
bool | encloses (const Vector3Type &pos) const |
Decides whether a certain position is inside this grid or not. More... | |
bool | isNotRotated () const |
Return whether the transformations of the grid are only translation and/or scaling. More... | |
WGridTransformOrthoTemplate< T > const | getTransform () const |
Returns the transformation used by this grid. More... | |
bool | operator== (const WGridRegular3DTemplate< T > &other) const |
Compares two grids. More... | |
Public Member Functions inherited from WGrid | |
WGrid (size_t size) | |
Constructs a new WGrid instance. More... | |
virtual | ~WGrid () |
Since WGrid is a base class and thus should be polymorphic we add virtual destructor. More... | |
size_t | size () const |
The number of positions in this grid. More... | |
std::shared_ptr< WPropertyGroup > | getInformationProperties () const |
Returns a pointer to the information properties object of the grid. More... | |
Private Member Functions | |
int | getNVoxelCoord (const Vector3Type &pos, size_t axis) const |
Computes for the n'th component of the voxel coordinate where the voxel contains the position pos. More... | |
void | initInformationProperties () |
Adds the specific information of this grid type to the informational properties. More... | |
Private Attributes | |
unsigned int | m_nbPosX |
Number of positions in x direction. More... | |
unsigned int | m_nbPosY |
Number of positions in y direction. More... | |
unsigned int | m_nbPosZ |
Number of positions in z direction. More... | |
WGridTransformOrthoTemplate< T > const | m_transform |
The grid's transformation. More... | |
Friends | |
template<class U > | |
class | WGridRegular3DTemplate |
this (friend) is necessary to allow casting More... | |
class | WGridRegular3DTest |
Only test are allowed as friends. More... | |
Additional Inherited Members | |
Protected Attributes inherited from WGrid | |
std::shared_ptr< WPropertyGroup > | m_infoProperties |
The property object for the grid containing only props whose purpose is "PV_PURPOSE_INFORMNATION". More... | |
A grid that has parallelepiped cells which all have the same proportion.
I.e. the samples along a single axis are equidistant. The distance of samples may vary between axes.
Definition at line 58 of file WGridRegular3D.h.
typedef boost::array< size_t, 8 > WGridRegular3DTemplate< T >::CellVertexArray |
Convenience typedef for a boost::array< size_t, 8 >.
Return type of getCellVertexIds.
Definition at line 86 of file WGridRegular3D.h.
typedef std::shared_ptr< const WGridRegular3DTemplate > WGridRegular3DTemplate< T >::ConstSPtr |
Convenience typedef for a std::shared_ptr< const WGridRegular3DTemplate >.
Definition at line 81 of file WGridRegular3D.h.
typedef std::shared_ptr< WGridRegular3DTemplate > WGridRegular3DTemplate< T >::SPtr |
Convenience typedef for a std::shared_ptr< WGridRegular3DTemplate >.
Definition at line 76 of file WGridRegular3D.h.
typedef WMatrixFixed< T, 3, 1 > WGridRegular3DTemplate< T >::Vector3Type |
Convenience typedef for 3d vectors of the appropriate numerical type.
Definition at line 71 of file WGridRegular3D.h.
WGridRegular3DTemplate< T >::WGridRegular3DTemplate | ( | WGridRegular3DTemplate< InputType > const & | rhs | ) |
Copy constructor.
Copies the data from an WGridRegular3DTemplate object with arbitary numerical type.
rhs | A WGridRegular3DTemplate object, which mustn't have the same numerical type. |
Definition at line 550 of file WGridRegular3D.h.
References WGridRegular3DTemplate< T >::initInformationProperties().
WGridRegular3DTemplate< T >::WGridRegular3DTemplate | ( | unsigned int | nbPosX, |
unsigned int | nbPosY, | ||
unsigned int | nbPosZ, | ||
WGridTransformOrthoTemplate< T > const | transform = WGridTransformOrthoTemplate< T >() |
||
) |
Defines the number of samples in each coordinate direction as ints, and the transformation of the grid via a grid transform.
nbPosX | number of positions along first axis |
nbPosY | number of positions along second axis |
nbPosZ | number of positions along third axis |
transform | a grid transformation |
Definition at line 561 of file WGridRegular3D.h.
References WGridRegular3DTemplate< T >::initInformationProperties().
WGridRegular3DTemplate< T >::WGridRegular3DTemplate | ( | unsigned int | nbPosX, |
unsigned int | nbPosY, | ||
unsigned int | nbPosZ, | ||
double | scaleX, | ||
double | scaleY, | ||
double | scaleZ | ||
) |
Defines the number of samples in each coordinate direction as ints, and the transformation of the grid via a grid transform.
nbPosX | number of positions along first axis |
nbPosY | number of positions along second axis |
nbPosZ | number of positions along third axis |
scaleX | scaling of a voxel in x direction |
scaleY | scaling of a voxel in y direction |
scaleZ | scaling of a voxel in z direction |
Definition at line 573 of file WGridRegular3D.h.
References WGridRegular3DTemplate< T >::initInformationProperties().
|
inline |
Decides whether a certain position is inside this grid or not.
pos | Position to test |
Definition at line 1222 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testEnclosesQuery(), and WGridRegular3DTest::testEnclosesRotated().
|
inlinevirtual |
Axis aligned Bounding Box that encloses this grid.
Implements WGrid.
Definition at line 669 of file WGridRegular3D.h.
References WBoundingBoxImpl< VT >::expandBy().
|
inline |
Calculates the bounding box but includes the border voxel associated cell too.
Definition at line 684 of file WGridRegular3D.h.
References WBoundingBoxImpl< VT >::expandBy().
|
inline |
Computes the id of the cell containing the position pos.
Note that the upper bound of the grid does not belong to any cell
pos | The position selecting the cell. |
success | True if the position pos is inside the grid. |
Definition at line 829 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testGetCellId().
|
inline |
Computes the ids of the vertices of a cell given by its id.
cellId | The id of the cell we want to know ther vertices of. |
z-axis y-axis | / | 6___/_7 |/: /| 4_:___5 | | :...|.| |.2 | 3 |_____|/ ____x-axis 0 1
Definition at line 843 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testGetCellVertexIds().
|
inline |
Returns the vector determining the direction of samples in x direction.
Adding this vector to a grid position in world coordinates yields the position of the next sample along the grids (world coordinate) x-axis.
Definition at line 621 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testOrientation().
|
inline |
Returns the vector determining the direction of samples in y direction.
Adding this vector to a grid position in world coordinates yields the position of the next sample along the grids (world coordinate) y-axis.
Definition at line 627 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testOrientation().
|
inline |
Returns the vector determining the direction of samples in z direction.
Adding this vector to a grid position in world coordinates yields the position of the next sample along the grids (world coordinate) z-axis.
Definition at line 633 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testOrientation().
|
inline |
Returns the number of samples in x direction.
Definition at line 585 of file WGridRegular3D.h.
Referenced by WGridRegular3DTemplate< T >::operator==(), and WGridRegular3DTest::testGetNbCoords().
|
inline |
Returns the number of samples in y direction.
Definition at line 591 of file WGridRegular3D.h.
Referenced by WGridRegular3DTemplate< T >::operator==(), and WGridRegular3DTest::testGetNbCoords().
|
inline |
Returns the number of samples in z direction.
Definition at line 597 of file WGridRegular3D.h.
Referenced by WGridRegular3DTemplate< T >::operator==(), and WGridRegular3DTest::testGetNbCoords().
std::vector< size_t > WGridRegular3DTemplate< T >::getNeighbours | ( | size_t | id | ) | const |
Return the list of neighbour voxels.
WOutOfBounds | If the voxel id is outside of the grid. |
id | Number of the voxel for which the neighbours should be computed |
Definition at line 885 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testNeighbourOfVoxelNotInsideThisGrid(), WGridRegular3DTest::testNeighbourOnBackUpperRight(), WGridRegular3DTest::testNeighbourOnLeftBorderPlane(), WGridRegular3DTest::testNeighboursInsideAGrid(), and WGridRegular3DTest::testNeighboursOnFrontLowerLeft().
std::vector< size_t > WGridRegular3DTemplate< T >::getNeighbours27 | ( | size_t | id | ) | const |
Return the list of all neighbour voxels.
WOutOfBounds | If the voxel id is outside of the grid. |
id | Number of the voxel for which the neighbours should be computed |
Definition at line 930 of file WGridRegular3D.h.
std::vector< size_t > WGridRegular3DTemplate< T >::getNeighbours9XY | ( | size_t | id | ) | const |
Return the list of all neighbour voxels.
WOutOfBounds | If the voxel id is outside of the grid. |
id | Number of the voxel for which the neighbours should be computed |
Definition at line 1031 of file WGridRegular3D.h.
std::vector< size_t > WGridRegular3DTemplate< T >::getNeighbours9XZ | ( | size_t | id | ) | const |
Return the list of all neighbour voxels.
WOutOfBounds | If the voxel id is outside of the grid. |
id | Number of the voxel for which the neighbours should be computed |
Definition at line 1158 of file WGridRegular3D.h.
std::vector< size_t > WGridRegular3DTemplate< T >::getNeighbours9YZ | ( | size_t | id | ) | const |
Return the list of all neighbour voxels.
WOutOfBounds | If the voxel id is outside of the grid. |
id | Number of the voxel for which the neighbours should be computed |
Definition at line 1094 of file WGridRegular3D.h.
std::vector< size_t > WGridRegular3DTemplate< T >::getNeighboursRange | ( | size_t | id, |
size_t | range | ||
) | const |
Return the list of all neighbour voxels.
WOutOfBounds | If the voxel id is outside of the grid. |
id | Number of the voxel for which the neighbours should be computed |
range | neighborhood range selected. It specifies the distance to count as neighbour in each direction. |
Definition at line 990 of file WGridRegular3D.h.
|
private |
Computes for the n'th component of the voxel coordinate where the voxel contains the position pos.
pos | The position for which the n'th component of the voxel coordinates should be computed. |
axis | The number of the component. (0 == x-axis, 1 == y-axis, ...) |
|
inline |
Returns the distance between samples in x direction.
Definition at line 603 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testGetVectorOffset().
|
inline |
Returns the distance between samples in y direction.
Definition at line 609 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testGetVectorOffset().
|
inline |
Returns the distance between samples in z direction.
Definition at line 615 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testGetVectorOffset().
|
inline |
Returns the position of the origin of the grid.
Definition at line 657 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testOrientation().
|
inline |
Returns the i-th position on the grid.
i | id of position to be obtained |
Definition at line 714 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testGetPositionScalarOffset().
|
inline |
Returns the position that is the iX-th in x direction, the iY-th in y direction and the iZ-th in z direction.
iX | id along first axis of position to be obtained |
iY | id along second axis of position to be obtained |
iZ | id along third axis of position to be obtained |
Definition at line 720 of file WGridRegular3D.h.
|
inline |
Returns the transformation used by this grid.
Definition at line 1248 of file WGridRegular3D.h.
|
inline |
Returns a 4x4 matrix that represents the grid's transformation.
Definition at line 663 of file WGridRegular3D.h.
|
inline |
Returns the vector determining the unit (normalized) direction of samples in x direction.
Definition at line 639 of file WGridRegular3D.h.
|
inline |
Returns the vector determining the unit (normalized) direction of samples in y direction.
Definition at line 645 of file WGridRegular3D.h.
|
inline |
Returns the vector determining the unit (normalized) direction of samples in z direction.
Definition at line 651 of file WGridRegular3D.h.
|
inline |
Calculate the bounding box in voxel space.
In contrast to the cell bounding box, this includes the space of the last voxel in each direction.
Definition at line 699 of file WGridRegular3D.h.
References WBoundingBoxImpl< VT >::expandBy().
|
inline |
Computes the voxel coordinates of that voxel which contains the position pos.
pos | The position selecting the voxel. |
Definition at line 819 of file WGridRegular3D.h.
|
inline |
returns the voxel index for a given discrete position in the grid
x | Position for which we want to have the voxel number. |
y | Position for which we want to have the voxel number. |
z | Position for which we want to have the voxel number. |
Definition at line 773 of file WGridRegular3D.h.
|
inline |
Returns the i'th voxel where the given position belongs too.
A voxel is a cuboid which surrounds a point on the grid.
Voxel: ______________ ____ (0.5, 0.5, 0.5) /: /| / : / | / : / | / : / | _/____:_ ___ __/ | | : | | | : *<--|--------- grid point (0, 0, 0) | :........|....|__ dz == 1| / | / | / | / dy == 1 | / | / _|/____________|/__ |<- dx == 1 ->| -0.5,-0.5,-0.5
Please note the first voxel has only 1/8 of the size a normal voxel would have since all positions outside the grid do not belong to any voxel. Note: a cell is different to a voxel in terms of position. A voxel has a grid point as center whereas a cell has grid points as corners.
pos | Position for which we want to have the voxel number. |
Definition at line 747 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testGetVoxelNumberOfPositionExactlyBetweenVoxels().
std::shared_ptr< std::vector< typename WGridRegular3DTemplate< T >::Vector3Type > > WGridRegular3DTemplate< T >::getVoxelVertices | ( | const Vector3Type & | point, |
const T | margin = 0.0 |
||
) | const |
Computes the vertices for a voxel cuboid around the given point:
z-axis y-axis | / | h___/_g |/: /| d_:___c | | :...|.| |.e | f |_____|/ ____x-axis a b
As you can see the order of the points is: a, b, c, d, e, f, g, h.
point | Center of the cuboid which must not necesarrily be a point of the grid. |
margin | If you need to shrink the Voxel put here the delta > 0. |
Definition at line 865 of file WGridRegular3D.h.
|
inline |
Computes the X coordinate of that voxel that contains the position pos.
pos | The position which selects the voxel for which the X coordinate is computed. |
Definition at line 784 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testRotatedVoxelNum(), and WGridRegular3DTest::testRotatedVoxelOutOfGrid().
|
inline |
Computes the Y coordinate of that voxel that contains the position pos.
pos | The position which selects the voxel for which the Y coordinate is computed. |
Definition at line 797 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testRotatedVoxelNum(), and WGridRegular3DTest::testRotatedVoxelOutOfGrid().
|
inline |
Computes the Z coordinate of that voxel that contains the position pos.
pos | The position which selects the voxel for which the Z coordinate is computed. |
Definition at line 808 of file WGridRegular3D.h.
Referenced by WGridRegular3DTest::testRotatedVoxelNum(), and WGridRegular3DTest::testRotatedVoxelOutOfGrid().
|
private |
Adds the specific information of this grid type to the informational properties.
Definition at line 1254 of file WGridRegular3D.h.
Referenced by WGridRegular3DTemplate< T >::WGridRegular3DTemplate().
|
inline |
Return whether the transformations of the grid are only translation and/or scaling.
Definition at line 1242 of file WGridRegular3D.h.
bool WGridRegular3DTemplate< T >::operator== | ( | const WGridRegular3DTemplate< T > & | other | ) | const |
Compares two grids.
Matches the transform and x,y,z resolution.
other | the one to compare against |
Definition at line 1278 of file WGridRegular3D.h.
References WGridRegular3DTemplate< T >::getNbCoordsX(), WGridRegular3DTemplate< T >::getNbCoordsY(), WGridRegular3DTemplate< T >::getNbCoordsZ(), and WGridRegular3DTemplate< T >::m_transform.
|
inline |
Transforms world coordinates to texture coordinates.
point | The point with these coordinates will be transformed. |
Definition at line 729 of file WGridRegular3D.h.
this (friend) is necessary to allow casting
Definition at line 62 of file WGridRegular3D.h.
|
friend |
Only test are allowed as friends.
Definition at line 66 of file WGridRegular3D.h.
|
private |
Number of positions in x direction.
Definition at line 535 of file WGridRegular3D.h.
|
private |
Number of positions in y direction.
Definition at line 536 of file WGridRegular3D.h.
|
private |
Number of positions in z direction.
Definition at line 537 of file WGridRegular3D.h.
|
private |
The grid's transformation.
Definition at line 540 of file WGridRegular3D.h.
Referenced by WGridRegular3DTemplate< T >::operator==().