OpenVDB  12.0.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Coord Class Reference

Signed (x, y, z) 32-bit integer coordinates. More...

#include <openvdb/math/Coord.h>

Public Types

using Int32 = int32_t
 
using Index32 = uint32_t
 
using Vec3i = Vec3< Int32 >
 
using Vec3I = Vec3< Index32 >
 
using ValueType = Int32
 
using Limits = std::numeric_limits< ValueType >
 

Public Member Functions

 Coord ()
 
constexpr Coord (Int32 xyz)
 
constexpr Coord (Int32 x, Int32 y, Int32 z)
 
 Coord (const Vec3i &v)
 
 Coord (const Vec3I &v)
 
 Coord (const Int32 *v)
 
Coordreset (Int32 x, Int32 y, Int32 z)
 Reset all three coordinates with the specified arguments. More...
 
Coordreset (Int32 xyz)
 Reset all three coordinates with the same specified argument. More...
 
CoordsetX (Int32 x)
 
CoordsetY (Int32 y)
 
CoordsetZ (Int32 z)
 
Coordoffset (Int32 dx, Int32 dy, Int32 dz)
 
Coordoffset (Int32 n)
 
Coord offsetBy (Int32 dx, Int32 dy, Int32 dz) const
 
Coord offsetBy (Int32 n) const
 
Coordoperator+= (const Coord &rhs)
 
Coordoperator-= (const Coord &rhs)
 
Coord operator+ (const Coord &rhs) const
 
Coord operator- (const Coord &rhs) const
 
Coord operator- () const
 
Coord operator>> (size_t n) const
 
Coord operator<< (size_t n) const
 
Coordoperator<<= (size_t n)
 
Coordoperator>>= (size_t n)
 
Coord operator& (Int32 n) const
 
Coord operator| (Int32 n) const
 
Coordoperator&= (Int32 n)
 
Coordoperator|= (Int32 n)
 
Int32 x () const
 
Int32 y () const
 
Int32 z () const
 
Int32 operator[] (size_t i) const
 
Int32x ()
 
Int32y ()
 
Int32z ()
 
Int32operator[] (size_t i)
 
const Int32data () const
 
Int32data ()
 
const Int32asPointer () const
 
Int32asPointer ()
 
Vec3d asVec3d () const
 
Vec3s asVec3s () const
 
Vec3i asVec3i () const
 
Vec3I asVec3I () const
 
void asXYZ (Int32 &x, Int32 &y, Int32 &z) const
 
bool operator== (const Coord &rhs) const
 
bool operator!= (const Coord &rhs) const
 
bool operator< (const Coord &rhs) const
 Lexicographic less than. More...
 
bool operator<= (const Coord &rhs) const
 Lexicographic less than or equal to. More...
 
bool operator> (const Coord &rhs) const
 Lexicographic greater than. More...
 
bool operator>= (const Coord &rhs) const
 Lexicographic greater than or equal to. More...
 
void minComponent (const Coord &other)
 Perform a component-wise minimum with the other Coord. More...
 
void maxComponent (const Coord &other)
 Perform a component-wise maximum with the other Coord. More...
 
size_t minIndex () const
 Return the index (0, 1 or 2) with the smallest value. More...
 
size_t maxIndex () const
 Return the index (0, 1 or 2) with the largest value. More...
 
void read (std::istream &is)
 
void write (std::ostream &os) const
 
template<int Log2N = 20>
size_t hash () const
 Return a hash value for this coordinate. More...
 

Static Public Member Functions

static Coord min ()
 Return the smallest possible coordinate. More...
 
static Coord max ()
 Return the largest possible coordinate. More...
 
template<typename T >
static Coord round (const Vec3< T > &xyz)
 Return xyz rounded to the closest integer coordinates (cell centered conversion). More...
 
template<typename T >
static Coord floor (const Vec3< T > &xyz)
 Return the largest integer coordinates that are not greater than xyz (node centered conversion). More...
 
template<typename T >
static Coord ceil (const Vec3< T > &xyz)
 Return the largest integer coordinates that are not greater than xyz+1 (node centered conversion). More...
 
static Coord minComponent (const Coord &lhs, const Coord &rhs)
 Return the component-wise minimum of the two Coords. More...
 
static Coord maxComponent (const Coord &lhs, const Coord &rhs)
 Return the component-wise maximum of the two Coords. More...
 
static bool lessThan (const Coord &a, const Coord &b)
 

Detailed Description

Signed (x, y, z) 32-bit integer coordinates.

Member Typedef Documentation

using Index32 = uint32_t
using Int32 = int32_t
using Limits = std::numeric_limits<ValueType>
using ValueType = Int32
using Vec3i = Vec3<Int32>
using Vec3I = Vec3<Index32>

Constructor & Destructor Documentation

Coord ( )
inline
constexpr Coord ( Int32  xyz)
inlineexplicit
constexpr Coord ( Int32  x,
Int32  y,
Int32  z 
)
inline
Coord ( const Vec3i v)
inlineexplicit
Coord ( const Vec3I v)
inlineexplicit
Coord ( const Int32 v)
inlineexplicit

Member Function Documentation

const Int32* asPointer ( ) const
inline
Int32* asPointer ( )
inline
Vec3d asVec3d ( ) const
inline
Vec3i asVec3i ( ) const
inline
Vec3I asVec3I ( ) const
inline
Vec3s asVec3s ( ) const
inline
void asXYZ ( Int32 x,
Int32 y,
Int32 z 
) const
inline
static Coord ceil ( const Vec3< T > &  xyz)
inlinestatic

Return the largest integer coordinates that are not greater than xyz+1 (node centered conversion).

const Int32* data ( ) const
inline
Int32* data ( )
inline
static Coord floor ( const Vec3< T > &  xyz)
inlinestatic

Return the largest integer coordinates that are not greater than xyz (node centered conversion).

size_t hash ( ) const
inline

Return a hash value for this coordinate.

Note
Log2N is the binary logarithm of the hash table size.

The hash function is originally taken from the SIGGRAPH paper: "VDB: High-resolution sparse volumes with dynamic topology" and the prime numbers are modified based on the ACM Transactions on Graphics paper: "Real-time 3D reconstruction at scale using voxel hashing"

static bool lessThan ( const Coord a,
const Coord b 
)
inlinestatic

Return true if any of the components of a are smaller than the corresponding components of b.

static Coord max ( )
inlinestatic

Return the largest possible coordinate.

void maxComponent ( const Coord other)
inline

Perform a component-wise maximum with the other Coord.

static Coord maxComponent ( const Coord lhs,
const Coord rhs 
)
inlinestatic

Return the component-wise maximum of the two Coords.

size_t maxIndex ( ) const
inline

Return the index (0, 1 or 2) with the largest value.

static Coord min ( )
inlinestatic

Return the smallest possible coordinate.

void minComponent ( const Coord other)
inline

Perform a component-wise minimum with the other Coord.

static Coord minComponent ( const Coord lhs,
const Coord rhs 
)
inlinestatic

Return the component-wise minimum of the two Coords.

size_t minIndex ( ) const
inline

Return the index (0, 1 or 2) with the smallest value.

Coord& offset ( Int32  dx,
Int32  dy,
Int32  dz 
)
inline
Coord& offset ( Int32  n)
inline
Coord offsetBy ( Int32  dx,
Int32  dy,
Int32  dz 
) const
inline
Coord offsetBy ( Int32  n) const
inline
bool operator!= ( const Coord rhs) const
inline
Coord operator& ( Int32  n) const
inline
Coord& operator&= ( Int32  n)
inline
Coord operator+ ( const Coord rhs) const
inline
Coord& operator+= ( const Coord rhs)
inline
Coord operator- ( const Coord rhs) const
inline
Coord operator- ( ) const
inline
Coord& operator-= ( const Coord rhs)
inline
bool operator< ( const Coord rhs) const
inline

Lexicographic less than.

Coord operator<< ( size_t  n) const
inline
Coord& operator<<= ( size_t  n)
inline
bool operator<= ( const Coord rhs) const
inline

Lexicographic less than or equal to.

bool operator== ( const Coord rhs) const
inline
bool operator> ( const Coord rhs) const
inline

Lexicographic greater than.

bool operator>= ( const Coord rhs) const
inline

Lexicographic greater than or equal to.

Coord operator>> ( size_t  n) const
inline
Coord& operator>>= ( size_t  n)
inline
Int32 operator[] ( size_t  i) const
inline
Int32& operator[] ( size_t  i)
inline
Coord operator| ( Int32  n) const
inline
Coord& operator|= ( Int32  n)
inline
void read ( std::istream &  is)
inline
Coord& reset ( Int32  x,
Int32  y,
Int32  z 
)
inline

Reset all three coordinates with the specified arguments.

Coord& reset ( Int32  xyz)
inline

Reset all three coordinates with the same specified argument.

static Coord round ( const Vec3< T > &  xyz)
inlinestatic

Return xyz rounded to the closest integer coordinates (cell centered conversion).

Coord& setX ( Int32  x)
inline
Coord& setY ( Int32  y)
inline
Coord& setZ ( Int32  z)
inline
void write ( std::ostream &  os) const
inline
Int32 x ( ) const
inline
Int32& x ( )
inline
Int32 y ( ) const
inline
Int32& y ( )
inline
Int32 z ( ) const
inline
Int32& z ( )
inline