Documentation of Region class.

This commit is contained in:
David Williams 2012-11-24 23:02:26 +01:00
parent 1b207325c4
commit e32d47ed8d
2 changed files with 122 additions and 25 deletions

View File

@ -86,22 +86,22 @@ namespace PolyVox
/// Gets the position of the upper corner. /// Gets the position of the upper corner.
Vector3DInt32 getUpperCorner(void) const; Vector3DInt32 getUpperCorner(void) const;
/// Gets the width of the region measured in voxels /// Gets the width of the region measured in voxels.
int32_t getWidthInVoxels(void) const; int32_t getWidthInVoxels(void) const;
/// Gets the height of the region measured in voxels /// Gets the height of the region measured in voxels.
int32_t getHeightInVoxels(void) const; int32_t getHeightInVoxels(void) const;
/// Gets the depth of the region measured in voxels /// Gets the depth of the region measured in voxels.
int32_t getDepthInVoxels(void) const; int32_t getDepthInVoxels(void) const;
/// Gets the dimensions of the region measured in voxels /// Gets the dimensions of the region measured in voxels.
Vector3DInt32 getDimensionsInVoxels(void) const; Vector3DInt32 getDimensionsInVoxels(void) const;
/// Gets the width of the region measured in cells /// Gets the width of the region measured in cells.
int32_t getWidthInCells(void) const; int32_t getWidthInCells(void) const;
/// Gets the height of the region measured in cells /// Gets the height of the region measured in cells.
int32_t getHeightInCells(void) const; int32_t getHeightInCells(void) const;
/// Gets the depth of the region measured in cells /// Gets the depth of the region measured in cells.
int32_t getDepthInCells(void) const; int32_t getDepthInCells(void) const;
/// Gets the dimensions of the region measured in cells /// Gets the dimensions of the region measured in cells.
Vector3DInt32 getDimensionsInCells(void) const; Vector3DInt32 getDimensionsInCells(void) const;
/// Sets the 'x' position of the lower corner. /// Sets the 'x' position of the lower corner.
@ -186,116 +186,193 @@ namespace PolyVox
// 'inline' keyword is used for the definition rather than the declaration. // 'inline' keyword is used for the definition rather than the declaration.
// See also http://www.parashift.com/c++-faq-lite/inline-functions.html // See also http://www.parashift.com/c++-faq-lite/inline-functions.html
////////////////////////////////////////////////////////////////////////////////
/// \return The 'x' position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getLowerX(void) const inline int32_t Region::getLowerX(void) const
{ {
return m_iLowerX; return m_iLowerX;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The 'y' position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getLowerY(void) const inline int32_t Region::getLowerY(void) const
{ {
return m_iLowerY; return m_iLowerY;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The 'z' position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getLowerZ(void) const inline int32_t Region::getLowerZ(void) const
{ {
return m_iLowerZ; return m_iLowerZ;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The 'x' position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getUpperX(void) const inline int32_t Region::getUpperX(void) const
{ {
return m_iUpperX; return m_iUpperX;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The 'y' position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getUpperY(void) const inline int32_t Region::getUpperY(void) const
{ {
return m_iUpperY; return m_iUpperY;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The 'z' position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getUpperZ(void) const inline int32_t Region::getUpperZ(void) const
{ {
return m_iUpperZ; return m_iUpperZ;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline Vector3DInt32 Region::getLowerCorner(void) const inline Vector3DInt32 Region::getLowerCorner(void) const
{ {
return Vector3DInt32(m_iLowerX, m_iLowerY, m_iLowerZ); return Vector3DInt32(m_iLowerX, m_iLowerY, m_iLowerZ);
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline Vector3DInt32 Region::getUpperCorner(void) const inline Vector3DInt32 Region::getUpperCorner(void) const
{ {
return Vector3DInt32(m_iUpperX, m_iUpperY, m_iUpperZ); return Vector3DInt32(m_iUpperX, m_iUpperY, m_iUpperZ);
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The width of the region measured in voxels.
/// \sa getWidthInCells()
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getWidthInVoxels(void) const inline int32_t Region::getWidthInVoxels(void) const
{ {
return getWidthInCells() + 1; return getWidthInCells() + 1;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The height of the region measured in voxels.
/// \sa getHeightInCells()
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getHeightInVoxels(void) const inline int32_t Region::getHeightInVoxels(void) const
{ {
return getHeightInCells() + 1; return getHeightInCells() + 1;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The depth of the region measured in voxels.
/// \sa getDepthInCells()
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getDepthInVoxels(void) const inline int32_t Region::getDepthInVoxels(void) const
{ {
return getDepthInCells() + 1; return getDepthInCells() + 1;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The dimensions of the region measured in voxels.
/// \sa getDimensionsInCells()
////////////////////////////////////////////////////////////////////////////////
inline Vector3DInt32 Region::getDimensionsInVoxels(void) const inline Vector3DInt32 Region::getDimensionsInVoxels(void) const
{ {
return getDimensionsInCells() + Vector3DInt32(1, 1, 1); return getDimensionsInCells() + Vector3DInt32(1, 1, 1);
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The width of the region measured in cells.
/// \sa getWidthInVoxels()
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getWidthInCells(void) const inline int32_t Region::getWidthInCells(void) const
{ {
return m_iUpperX - m_iLowerX; return m_iUpperX - m_iLowerX;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The height of the region measured in cells.
/// \sa getHeightInVoxels()
////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getHeightInCells(void) const inline int32_t Region::getHeightInCells(void) const
{ {
return m_iUpperY - m_iLowerY; return m_iUpperY - m_iLowerY;
} }
inline Vector3DInt32 Region::getDimensionsInCells(void) const ////////////////////////////////////////////////////////////////////////////////
{ /// \return The depth of the region measured in cells.
return Vector3DInt32(getWidthInCells(), getHeightInCells(), getDepthInCells()); /// \sa getDepthInVoxels()
} ////////////////////////////////////////////////////////////////////////////////
inline int32_t Region::getDepthInCells(void) const inline int32_t Region::getDepthInCells(void) const
{ {
return m_iUpperZ - m_iLowerZ; return m_iUpperZ - m_iLowerZ;
} }
////////////////////////////////////////////////////////////////////////////////
/// \return The dimensions of the region measured in cells.
/// \sa getDimensionsInVoxels()
////////////////////////////////////////////////////////////////////////////////
inline Vector3DInt32 Region::getDimensionsInCells(void) const
{
return Vector3DInt32(getWidthInCells(), getHeightInCells(), getDepthInCells());
}
////////////////////////////////////////////////////////////////////////////////
/// \param iX The new 'x' position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setLowerX(int32_t iX) inline void Region::setLowerX(int32_t iX)
{ {
m_iLowerX = iX; m_iLowerX = iX;
} }
////////////////////////////////////////////////////////////////////////////////
/// \param iY The new 'y' position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setLowerY(int32_t iY) inline void Region::setLowerY(int32_t iY)
{ {
m_iLowerY = iY; m_iLowerY = iY;
} }
////////////////////////////////////////////////////////////////////////////////
/// \param iZ The new 'z' position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setLowerZ(int32_t iZ) inline void Region::setLowerZ(int32_t iZ)
{ {
m_iLowerZ = iZ; m_iLowerZ = iZ;
} }
////////////////////////////////////////////////////////////////////////////////
/// \param iX The new 'x' position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setUpperX(int32_t iX) inline void Region::setUpperX(int32_t iX)
{ {
m_iUpperX = iX; m_iUpperX = iX;
} }
////////////////////////////////////////////////////////////////////////////////
/// \param iY The new 'y' position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setUpperY(int32_t iY) inline void Region::setUpperY(int32_t iY)
{ {
m_iUpperY = iY; m_iUpperY = iY;
} }
////////////////////////////////////////////////////////////////////////////////
/// \param iZ The new 'z' position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setUpperZ(int32_t iZ) inline void Region::setUpperZ(int32_t iZ)
{ {
m_iUpperZ = iZ; m_iUpperZ = iZ;
} }
////////////////////////////////////////////////////////////////////////////////
/// \param v3dLowerCorner The new position of the lower corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner) inline void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner)
{ {
m_iLowerX = v3dLowerCorner.getX(); m_iLowerX = v3dLowerCorner.getX();
@ -303,6 +380,9 @@ namespace PolyVox
m_iLowerZ = v3dLowerCorner.getZ(); m_iLowerZ = v3dLowerCorner.getZ();
} }
////////////////////////////////////////////////////////////////////////////////
/// \param v3dUpperCorner The new position of the upper corner.
////////////////////////////////////////////////////////////////////////////////
inline void Region::setUpperCorner(const Vector3DInt32& v3dUpperCorner) inline void Region::setUpperCorner(const Vector3DInt32& v3dUpperCorner)
{ {
m_iUpperX = v3dUpperCorner.getX(); m_iUpperX = v3dUpperCorner.getX();

View File

@ -39,6 +39,9 @@ namespace PolyVox
Vector3DInt32((std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)()) Vector3DInt32((std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)())
); );
////////////////////////////////////////////////////////////////////////////////
/// Constructs a Region and clears all extents to zero.
////////////////////////////////////////////////////////////////////////////////
Region::Region() Region::Region()
:m_iLowerX(0) :m_iLowerX(0)
,m_iLowerY(0) ,m_iLowerY(0)
@ -49,6 +52,11 @@ namespace PolyVox
{ {
} }
////////////////////////////////////////////////////////////////////////////////
/// Constructs a Region and sets the lower and upper corners to the specified values.
/// \param v3dLowerCorner The desired lower corner of the Region.
/// \param v3dUpperCorner The desired upper corner of the Region.
////////////////////////////////////////////////////////////////////////////////
Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner) Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner)
:m_iLowerX(v3dLowerCorner.getX()) :m_iLowerX(v3dLowerCorner.getX())
,m_iLowerY(v3dLowerCorner.getY()) ,m_iLowerY(v3dLowerCorner.getY())
@ -59,6 +67,15 @@ namespace PolyVox
{ {
} }
////////////////////////////////////////////////////////////////////////////////
/// Constructs a Region and sets the extents to the specified values.
/// \param iLowerX The desired lower 'x' extent of the Region.
/// \param iLowerY The desired lower 'y' extent of the Region.
/// \param iLowerZ The desired lower 'z' extent of the Region.
/// \param iUpperX The desired upper 'x' extent of the Region.
/// \param iUpperY The desired upper 'y' extent of the Region.
/// \param iUpperZ The desired upper 'z' extent of the Region.
////////////////////////////////////////////////////////////////////////////////
Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ) Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ)
:m_iLowerX(iLowerX) :m_iLowerX(iLowerX)
,m_iLowerY(iLowerY) ,m_iLowerY(iLowerY)
@ -69,24 +86,24 @@ namespace PolyVox
{ {
} }
/** ////////////////////////////////////////////////////////////////////////////////
Checks whether two Regions are equal. /// Two regions are considered equal if all their extents match.
\param rhs The Region to compare to. /// \param rhs The Region to compare to.
\return true if the Regions match. /// \return true if the Regions match.
\see operator!= /// \sa operator!=
*/ ////////////////////////////////////////////////////////////////////////////////
bool Region::operator==(const Region& rhs) const bool Region::operator==(const Region& rhs) const
{ {
return ((m_iLowerX == rhs.m_iLowerX) && (m_iLowerY == rhs.m_iLowerY) && (m_iLowerZ == rhs.m_iLowerZ) return ((m_iLowerX == rhs.m_iLowerX) && (m_iLowerY == rhs.m_iLowerY) && (m_iLowerZ == rhs.m_iLowerZ)
&& (m_iUpperX == rhs.m_iUpperX) && (m_iUpperY == rhs.m_iUpperY) && (m_iUpperZ == rhs.m_iUpperZ)); && (m_iUpperX == rhs.m_iUpperX) && (m_iUpperY == rhs.m_iUpperY) && (m_iUpperZ == rhs.m_iUpperZ));
} }
/** ////////////////////////////////////////////////////////////////////////////////
Checks whether two Regions are not equal. /// Two regions are considered different if any of their extents differ.
\param rhs The Region to compare to. /// \param rhs The Region to compare to.
\return true if the Regions do not match. /// \return true if the Regions are different.
\see operator== /// \sa operator==
*/ ////////////////////////////////////////////////////////////////////////////////
bool Region::operator!=(const Region& rhs) const bool Region::operator!=(const Region& rhs) const
{ {
return !(*this == rhs); return !(*this == rhs);