OpenVDB 13.1.0
Loading...
Searching...
No Matches
Coord Class Reference

Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord. More...

#include <nanovdb/math/Math.h>

Public Types

using ValueType = int32_t
using IndexType = uint32_t

Public Member Functions

__hostdev__ Coord ()
 Initialize all coordinates to zero.
__hostdev__ Coord (ValueType n)
 Initializes all coordinates to the given signed integer.
__hostdev__ Coord (ValueType i, ValueType j, ValueType k)
 Initializes coordinate to the given signed integers.
__hostdev__ Coord (ValueType *ptr)
__hostdev__ int32_t x () const
__hostdev__ int32_t & x ()
__hostdev__ int32_t y () const
__hostdev__ int32_t & y ()
__hostdev__ int32_t z () const
__hostdev__ int32_t & z ()
__hostdev__ const ValueTypeoperator[] (IndexType i) const
 Return a const reference to the given Coord component.
__hostdev__ ValueTypeoperator[] (IndexType i)
 Return a non-const reference to the given Coord component.
template<typename CoordT>
__hostdev__ Coordoperator= (const CoordT &other)
 Assignment operator that works with openvdb::Coord.
__hostdev__ Coord operator& (IndexType n) const
 Return a new instance with coordinates masked by the given unsigned integer.
__hostdev__ Coord operator<< (IndexType n) const
__hostdev__ Coord operator>> (IndexType n) const
__hostdev__ bool operator< (const Coord &rhs) const
 Return true if this Coord is lexicographically less than the given Coord.
__hostdev__ bool operator<= (const Coord &rhs) const
 Return true if this Coord is lexicographically less or equal to the given Coord.
__hostdev__ bool operator> (const Coord &rhs) const
__hostdev__ bool operator>= (const Coord &rhs) const
__hostdev__ bool operator== (const Coord &rhs) const
__hostdev__ bool operator!= (const Coord &rhs) const
__hostdev__ Coordoperator&= (int n)
__hostdev__ Coordoperator<<= (uint32_t n)
__hostdev__ Coordoperator>>= (uint32_t n)
__hostdev__ Coordoperator+= (int n)
__hostdev__ Coordoperator+= (const Coord &rhs)
__hostdev__ Coord operator+ (const Coord &rhs) const
__hostdev__ Coord operator- (const Coord &rhs) const
__hostdev__ Coord operator- () const
__hostdev__ Coordoperator-= (const Coord &rhs)
__hostdev__ CoordminComponent (const Coord &other)
 Perform a component-wise minimum with the other Coord.
__hostdev__ CoordmaxComponent (const Coord &other)
 Perform a component-wise maximum with the other Coord.
__hostdev__ Coord offsetBy (ValueType dx, ValueType dy, ValueType dz) const
__hostdev__ Coord offsetBy (ValueType n) const
template<int Log2N = 3 + 4 + 5>
__hostdev__ uint32_t hash () const
 Return a hash key derived from the existing coordinates.
__hostdev__ uint8_t octant () const
 Return the octant of this Coord.
__hostdev__ Vec3< float > asVec3s () const
 Return a single precision floating-point vector of this coordinate.
__hostdev__ Vec3< double > asVec3d () const
 Return a double precision floating-point vector of this coordinate.
__hostdev__ Coord round () const

Static Public Member Functions

static __hostdev__ Coord max ()
static __hostdev__ Coord min ()
static __hostdev__ size_t memUsage ()
static __hostdev__ bool lessThan (const Coord &a, const Coord &b)
template<typename Vec3T>
static __hostdev__ Coord Floor (const Vec3T &xyz)
 Return the largest integer coordinates that are not greater than xyz (node centered conversion).

Detailed Description

Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.

Member Typedef Documentation

◆ IndexType

using IndexType = uint32_t

◆ ValueType

using ValueType = int32_t

Constructor & Destructor Documentation

◆ Coord() [1/4]

__hostdev__ Coord ( )
inline

Initialize all coordinates to zero.

◆ Coord() [2/4]

__hostdev__ Coord ( ValueType n)
inlineexplicit

Initializes all coordinates to the given signed integer.

◆ Coord() [3/4]

Initializes coordinate to the given signed integers.

◆ Coord() [4/4]

__hostdev__ Coord ( ValueType * ptr)
inline

Member Function Documentation

◆ asVec3d()

__hostdev__ Vec3< double > asVec3d ( ) const
inline

Return a double precision floating-point vector of this coordinate.

◆ asVec3s()

__hostdev__ Vec3< float > asVec3s ( ) const
inline

Return a single precision floating-point vector of this coordinate.

◆ Floor()

template<typename Vec3T>
__hostdev__ Coord Floor ( const Vec3T & xyz)
inlinestatic

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

◆ hash()

template<int Log2N = 3 + 4 + 5>
__hostdev__ uint32_t hash ( ) const
inline

Return a hash key derived from the existing coordinates.

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" (the second number had a typo!)

◆ lessThan()

__hostdev__ 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.

◆ max()

__hostdev__ Coord max ( )
inlinestatic

◆ maxComponent()

__hostdev__ Coord & maxComponent ( const Coord & other)
inline

Perform a component-wise maximum with the other Coord.

◆ memUsage()

__hostdev__ size_t memUsage ( )
inlinestatic

◆ min()

__hostdev__ Coord min ( )
inlinestatic

◆ minComponent()

__hostdev__ Coord & minComponent ( const Coord & other)
inline

Perform a component-wise minimum with the other Coord.

◆ octant()

__hostdev__ uint8_t octant ( ) const
inline

Return the octant of this Coord.

◆ offsetBy() [1/2]

__hostdev__ Coord offsetBy ( ValueType dx,
ValueType dy,
ValueType dz ) const
inline

◆ offsetBy() [2/2]

__hostdev__ Coord offsetBy ( ValueType n) const
inline

◆ operator!=()

__hostdev__ bool operator!= ( const Coord & rhs) const
inline

◆ operator&()

__hostdev__ Coord operator& ( IndexType n) const
inline

Return a new instance with coordinates masked by the given unsigned integer.

◆ operator&=()

__hostdev__ Coord & operator&= ( int n)
inline

◆ operator+()

__hostdev__ Coord operator+ ( const Coord & rhs) const
inline

◆ operator+=() [1/2]

__hostdev__ Coord & operator+= ( const Coord & rhs)
inline

◆ operator+=() [2/2]

__hostdev__ Coord & operator+= ( int n)
inline

◆ operator-() [1/2]

__hostdev__ Coord operator- ( ) const
inline

◆ operator-() [2/2]

__hostdev__ Coord operator- ( const Coord & rhs) const
inline

◆ operator-=()

__hostdev__ Coord & operator-= ( const Coord & rhs)
inline

◆ operator<()

__hostdev__ bool operator< ( const Coord & rhs) const
inline

Return true if this Coord is lexicographically less than the given Coord.

◆ operator<<()

__hostdev__ Coord operator<< ( IndexType n) const
inline

◆ operator<<=()

__hostdev__ Coord & operator<<= ( uint32_t n)
inline

◆ operator<=()

__hostdev__ bool operator<= ( const Coord & rhs) const
inline

Return true if this Coord is lexicographically less or equal to the given Coord.

◆ operator=()

template<typename CoordT>
__hostdev__ Coord & operator= ( const CoordT & other)
inline

Assignment operator that works with openvdb::Coord.

◆ operator==()

__hostdev__ bool operator== ( const Coord & rhs) const
inline

◆ operator>()

__hostdev__ bool operator> ( const Coord & rhs) const
inline

◆ operator>=()

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

◆ operator>>()

__hostdev__ Coord operator>> ( IndexType n) const
inline

◆ operator>>=()

__hostdev__ Coord & operator>>= ( uint32_t n)
inline

◆ operator[]() [1/2]

__hostdev__ ValueType & operator[] ( IndexType i)
inline

Return a non-const reference to the given Coord component.

Warning
The argument is assumed to be 0, 1, or 2.

◆ operator[]() [2/2]

__hostdev__ const ValueType & operator[] ( IndexType i) const
inline

Return a const reference to the given Coord component.

Warning
The argument is assumed to be 0, 1, or 2.

◆ round()

__hostdev__ Coord round ( ) const
inline

◆ x() [1/2]

__hostdev__ int32_t & x ( )
inline

◆ x() [2/2]

__hostdev__ int32_t x ( ) const
inline

◆ y() [1/2]

__hostdev__ int32_t & y ( )
inline

◆ y() [2/2]

__hostdev__ int32_t y ( ) const
inline

◆ z() [1/2]

__hostdev__ int32_t & z ( )
inline

◆ z() [2/2]

__hostdev__ int32_t z ( ) const
inline