OpenVDB  3.0.0
Coord.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2014 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30 
31 #ifndef OPENVDB_MATH_COORD_HAS_BEEN_INCLUDED
32 #define OPENVDB_MATH_COORD_HAS_BEEN_INCLUDED
33 
34 #include <openvdb/Platform.h>
35 #include "Math.h"
36 #include "Vec3.h"
37 
38 namespace tbb { class split; } // forward declaration
39 
40 
41 namespace openvdb {
43 namespace OPENVDB_VERSION_NAME {
44 namespace math {
45 
47 class Coord
48 {
49 public:
50  typedef int32_t Int32;
51  typedef uint32_t Index32;
52  typedef Vec3<Int32> Vec3i;
54 
55  typedef Int32 ValueType;
56  typedef std::numeric_limits<ValueType> Limits;
57 
59  { mVec[0] = mVec[1] = mVec[2] = 0; }
60  explicit Coord(Int32 xyz)
61  { mVec[0] = mVec[1] = mVec[2] = xyz; }
62  Coord(Int32 x, Int32 y, Int32 z)
63  { mVec[0] = x; mVec[1] = y; mVec[2] = z; }
64  explicit Coord(const Vec3i& v)
65  { mVec[0] = v[0]; mVec[1] = v[1]; mVec[2] = v[2]; }
66  explicit Coord(const Vec3I& v)
67  { mVec[0] = Int32(v[0]); mVec[1] = Int32(v[1]); mVec[2] = Int32(v[2]); }
68  explicit Coord(const Int32* v)
69  { mVec[0] = v[0]; mVec[1] = v[1]; mVec[2] = v[2]; }
70 
72  static Coord min() { return Coord(Limits::min()); }
73 
75  static Coord max() { return Coord(Limits::max()); }
76 
79  template<typename T> static Coord round(const Vec3<T>& xyz)
80  { return Coord(Int32(Round(xyz[0])), Int32(Round(xyz[1])), Int32(Round(xyz[2]))); }
83  template<typename T> static Coord floor(const Vec3<T>& xyz)
84  { return Coord(Int32(Floor(xyz[0])), Int32(Floor(xyz[1])), Int32(Floor(xyz[2]))); }
85 
88  template<typename T> static Coord ceil(const Vec3<T>& xyz)
89  { return Coord(Int32(Ceil(xyz[0])), Int32(Ceil(xyz[1])), Int32(Ceil(xyz[2]))); }
90 
91  Coord& reset(Int32 x, Int32 y, Int32 z)
92  { mVec[0] = x; mVec[1] = y; mVec[2] = z; this->dirty(); return *this; }
93  Coord& reset(Int32 xyz) { return this->reset(xyz, xyz, xyz); }
94 
95  Coord& setX(Int32 x) { mVec[0] = x; dirty(); return *this; }
96  Coord& setY(Int32 y) { mVec[1] = y; dirty(); return *this; }
97  Coord& setZ(Int32 z) { mVec[2] = z; dirty(); return *this; }
98 
99  Coord& offset(Int32 dx, Int32 dy, Int32 dz)
100  { mVec[0]+=dx; mVec[1]+=dy; mVec[2]+=dz; this->dirty(); return *this; }
101  Coord& offset(Int32 n) { return this->offset(n, n, n); }
102  Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
103  { return Coord(mVec[0] + dx, mVec[1] + dy, mVec[2] + dz); }
104  Coord offsetBy(Int32 n) const { return offsetBy(n, n, n); }
105 
106  Coord& operator+=(const Coord& rhs)
107  { mVec[0] += rhs[0]; mVec[1] += rhs[1]; mVec[2] += rhs[2]; return *this; }
108  Coord& operator-=(const Coord& rhs)
109  { mVec[0] -= rhs[0]; mVec[1] -= rhs[1]; mVec[2] -= rhs[2]; return *this; }
110  Coord operator+(const Coord& rhs) const
111  { return Coord(mVec[0] + rhs[0], mVec[1] + rhs[1], mVec[2] + rhs[2]); }
112  Coord operator-(const Coord& rhs) const
113  { return Coord(mVec[0] - rhs[0], mVec[1] - rhs[1], mVec[2] - rhs[2]); }
114  Coord operator-() const { return Coord(-mVec[0], -mVec[1], -mVec[2]); }
115 
116  Coord operator>> (size_t n) const { return Coord(mVec[0]>>n, mVec[1]>>n, mVec[2]>>n); }
117  Coord operator<< (size_t n) const { return Coord(mVec[0]<<n, mVec[1]<<n, mVec[2]<<n); }
118  Coord& operator<<=(size_t n) { mVec[0]<<=n; mVec[1]<<=n; mVec[2]<<=n; dirty(); return *this; }
119  Coord& operator>>=(size_t n) { mVec[0]>>=n; mVec[1]>>=n; mVec[2]>>=n; dirty(); return *this; }
120  Coord operator& (Int32 n) const { return Coord(mVec[0] & n, mVec[1] & n, mVec[2] & n); }
121  Coord operator| (Int32 n) const { return Coord(mVec[0] | n, mVec[1] | n, mVec[2] | n); }
122  Coord& operator&= (Int32 n) { mVec[0]&=n; mVec[1]&=n; mVec[2]&=n; dirty(); return *this; }
123  Coord& operator|= (Int32 n) { mVec[0]|=n; mVec[1]|=n; mVec[2]|=n; dirty(); return *this; }
124 
125  Int32 x() const { return mVec[0]; }
126  Int32 y() const { return mVec[1]; }
127  Int32 z() const { return mVec[2]; }
128  Int32 operator[](size_t i) const { assert(i < 3); return mVec[i]; }
129  Int32& x() { dirty(); return mVec[0]; }
130  Int32& y() { dirty(); return mVec[1]; }
131  Int32& z() { dirty(); return mVec[2]; }
132  Int32& operator[](size_t i) { assert(i < 3); dirty(); return mVec[i]; }
133 
134  const Int32* asPointer() const { return mVec; }
135  Int32* asPointer() { dirty(); return mVec; }
136  Vec3d asVec3d() const { return Vec3d(double(mVec[0]), double(mVec[1]), double(mVec[2])); }
137  Vec3s asVec3s() const { return Vec3s(float(mVec[0]), float(mVec[1]), float(mVec[2])); }
138  Vec3i asVec3i() const { return Vec3i(mVec); }
139  Vec3I asVec3I() const { return Vec3I(Index32(mVec[0]), Index32(mVec[1]), Index32(mVec[2])); }
140  void asXYZ(Int32& x, Int32& y, Int32& z) const { x = mVec[0]; y = mVec[1]; z = mVec[2]; }
141 
142  bool operator==(const Coord& rhs) const
143  { return (mVec[0] == rhs.mVec[0] && mVec[1] == rhs.mVec[1] && mVec[2] == rhs.mVec[2]); }
144  bool operator!=(const Coord& rhs) const { return !(*this == rhs); }
145 
147  bool operator<(const Coord& rhs) const
148  {
149  return this->x() < rhs.x() ? true : this->x() > rhs.x() ? false
150  : this->y() < rhs.y() ? true : this->y() > rhs.y() ? false
151  : this->z() < rhs.z() ? true : false;
152  }
154  bool operator<=(const Coord& rhs) const
155  {
156  return this->x() < rhs.x() ? true : this->x() > rhs.x() ? false
157  : this->y() < rhs.y() ? true : this->y() > rhs.y() ? false
158  : this->z() <=rhs.z() ? true : false;
159  }
161  bool operator>(const Coord& rhs) const { return !(*this <= rhs); }
163  bool operator>=(const Coord& rhs) const { return !(*this < rhs); }
164 
165  //HashType hash() { if (!mHash) { mHash = ...; } return mHash; }
166 
168  void minComponent(const Coord& other)
169  {
170  mVec[0] = std::min(mVec[0], other.mVec[0]);
171  mVec[1] = std::min(mVec[1], other.mVec[1]);
172  mVec[2] = std::min(mVec[2], other.mVec[2]);
173  }
174 
176  void maxComponent(const Coord& other)
177  {
178  mVec[0] = std::max(mVec[0], other.mVec[0]);
179  mVec[1] = std::max(mVec[1], other.mVec[1]);
180  mVec[2] = std::max(mVec[2], other.mVec[2]);
181  }
182 
184  static inline Coord minComponent(const Coord& lhs, const Coord& rhs)
185  {
186  return Coord(std::min(lhs.x(), rhs.x()),
187  std::min(lhs.y(), rhs.y()),
188  std::min(lhs.z(), rhs.z()));
189  }
190 
192  static inline Coord maxComponent(const Coord& lhs, const Coord& rhs)
193  {
194  return Coord(std::max(lhs.x(), rhs.x()),
195  std::max(lhs.y(), rhs.y()),
196  std::max(lhs.z(), rhs.z()));
197  }
198  static inline bool lessThan(const Coord& a, const Coord& b)
199  {
200  return (a[0] < b[0] || a[1] < b[1] || a[2] < b[2]);
201  }
202 
204  size_t minIndex() const { return MinIndex(mVec); }
205 
207  size_t maxIndex() const { return MaxIndex(mVec); }
208 
209  void read(std::istream& is) { is.read(reinterpret_cast<char*>(mVec), sizeof(mVec)); }
210  void write(std::ostream& os) const
211  { os.write(reinterpret_cast<const char*>(mVec), sizeof(mVec)); }
212 
213 private:
214  //no-op for now
215  void dirty() { /*mHash.clear();*/ }
216 
217  Int32 mVec[3];
218  //HashType mHash;
219 }; // class Coord
220 
221 
223 
224 
230 {
231 public:
232  typedef uint64_t Index64;
234 
236  CoordBBox(): mMin(Coord::max()), mMax(Coord::min()) {}
238  CoordBBox(const Coord& min, const Coord& max): mMin(min), mMax(max) {}
241  CoordBBox(CoordBBox& other, const tbb::split&): mMin(other.mMin), mMax(other.mMax)
242  {
243  assert(this->is_divisible());
244  const size_t n = this->maxExtent();
245  mMax[n] = (mMin[n] + mMax[n]) >> 1;
246  other.mMin[n] = mMax[n] + 1;
247  }
248 
249  static CoordBBox createCube(const Coord& min, ValueType dim)
250  {
251  return CoordBBox(min, min.offsetBy(dim - 1));
252  }
253 
255  static CoordBBox inf() { return CoordBBox(Coord::min(), Coord::max()); }
256 
257  const Coord& min() const { return mMin; }
258  const Coord& max() const { return mMax; }
259 
260  Coord& min() { return mMin; }
261  Coord& max() { return mMax; }
262 
263  void reset() { mMin = Coord::max(); mMax = Coord::min(); }
264  void reset(const Coord& min, const Coord& max) { mMin = min; mMax = max; }
265  void resetToCube(const Coord& min, ValueType dim) { mMin = min; mMax = min.offsetBy(dim - 1); }
266 
268  Coord getStart() const { return mMin; }
270  Coord getEnd() const { return mMax.offsetBy(1); }
271 
272  bool operator==(const CoordBBox& rhs) const { return mMin == rhs.mMin && mMax == rhs.mMax; }
273  bool operator!=(const CoordBBox& rhs) const { return !(*this == rhs); }
274 
275  bool empty() const { return (mMin[0] > mMax[0] || mMin[1] > mMax[1] || mMin[2] > mMax[2]); }
277  operator bool() const { return !this->empty(); }
279  bool hasVolume() const { return !this->empty(); }
281 
283  Vec3d getCenter() const { return 0.5 * Vec3d((mMin + mMax).asPointer()); }
284 
288  Coord dim() const { return mMax.offsetBy(1) - mMin; }
290  Coord extents() const { return this->dim(); }
293  Index64 volume() const
294  {
295  const Coord d = this->dim();
296  return Index64(d[0]) * Index64(d[1]) * Index64(d[2]);
297  }
299  bool is_divisible() const { return mMin[0]<mMax[0] && mMin[1]<mMax[1] && mMin[2]<mMax[2]; }
300 
302  size_t minExtent() const { return this->dim().minIndex(); }
303 
305  size_t maxExtent() const { return this->dim().maxIndex(); }
306 
308  bool isInside(const Coord& xyz) const
309  {
310  return !(Coord::lessThan(xyz,mMin) || Coord::lessThan(mMax,xyz));
311  }
312 
314  bool isInside(const CoordBBox& b) const
315  {
316  return !(Coord::lessThan(b.mMin,mMin) || Coord::lessThan(mMax,b.mMax));
317  }
318 
320  bool hasOverlap(const CoordBBox& b) const
321  {
322  return !(Coord::lessThan(mMax,b.mMin) || Coord::lessThan(b.mMax,mMin));
323  }
324 
326  void expand(ValueType padding)
327  {
328  mMin.offset(-padding);
329  mMax.offset( padding);
330  }
332  void expand(const Coord& xyz)
333  {
334  mMin.minComponent(xyz);
335  mMax.maxComponent(xyz);
336  }
338  void expand(const CoordBBox& bbox)
339  {
340  mMin.minComponent(bbox.min());
341  mMax.maxComponent(bbox.max());
342  }
344  void intersect(const CoordBBox& bbox)
345  {
346  mMin.maxComponent(bbox.min());
347  mMax.minComponent(bbox.max());
348  }
351  void expand(const Coord& min, Coord::ValueType dim)
352  {
353  mMin.minComponent(min);
354  mMax.maxComponent(min.offsetBy(dim-1));
355  }
357  void translate(const Coord& t) { mMin += t; mMax += t; }
358 
360  void read(std::istream& is) { mMin.read(is); mMax.read(is); }
362  void write(std::ostream& os) const { mMin.write(os); mMax.write(os); }
363 
364 private:
365  Coord mMin, mMax;
366 }; // class CoordBBox
367 
368 
370 
371 
372 inline std::ostream& operator<<(std::ostream& os, const Coord& xyz)
373 {
374  os << xyz.asVec3i(); return os;
375 }
376 
377 
379 template<typename T>
381 inline Vec3<typename promote<T, typename Coord::ValueType>::type>
382 operator+(const Vec3<T>& v0, const Coord& v1)
383 {
385  result[0] += v1[0];
386  result[1] += v1[1];
387  result[2] += v1[2];
388  return result;
389 }
390 
391 template<typename T>
392 inline Vec3<typename promote<T, typename Coord::ValueType>::type>
393 operator+(const Coord& v1, const Vec3<T>& v0)
394 {
396  result[0] += v1[0];
397  result[1] += v1[1];
398  result[2] += v1[2];
399  return result;
400 }
402 
403 
405 template <typename T>
407 inline Vec3<typename promote<T, Coord::ValueType>::type>
408 operator-(const Vec3<T>& v0, const Coord& v1)
409 {
411  result[0] -= v1[0];
412  result[1] -= v1[1];
413  result[2] -= v1[2];
414  return result;
415 }
416 
417 template <typename T>
418 inline Vec3<typename promote<T, Coord::ValueType>::type>
419 operator-(const Coord& v1, const Vec3<T>& v0)
420 {
422  result[0] -= v1[0];
423  result[1] -= v1[1];
424  result[2] -= v1[2];
425  return -result;
426 }
428 
429 inline std::ostream&
430 operator<<(std::ostream& os, const CoordBBox& b)
431 {
432  os << b.min() << " -> " << b.max();
433  return os;
434 }
435 
436 } // namespace math
437 } // namespace OPENVDB_VERSION_NAME
438 } // namespace openvdb
439 
440 #endif // OPENVDB_MATH_COORD_HAS_BEEN_INCLUDED
441 
442 // Copyright (c) 2012-2014 DreamWorks Animation LLC
443 // All rights reserved. This software is distributed under the
444 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
bool operator<(const Coord &rhs) const
Lexicographic less than.
Definition: Coord.h:147
bool operator==(const Coord &rhs) const
Definition: Coord.h:142
Coord(Int32 x, Int32 y, Int32 z)
Definition: Coord.h:62
Coord & setZ(Int32 z)
Definition: Coord.h:97
Coord()
Definition: Coord.h:58
Coord(const Vec3i &v)
Definition: Coord.h:64
Coord::ValueType ValueType
Definition: Coord.h:233
Coord dim() const
Return the dimensions of the coordinates spanned by this bounding box.
Definition: Coord.h:288
Definition: Mat.h:146
void expand(const CoordBBox &bbox)
Union this bounding box with the given bounding box.
Definition: Coord.h:338
CoordBBox(CoordBBox &other, const tbb::split &)
Splitting constructor for use in TBB ranges.
Definition: Coord.h:241
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
bool is_divisible() const
Return true if this bounding box can be subdivided [mainly for use by TBB].
Definition: Coord.h:299
static Coord floor(const Vec3< T > &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion)...
Definition: Coord.h:83
Coord(Int32 xyz)
Definition: Coord.h:60
bool empty() const
Definition: Coord.h:275
uint64_t Index64
Definition: Types.h:58
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:72
Vec3d asVec3d() const
Definition: Coord.h:136
Coord & operator>>=(size_t n)
Definition: Coord.h:119
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:229
Vec3< Index32 > Vec3I
Definition: Coord.h:53
Vec3< typename promote< T, typename Coord::ValueType >::type > operator+(const Coord &v1, const Vec3< T > &v0)
Allow a Coord to be added to or subtracted from a Vec3.
Definition: Coord.h:393
Vec3I asVec3I() const
Definition: Coord.h:139
void read(std::istream &is)
Definition: Coord.h:209
std::ostream & operator<<(std::ostream &os, const CoordBBox &b)
Definition: Coord.h:430
Coord & operator-=(const Coord &rhs)
Definition: Coord.h:108
Coord operator-() const
Definition: Coord.h:114
Coord(const Int32 *v)
Definition: Coord.h:68
Coord(const Vec3I &v)
Definition: Coord.h:66
bool operator!=(const CoordBBox &rhs) const
Definition: Coord.h:273
std::numeric_limits< ValueType > Limits
Definition: Coord.h:56
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
Int32 x() const
Definition: Coord.h:125
void resetToCube(const Coord &min, ValueType dim)
Definition: Coord.h:265
static Coord maxComponent(const Coord &lhs, const Coord &rhs)
Return the component-wise maximum of the two Coords.
Definition: Coord.h:192
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:326
Vec3< int32_t > Vec3i
Definition: Vec3.h:626
size_t MaxIndex(const Vec3T &v)
Return the index [0,1,2] of the largest value in a 3D vector.
Definition: Math.h:877
int32_t Int32
Definition: Types.h:61
Coord & min()
Definition: Coord.h:260
Int32 & operator[](size_t i)
Definition: Coord.h:132
const Coord & min() const
Definition: Coord.h:257
Int32 & x()
Definition: Coord.h:129
void write(std::ostream &os) const
Serialize this bounding box to the given stream.
Definition: Coord.h:362
void expand(const Coord &xyz)
Expand this bounding box to enclose point (x, y, z).
Definition: Coord.h:332
bool isInside(const CoordBBox &b) const
Return true if the given bounding box is inside this bounding box.
Definition: Coord.h:314
Coord & operator<<=(size_t n)
Definition: Coord.h:118
math::Vec3< Index32 > Vec3I
Definition: Types.h:78
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Coord offsetBy(Int32 n) const
Definition: Coord.h:104
int32_t Int32
Definition: Coord.h:50
CoordBBox()
The default constructor produces an empty bounding box.
Definition: Coord.h:236
bool hasVolume() const
Return true if this bounding box is nonempty.
Definition: Coord.h:279
void asXYZ(Int32 &x, Int32 &y, Int32 &z) const
Definition: Coord.h:140
uint64_t Index64
Definition: Coord.h:232
size_t minIndex() const
Return the index (0, 1 or 2) with the smallest value.
Definition: Coord.h:204
void minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: Coord.h:168
size_t minExtent() const
Return the index (0, 1 or 2) of the shortest axis.
Definition: Coord.h:302
Int32 & z()
Definition: Coord.h:131
Coord & setX(Int32 x)
Definition: Coord.h:95
Coord & operator+=(const Coord &rhs)
Definition: Coord.h:106
Coord operator-(const Coord &rhs) const
Definition: Coord.h:112
Coord & offset(Int32 dx, Int32 dy, Int32 dz)
Definition: Coord.h:99
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition: Coord.h:255
Int32 operator[](size_t i) const
Definition: Coord.h:128
Definition: Exceptions.h:39
Coord & reset(Int32 xyz)
Definition: Coord.h:93
OPENVDB_API Hermite min(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
Int32 & y()
Definition: Coord.h:130
Coord getEnd() const
Definition: Coord.h:270
size_t maxExtent() const
Return the index (0, 1 or 2) of the longest axis.
Definition: Coord.h:305
size_t MinIndex(const Vec3T &v)
Return the index [0,1,2] of the smallest value in a 3D vector.
Definition: Math.h:856
CoordBBox(const Coord &min, const Coord &max)
Construct a bounding box with the given min and max bounds.
Definition: Coord.h:238
Vec3< double > Vec3d
Definition: Vec3.h:629
static Coord max()
Return the largest possible coordinate.
Definition: Coord.h:75
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:320
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:344
bool operator>(const Coord &rhs) const
Lexicographic greater than.
Definition: Coord.h:161
Int32 ValueType
Definition: Coord.h:55
const Coord & max() const
Definition: Coord.h:258
bool operator>=(const Coord &rhs) const
Lexicographic greater than or equal to.
Definition: Coord.h:163
Int32 z() const
Definition: Coord.h:127
Index64 volume() const
Return the integer volume of coordinates spanned by this bounding box.
Definition: Coord.h:293
Coord & reset(Int32 x, Int32 y, Int32 z)
Definition: Coord.h:91
void translate(const Coord &t)
Translate this bounding box by .
Definition: Coord.h:357
bool operator==(const CoordBBox &rhs) const
Definition: Coord.h:272
Vec3d getCenter() const
Return the floating-point position of the center of this bounding box.
Definition: Coord.h:283
int Floor(float x)
Return the floor of x.
Definition: Math.h:780
static Coord minComponent(const Coord &lhs, const Coord &rhs)
Return the component-wise minimum of the two Coords.
Definition: Coord.h:184
int Ceil(float x)
Return the ceiling of x.
Definition: Math.h:788
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:102
Definition: Coord.h:38
OPENVDB_API Hermite max(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:249
bool operator<=(const Coord &rhs) const
Lexicographic less than or equal to.
Definition: Coord.h:154
Coord & setY(Int32 y)
Definition: Coord.h:96
static bool lessThan(const Coord &a, const Coord &b)
Definition: Coord.h:198
Int32 y() const
Definition: Coord.h:126
Vec3< typename promote< T, Coord::ValueType >::type > operator-(const Coord &v1, const Vec3< T > &v0)
Allow a Coord to be subtracted from a Vec3.
Definition: Coord.h:419
Int32 * asPointer()
Definition: Coord.h:135
void reset(const Coord &min, const Coord &max)
Definition: Coord.h:264
Vec3i asVec3i() const
Definition: Coord.h:138
bool operator!=(const Coord &rhs) const
Definition: Coord.h:144
static Coord round(const Vec3< T > &xyz)
Return xyz rounded to the closest integer coordinates (cell centered conversion). ...
Definition: Coord.h:79
Coord getStart() const
Definition: Coord.h:268
Coord extents() const
Definition: Coord.h:290
Vec3s asVec3s() const
Definition: Coord.h:137
void maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition: Coord.h:176
uint32_t Index32
Definition: Types.h:57
static Coord ceil(const Vec3< T > &xyz)
Return the largest integer coordinates that are not greater than xyz+1 (node centered conversion)...
Definition: Coord.h:88
float Round(float x)
Return x rounded to the nearest integer.
Definition: Math.h:751
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
uint32_t Index32
Definition: Coord.h:51
Vec3< float > Vec3s
Definition: Vec3.h:628
Coord operator+(const Coord &rhs) const
Definition: Coord.h:110
Coord & offset(Int32 n)
Definition: Coord.h:101
const Int32 * asPointer() const
Definition: Coord.h:134
void expand(const Coord &min, Coord::ValueType dim)
Union this bounding box with the cubical bounding box of the given size and with the given minimum co...
Definition: Coord.h:351
Coord & max()
Definition: Coord.h:261
void read(std::istream &is)
Unserialize this bounding box from the given stream.
Definition: Coord.h:360
void reset()
Definition: Coord.h:263
size_t maxIndex() const
Return the index (0, 1 or 2) with the largest value.
Definition: Coord.h:207
Vec3< Int32 > Vec3i
Definition: Coord.h:52
void write(std::ostream &os) const
Definition: Coord.h:210
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:308