OpenVDB 14.0.0
Loading...
Searching...
No Matches
Coord2 Class Reference

Signed (i, j) 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__ constexpr Coord2 () noexcept
 Initialize all coordinates to zero.
__hostdev__ constexpr Coord2 (ValueType n) noexcept
 Initializes all coordinates to the given signed integer.
__hostdev__ constexpr Coord2 (ValueType i, ValueType j) noexcept
 Initializes coordinate to the given signed integers.
__hostdev__ constexpr Coord2 (ValueType *ptr) noexcept
 Read two signed integers from ptr (no bounds check).
__hostdev__ constexpr int32_t x () const noexcept
 Named component accessors (x = mVec[0], y = mVec[1]).
__hostdev__ constexpr int32_t y () const noexcept
__hostdev__ constexpr int32_t & x () noexcept
__hostdev__ constexpr int32_t & y () noexcept
__hostdev__ constexpr const ValueType & operator[] (IndexType i) const noexcept
 Return a const reference to the given Coord component.
__hostdev__ constexpr ValueType & operator[] (IndexType i) noexcept
 Return a non-const reference to the given Coord component.
template<typename CoordT>
__hostdev__ constexpr Coord2 & operator= (const CoordT &other) noexcept
 Assignment operator that works with openvdb::Coord.
__hostdev__ constexpr Coord2 operator& (IndexType n) const noexcept
 Return a new instance with coordinates masked by the given unsigned integer.
__hostdev__ constexpr Coord2 operator<< (IndexType n) const noexcept
 Return a new instance with coordinates left-shifted by the given unsigned integer.
__hostdev__ constexpr Coord2 operator>> (IndexType n) const noexcept
 Return a new instance with coordinates right-shifted by the given unsigned integer.
__hostdev__ constexpr bool operator< (const Coord2 &rhs) const noexcept
 Return true if this Coord is lexicographically less than the given Coord.
__hostdev__ constexpr bool operator<= (const Coord2 &rhs) const noexcept
 Return true if this Coord is lexicographically less or equal to the given Coord.
__hostdev__ constexpr bool operator> (const Coord2 &rhs) const noexcept
 Return true if this Coord is lexicographically greater than the given Coord.
__hostdev__ constexpr bool operator>= (const Coord2 &rhs) const noexcept
 Return true if this Coord is lexicographically greater or equal to the given Coord.
__hostdev__ constexpr bool operator== (const Coord2 &rhs) const noexcept
 Return true iff every component matches rhs.
__hostdev__ constexpr bool operator!= (const Coord2 &rhs) const noexcept
 Return true iff any component differs from rhs.
__hostdev__ constexpr Coord2 & operator&= (int n) noexcept
 In-place component-wise bitwise AND with the given mask.
__hostdev__ constexpr Coord2 & operator<<= (uint32_t n) noexcept
 In-place left-shift of every component by n bits.
__hostdev__ constexpr Coord2 & operator>>= (uint32_t n) noexcept
 In-place right-shift of every component by n bits.
__hostdev__ constexpr Coord2 & operator+= (int n) noexcept
 Add a scalar to every component in place.
__hostdev__ constexpr Coord2 operator+ (const Coord2 &rhs) const noexcept
 Component-wise sum of two coordinates.
__hostdev__ constexpr Coord2 operator- (const Coord2 &rhs) const noexcept
 Component-wise difference of two coordinates.
__hostdev__ constexpr Coord2 operator- () const noexcept
 Component-wise negation.
__hostdev__ constexpr Coord2 & operator+= (const Coord2 &rhs) noexcept
 In-place component-wise addition with another coordinate.
__hostdev__ constexpr Coord2 & operator-= (const Coord2 &rhs) noexcept
 In-place component-wise subtraction with another coordinate.
__hostdev__ constexpr Coord2 & minComponent (const Coord2 &other) noexcept
 Perform a component-wise minimum with the other Coord.
__hostdev__ constexpr Coord2 & maxComponent (const Coord2 &other) noexcept
 Perform a component-wise maximum with the other Coord.
__hostdev__ constexpr Coord2 offsetBy (ValueType dx, ValueType dy) const noexcept
 Return a new Coord2 offset component-by-component by (dx, dy).
__hostdev__ constexpr Coord2 offsetBy (ValueType n) const noexcept
 Return a new Coord2 offset by the same scalar n in both components.
__hostdev__ constexpr Vec2< float > asVec2s () const noexcept
 Return a single precision floating-point vector of this coordinate.
__hostdev__ constexpr Vec2< double > asVec2d () const noexcept
 Return a double precision floating-point vector of this coordinate.
__hostdev__ constexpr Coord2 round () const noexcept
 Identity (Coord2 is already integer); provided so generic code can call .round() uniformly on Coord2 and Vec2<T>.

Static Public Member Functions

static __hostdev__ constexpr Coord2 max () noexcept
 Largest representable Coord2 (all components = INT32_MAX).
static __hostdev__ constexpr Coord2 min () noexcept
 Smallest representable Coord2 (all components = INT32_MIN).
static __hostdev__ constexpr size_t memUsage () noexcept
 Byte size of a Coord2 (always 8 on a 32-bit int32_t platform).
static __hostdev__ constexpr bool lessThan (const Coord2 &a, const Coord2 &b) noexcept
template<typename Vec2T>
static __hostdev__ Coord2 Floor (const Vec2T &xy) noexcept
 Return the largest integer coordinates that are not greater than xyz (node centered conversion).

Detailed Description

Signed (i, j) 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

◆ Coord2() [1/4]

__hostdev__ constexpr Coord2 ( )
inlineconstexprnoexcept

Initialize all coordinates to zero.

◆ Coord2() [2/4]

__hostdev__ constexpr Coord2 ( ValueType n)
inlineexplicitconstexprnoexcept

Initializes all coordinates to the given signed integer.

◆ Coord2() [3/4]

__hostdev__ constexpr Coord2 ( ValueType i,
ValueType j )
inlineconstexprnoexcept

Initializes coordinate to the given signed integers.

◆ Coord2() [4/4]

__hostdev__ constexpr Coord2 ( ValueType * ptr)
inlineconstexprnoexcept

Read two signed integers from ptr (no bounds check).

Member Function Documentation

◆ asVec2d()

__hostdev__ constexpr Vec2< double > asVec2d ( ) const
inlinenodiscardconstexprnoexcept

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

◆ asVec2s()

__hostdev__ constexpr Vec2< float > asVec2s ( ) const
inlinenodiscardconstexprnoexcept

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

◆ Floor()

template<typename Vec2T>
__hostdev__ Coord2 Floor ( const Vec2T & xy)
inlinestaticnodiscardnoexcept

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

◆ lessThan()

__hostdev__ constexpr bool lessThan ( const Coord2 & a,
const Coord2 & b )
inlinestaticnodiscardconstexprnoexcept

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

◆ max()

__hostdev__ constexpr Coord2 max ( )
inlinestaticnodiscardconstexprnoexcept

Largest representable Coord2 (all components = INT32_MAX).

◆ maxComponent()

__hostdev__ constexpr Coord2 & maxComponent ( const Coord2 & other)
inlineconstexprnoexcept

Perform a component-wise maximum with the other Coord.

◆ memUsage()

__hostdev__ constexpr size_t memUsage ( )
inlinestaticnodiscardconstexprnoexcept

Byte size of a Coord2 (always 8 on a 32-bit int32_t platform).

◆ min()

__hostdev__ constexpr Coord2 min ( )
inlinestaticnodiscardconstexprnoexcept

Smallest representable Coord2 (all components = INT32_MIN).

◆ minComponent()

__hostdev__ constexpr Coord2 & minComponent ( const Coord2 & other)
inlineconstexprnoexcept

Perform a component-wise minimum with the other Coord.

◆ offsetBy() [1/2]

__hostdev__ constexpr Coord2 offsetBy ( ValueType dx,
ValueType dy ) const
inlinenodiscardconstexprnoexcept

Return a new Coord2 offset component-by-component by (dx, dy).

◆ offsetBy() [2/2]

__hostdev__ constexpr Coord2 offsetBy ( ValueType n) const
inlinenodiscardconstexprnoexcept

Return a new Coord2 offset by the same scalar n in both components.

◆ operator!=()

__hostdev__ constexpr bool operator!= ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

Return true iff any component differs from rhs.

◆ operator&()

__hostdev__ constexpr Coord2 operator& ( IndexType n) const
inlinenodiscardconstexprnoexcept

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

◆ operator&=()

__hostdev__ constexpr Coord2 & operator&= ( int n)
inlineconstexprnoexcept

In-place component-wise bitwise AND with the given mask.

◆ operator+()

__hostdev__ constexpr Coord2 operator+ ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

Component-wise sum of two coordinates.

◆ operator+=() [1/2]

__hostdev__ constexpr Coord2 & operator+= ( const Coord2 & rhs)
inlineconstexprnoexcept

In-place component-wise addition with another coordinate.

◆ operator+=() [2/2]

__hostdev__ constexpr Coord2 & operator+= ( int n)
inlineconstexprnoexcept

Add a scalar to every component in place.

◆ operator-() [1/2]

__hostdev__ constexpr Coord2 operator- ( ) const
inlinenodiscardconstexprnoexcept

Component-wise negation.

◆ operator-() [2/2]

__hostdev__ constexpr Coord2 operator- ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

Component-wise difference of two coordinates.

◆ operator-=()

__hostdev__ constexpr Coord2 & operator-= ( const Coord2 & rhs)
inlineconstexprnoexcept

In-place component-wise subtraction with another coordinate.

◆ operator<()

__hostdev__ constexpr bool operator< ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

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

◆ operator<<()

__hostdev__ constexpr Coord2 operator<< ( IndexType n) const
inlinenodiscardconstexprnoexcept

Return a new instance with coordinates left-shifted by the given unsigned integer.

◆ operator<<=()

__hostdev__ constexpr Coord2 & operator<<= ( uint32_t n)
inlineconstexprnoexcept

In-place left-shift of every component by n bits.

◆ operator<=()

__hostdev__ constexpr bool operator<= ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

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

◆ operator=()

template<typename CoordT>
__hostdev__ constexpr Coord2 & operator= ( const CoordT & other)
inlineconstexprnoexcept

Assignment operator that works with openvdb::Coord.

◆ operator==()

__hostdev__ constexpr bool operator== ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

Return true iff every component matches rhs.

◆ operator>()

__hostdev__ constexpr bool operator> ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

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

◆ operator>=()

__hostdev__ constexpr bool operator>= ( const Coord2 & rhs) const
inlinenodiscardconstexprnoexcept

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

◆ operator>>()

__hostdev__ constexpr Coord2 operator>> ( IndexType n) const
inlinenodiscardconstexprnoexcept

Return a new instance with coordinates right-shifted by the given unsigned integer.

◆ operator>>=()

__hostdev__ constexpr Coord2 & operator>>= ( uint32_t n)
inlineconstexprnoexcept

In-place right-shift of every component by n bits.

◆ operator[]() [1/2]

__hostdev__ constexpr const ValueType & operator[] ( IndexType i) const
inlineconstexprnoexcept

Return a const reference to the given Coord component.

Warning
The argument is assumed to be 0 or 1,

◆ operator[]() [2/2]

__hostdev__ constexpr ValueType & operator[] ( IndexType i)
inlineconstexprnoexcept

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

Warning
The argument is assumed to be 0 or 1.

◆ round()

__hostdev__ constexpr Coord2 round ( ) const
inlinenodiscardconstexprnoexcept

Identity (Coord2 is already integer); provided so generic code can call .round() uniformly on Coord2 and Vec2<T>.

◆ x() [1/2]

__hostdev__ constexpr int32_t x ( ) const
inlineconstexprnoexcept

Named component accessors (x = mVec[0], y = mVec[1]).

◆ x() [2/2]

__hostdev__ constexpr int32_t & x ( )
inlineconstexprnoexcept

◆ y() [1/2]

__hostdev__ constexpr int32_t y ( ) const
inlineconstexprnoexcept

◆ y() [2/2]

__hostdev__ constexpr int32_t & y ( )
inlineconstexprnoexcept