OpenVDB: Coord.h Source File

OpenVDB 3.2.0

Coord.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2016 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 {
42 OPENVDB_USE_VERSION_NAMESPACE
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;
53 typedef Vec3<Index32> Vec3I;
54
55 typedef Int32 ValueType;
56 typedef std::numeric_limits<ValueType> Limits;
57
58 Coord() { mVec[0] = mVec[1] = mVec[2] = 0; }
59 explicit Coord(Int32 xyz) { mVec[0] = mVec[1] = mVec[2] = xyz; }
60 Coord(Int32 x, Int32 y, Int32 z) { mVec[0] = x; mVec[1] = y; mVec[2] = z; }
61 explicit Coord(const Vec3i& v) { mVec[0] = v[0]; mVec[1] = v[1]; mVec[2] = v[2]; }
62 explicit Coord(const Vec3I& v)
63 {
64 mVec[0] = Int32(v[0]); mVec[1] = Int32(v[1]); mVec[2] = Int32(v[2]);
65 }
66 explicit Coord(const Int32* v) { mVec[0] = v[0]; mVec[1] = v[1]; mVec[2] = v[2]; }
67
69 static Coord min() { return Coord(Limits::min()); }
70
72 static Coord max() { return Coord(Limits::max()); }
73
76 template<typename T> static Coord round(const Vec3<T>& xyz)
77 {
78 return Coord(Int32(Round(xyz[0])), Int32(Round(xyz[1])), Int32(Round(xyz[2])));
79 }
82 template<typename T> static Coord floor(const Vec3<T>& xyz)
83 {
84 return Coord(Int32(Floor(xyz[0])), Int32(Floor(xyz[1])), Int32(Floor(xyz[2])));
85 }
86
89 template<typename T> static Coord ceil(const Vec3<T>& xyz)
90 {
91 return Coord(Int32(Ceil(xyz[0])), Int32(Ceil(xyz[1])), Int32(Ceil(xyz[2])));
92 }
93
94 Coord& reset(Int32 x, Int32 y, Int32 z)
95 {
96 mVec[0] = x; mVec[1] = y; mVec[2] = z;
97 return *this;
98 }
99 Coord& reset(Int32 xyz) { return this->reset(xyz, xyz, xyz); }
100
101 Coord& setX(Int32 x) { mVec[0] = x; return *this; }
102 Coord& setY(Int32 y) { mVec[1] = y; return *this; }
103 Coord& setZ(Int32 z) { mVec[2] = z; return *this; }
104
105 Coord& offset(Int32 dx, Int32 dy, Int32 dz)
106 {
107 mVec[0]+=dx; mVec[1]+=dy; mVec[2]+=dz;
108 return *this;
109 }
110 Coord& offset(Int32 n) { return this->offset(n, n, n); }
111 Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
112 {
113 return Coord(mVec[0] + dx, mVec[1] + dy, mVec[2] + dz);
114 }
115 Coord offsetBy(Int32 n) const { return offsetBy(n, n, n); }
116
117 Coord& operator+=(const Coord& rhs)
118 {
119 mVec[0] += rhs[0]; mVec[1] += rhs[1]; mVec[2] += rhs[2];
120 return *this;
121 }
122 Coord& operator-=(const Coord& rhs)
123 {
124 mVec[0] -= rhs[0]; mVec[1] -= rhs[1]; mVec[2] -= rhs[2];
125 return *this;
126 }
127 Coord operator+(const Coord& rhs) const
128 {
129 return Coord(mVec[0] + rhs[0], mVec[1] + rhs[1], mVec[2] + rhs[2]);
130 }
131 Coord operator-(const Coord& rhs) const
132 {
133 return Coord(mVec[0] - rhs[0], mVec[1] - rhs[1], mVec[2] - rhs[2]);
134 }
135 Coord operator-() const { return Coord(-mVec[0], -mVec[1], -mVec[2]); }
136
137 Coord operator>> (size_t n) const { return Coord(mVec[0]>>n, mVec[1]>>n, mVec[2]>>n); }
138 Coord operator<< (size_t n) const { return Coord(mVec[0]<<n, mVec[1]<<n, mVec[2]<<n); }
139 Coord& operator<<=(size_t n) { mVec[0]<<=n; mVec[1]<<=n; mVec[2]<<=n; return *this; }
140 Coord& operator>>=(size_t n) { mVec[0]>>=n; mVec[1]>>=n; mVec[2]>>=n; return *this; }
141 Coord operator& (Int32 n) const { return Coord(mVec[0] & n, mVec[1] & n, mVec[2] & n); }
142 Coord operator| (Int32 n) const { return Coord(mVec[0] | n, mVec[1] | n, mVec[2] | n); }
143 Coord& operator&= (Int32 n) { mVec[0]&=n; mVec[1]&=n; mVec[2]&=n; return *this; }
144 Coord& operator|= (Int32 n) { mVec[0]|=n; mVec[1]|=n; mVec[2]|=n; return *this; }
145
146 Int32 x() const { return mVec[0]; }
147 Int32 y() const { return mVec[1]; }
148 Int32 z() const { return mVec[2]; }
149 Int32 operator[](size_t i) const { assert(i < 3); return mVec[i]; }
150 Int32& x() { return mVec[0]; }
151 Int32& y() { return mVec[1]; }
152 Int32& z() { return mVec[2]; }
153 Int32& operator[](size_t i) { assert(i < 3); return mVec[i]; }
154
155 const Int32* data() const { return mVec; }
156 Int32* data() { return mVec; }
157 const Int32* asPointer() const { return mVec; }
158 Int32* asPointer() { return mVec; }
159 Vec3d asVec3d() const { return Vec3d(double(mVec[0]), double(mVec[1]), double(mVec[2])); }
160 Vec3s asVec3s() const { return Vec3s(float(mVec[0]), float(mVec[1]), float(mVec[2])); }
161 Vec3i asVec3i() const { return Vec3i(mVec); }
162 Vec3I asVec3I() const { return Vec3I(Index32(mVec[0]), Index32(mVec[1]), Index32(mVec[2])); }
163 void asXYZ(Int32& x, Int32& y, Int32& z) const { x = mVec[0]; y = mVec[1]; z = mVec[2]; }
164
165 bool operator==(const Coord& rhs) const
166 {
167 return (mVec[0] == rhs.mVec[0] && mVec[1] == rhs.mVec[1] && mVec[2] == rhs.mVec[2]);
168 }
169 bool operator!=(const Coord& rhs) const { return !(*this == rhs); }
170
172 bool operator<(const Coord& rhs) const
173 {
174 return this->x() < rhs.x() ? true : this->x() > rhs.x() ? false
175 : this->y() < rhs.y() ? true : this->y() > rhs.y() ? false
176 : this->z() < rhs.z() ? true : false;
177 }
179 bool operator<=(const Coord& rhs) const
180 {
181 return this->x() < rhs.x() ? true : this->x() > rhs.x() ? false
182 : this->y() < rhs.y() ? true : this->y() > rhs.y() ? false
183 : this->z() <=rhs.z() ? true : false;
184 }
186 bool operator>(const Coord& rhs) const { return !(*this <= rhs); }
188 bool operator>=(const Coord& rhs) const { return !(*this < rhs); }
189
191 void minComponent(const Coord& other)
192 {
193 mVec[0] = std::min(mVec[0], other.mVec[0]);
194 mVec[1] = std::min(mVec[1], other.mVec[1]);
195 mVec[2] = std::min(mVec[2], other.mVec[2]);
196 }
197
199 void maxComponent(const Coord& other)
200 {
201 mVec[0] = std::max(mVec[0], other.mVec[0]);
202 mVec[1] = std::max(mVec[1], other.mVec[1]);
203 mVec[2] = std::max(mVec[2], other.mVec[2]);
204 }
205
207 static inline Coord minComponent(const Coord& lhs, const Coord& rhs)
208 {
209 return Coord(std::min(lhs.x(), rhs.x()),
210 std::min(lhs.y(), rhs.y()),
211 std::min(lhs.z(), rhs.z()));
212 }
213
215 static inline Coord maxComponent(const Coord& lhs, const Coord& rhs)
216 {
217 return Coord(std::max(lhs.x(), rhs.x()),
218 std::max(lhs.y(), rhs.y()),
219 std::max(lhs.z(), rhs.z()));
220 }
221
224 static inline bool lessThan(const Coord& a, const Coord& b)
225 {
226 return (a[0] < b[0] || a[1] < b[1] || a[2] < b[2]);
227 }
228
230 size_t minIndex() const { return MinIndex(mVec); }
231
233 size_t maxIndex() const { return MaxIndex(mVec); }
234
235 void read(std::istream& is) { is.read(reinterpret_cast<char*>(mVec), sizeof(mVec)); }
236 void write(std::ostream& os) const
237 {
238 os.write(reinterpret_cast<const char*>(mVec), sizeof(mVec));
239 }
240
241 private:
242
243 Int32 mVec[3];
244 }; // class Coord
245
246 inline Coord
247 Abs(const Coord& xyz)
248 {
249 return Coord(Abs(xyz[0]), Abs(xyz[1]), Abs(xyz[2]));
250 }
251
253
254
259 class CoordBBox
260 {
261 public:
262 typedef uint64_t Index64;
263 typedef Coord::ValueType ValueType;
264
269 template<bool ZYX>
270 class Iterator {
271 public:
273 Iterator(const CoordBBox &b) : mPos(b.min()), mMin(b.min()), mMax(b.max()) {}
277 Iterator& operator++() {
278 ZYX ? this->next<2,1,0>() : this->next<0,1,2>();//resolved and inlined
279 return *this;
280 }
282 operator bool() const {
283 return ZYX ? mPos[0] <= mMax[0] : mPos[2] <= mMax[2];
284 }
286 const Coord& operator*() const { return mPos; }
287 private:
288 template<size_t a, size_t b, size_t c>
289 inline void next() {
290 if ( mPos[a] < mMax[a] ) {// this is the most common case
291 ++mPos[a];
292 } else if ( mPos[b] < mMax[b] ) {
293 mPos[a] = mMin[a];
294 ++mPos[b];
295 } else if ( mPos[c] <= mMax[c] ) {
296 mPos[a] = mMin[a];
297 mPos[b] = mMin[b];
298 ++mPos[c];
299 }
300 }
301 Coord mPos, mMin, mMax;
302 };// CoordBBox::Iterator
303
305 CoordBBox(): mMin(Coord::max()), mMax(Coord::min()) {}
307 CoordBBox(const Coord& min, const Coord& max): mMin(min), mMax(max) {}
309 CoordBBox(ValueType x_min, ValueType y_min, ValueType z_min,
310 ValueType x_max, ValueType y_max, ValueType z_max)
311 : mMin(x_min, y_min, z_min), mMax(x_max, y_max, z_max)
312 {
313 }
316 CoordBBox(CoordBBox& other, const tbb::split&): mMin(other.mMin), mMax(other.mMax)
317 {
318 assert(this->is_divisible());
319 const size_t n = this->maxExtent();
320 mMax[n] = (mMin[n] + mMax[n]) >> 1;
321 other.mMin[n] = mMax[n] + 1;
322 }
323
324 static CoordBBox createCube(const Coord& min, ValueType dim)
325 {
326 return CoordBBox(min, min.offsetBy(dim - 1));
327 }
328
330 static CoordBBox inf() { return CoordBBox(Coord::min(), Coord::max()); }
331
332 const Coord& min() const { return mMin; }
333 const Coord& max() const { return mMax; }
334
335 Coord& min() { return mMin; }
336 Coord& max() { return mMax; }
337
338 void reset() { mMin = Coord::max(); mMax = Coord::min(); }
339 void reset(const Coord& min, const Coord& max) { mMin = min; mMax = max; }
340 void resetToCube(const Coord& min, ValueType dim) { mMin = min; mMax = min.offsetBy(dim - 1); }
341
343 Coord getStart() const { return mMin; }
345 Coord getEnd() const { return mMax.offsetBy(1); }
346
347 bool operator==(const CoordBBox& rhs) const { return mMin == rhs.mMin && mMax == rhs.mMax; }
348 bool operator!=(const CoordBBox& rhs) const { return !(*this == rhs); }
349
350 bool empty() const { return (mMin[0] > mMax[0] || mMin[1] > mMax[1] || mMin[2] > mMax[2]); }
352 operator bool() const { return !this->empty(); }
354 bool hasVolume() const { return !this->empty(); }
356
358 Vec3d getCenter() const { return 0.5 * Vec3d((mMin + mMax).asPointer()); }
359
363 Coord dim() const { return mMax.offsetBy(1) - mMin; }
365 Coord extents() const { return this->dim(); }
368 Index64 volume() const
369 {
370 const Coord d = this->dim();
371 return Index64(d[0]) * Index64(d[1]) * Index64(d[2]);
372 }
374 bool is_divisible() const { return mMin[0]<mMax[0] && mMin[1]<mMax[1] && mMin[2]<mMax[2]; }
375
377 size_t minExtent() const { return this->dim().minIndex(); }
378
380 size_t maxExtent() const { return this->dim().maxIndex(); }
381
383 bool isInside(const Coord& xyz) const
384 {
385 return !(Coord::lessThan(xyz,mMin) || Coord::lessThan(mMax,xyz));
386 }
387
389 bool isInside(const CoordBBox& b) const
390 {
391 return !(Coord::lessThan(b.mMin,mMin) || Coord::lessThan(mMax,b.mMax));
392 }
393
395 bool hasOverlap(const CoordBBox& b) const
396 {
397 return !(Coord::lessThan(mMax,b.mMin) || Coord::lessThan(b.mMax,mMin));
398 }
399
401 void expand(ValueType padding)
402 {
403 mMin.offset(-padding);
404 mMax.offset( padding);
405 }
406
408 CoordBBox expandBy(ValueType padding) const
409 {
410 return CoordBBox(mMin.offsetBy(-padding),mMax.offsetBy(padding));
411 }
412
414 void expand(const Coord& xyz)
415 {
416 mMin.minComponent(xyz);
417 mMax.maxComponent(xyz);
418 }
419
421 void expand(const CoordBBox& bbox)
422 {
423 mMin.minComponent(bbox.min());
424 mMax.maxComponent(bbox.max());
425 }
427 void intersect(const CoordBBox& bbox)
428 {
429 mMin.maxComponent(bbox.min());
430 mMax.minComponent(bbox.max());
431 }
434 void expand(const Coord& min, Coord::ValueType dim)
435 {
436 mMin.minComponent(min);
437 mMax.maxComponent(min.offsetBy(dim-1));
438 }
440 void translate(const Coord& t) { mMin += t; mMax += t; }
441
446 void getCornerPoints(Coord *p) const
447 {
448 assert(p != NULL);
449 p->reset(mMin.x(), mMin.y(), mMin.z()); ++p;
450 p->reset(mMin.x(), mMin.y(), mMax.z()); ++p;
451 p->reset(mMin.x(), mMax.y(), mMin.z()); ++p;
452 p->reset(mMin.x(), mMax.y(), mMax.z()); ++p;
453 p->reset(mMax.x(), mMin.y(), mMin.z()); ++p;
454 p->reset(mMax.x(), mMin.y(), mMax.z()); ++p;
455 p->reset(mMax.x(), mMax.y(), mMin.z()); ++p;
456 p->reset(mMax.x(), mMax.y(), mMax.z());
457 }
458
460 CoordBBox operator>> (size_t n) const { return CoordBBox(mMin>>n, mMax>>n); }
462 CoordBBox operator<< (size_t n) const { return CoordBBox(mMin<<n, mMax<<n); }
463 CoordBBox& operator<<=(size_t n) { mMin <<= n; mMax <<= n; return *this; }
464 CoordBBox& operator>>=(size_t n) { mMin >>= n; mMax >>= n; return *this; }
465 CoordBBox operator& (Coord::Int32 n) const { return CoordBBox(mMin & n, mMax & n); }
466 CoordBBox operator| (Coord::Int32 n) const { return CoordBBox(mMin | n, mMax | n); }
467 CoordBBox& operator&= (Coord::Int32 n) { mMin &= n; mMax &= n; return *this; }
468 CoordBBox& operator|= (Coord::Int32 n) { mMin |= n; mMax |= n; return *this; }
470
472 void read(std::istream& is) { mMin.read(is); mMax.read(is); }
474 void write(std::ostream& os) const { mMin.write(os); mMax.write(os); }
475
476 private:
477 Coord mMin, mMax;
478 }; // class CoordBBox
479
480
482
483
484 inline std::ostream& operator<<(std::ostream& os, const Coord& xyz)
485 {
486 os << xyz.asVec3i(); return os;
487 }
488
489
491 template<typename T>
493 inline Vec3<typename promote<T, typename Coord::ValueType>::type>
494 operator+(const Vec3<T>& v0, const Coord& v1)
495 {
496 Vec3<typename promote<T, typename Coord::ValueType>::type> result(v0);
497 result[0] += v1[0];
498 result[1] += v1[1];
499 result[2] += v1[2];
500 return result;
501 }
502
503 template<typename T>
504 inline Vec3<typename promote<T, typename Coord::ValueType>::type>
505 operator+(const Coord& v1, const Vec3<T>& v0)
506 {
507 Vec3<typename promote<T, typename Coord::ValueType>::type> result(v0);
508 result[0] += v1[0];
509 result[1] += v1[1];
510 result[2] += v1[2];
511 return result;
512 }
514
515
517 template <typename T>
519 inline Vec3<typename promote<T, Coord::ValueType>::type>
520 operator-(const Vec3<T>& v0, const Coord& v1)
521 {
522 Vec3<typename promote<T, Coord::ValueType>::type> result(v0);
523 result[0] -= v1[0];
524 result[1] -= v1[1];
525 result[2] -= v1[2];
526 return result;
527 }
528
529 template <typename T>
530 inline Vec3<typename promote<T, Coord::ValueType>::type>
531 operator-(const Coord& v1, const Vec3<T>& v0)
532 {
533 Vec3<typename promote<T, Coord::ValueType>::type> result(v0);
534 result[0] -= v1[0];
535 result[1] -= v1[1];
536 result[2] -= v1[2];
537 return -result;
538 }
540
541 inline std::ostream&
542 operator<<(std::ostream& os, const CoordBBox& b)
543 {
544 os << b.min() << " -> " << b.max();
545 return os;
546 }
547
548 } // namespace math
549 } // namespace OPENVDB_VERSION_NAME
550 } // namespace openvdb
551
552 #endif // OPENVDB_MATH_COORD_HAS_BEEN_INCLUDED
553
554 // Copyright (c) 2012-2016 DreamWorks Animation LLC
555 // All rights reserved. This software is distributed under the
556 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_2_0::math::Coord::minIndex
size_t minIndex() const
Return the index (0, 1 or 2) with the smallest value.
Definition: Coord.h:230
openvdb::v3_2_0::math::Coord::Int32
int32_t Int32
Definition: Coord.h:50
openvdb::v3_2_0::math::Vec3s
Vec3< float > Vec3s
Definition: Vec3.h:650
openvdb::v3_2_0::math::Coord::max
static Coord max()
Return the largest possible coordinate.
Definition: Coord.h:72
openvdb::v3_2_0::math::Abs
Coord Abs(const Coord &xyz)
Definition: Coord.h:247
openvdb::v3_2_0::math::CoordBBox::isInside
bool isInside(const CoordBBox &b) const
Return true if the given bounding box is inside this bounding box.
Definition: Coord.h:389
openvdb::v3_2_0::math::Coord::minComponent
void minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: Coord.h:191
openvdb::v3_2_0::math::Coord::z
Int32 & z()
Definition: Coord.h:152
Vec3.h
openvdb::v3_2_0::math::CoordBBox::expand
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:434
openvdb::v3_2_0::math::Coord::setX
Coord & setX(Int32 x)
Definition: Coord.h:101
openvdb::v3_2_0::math::CoordBBox::max
Coord & max()
Definition: Coord.h:336
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v3_2_0::math::Coord::operator+=
Coord & operator+=(const Coord &rhs)
Definition: Coord.h:117
openvdb::v3_2_0::math::Coord::offset
Coord & offset(Int32 dx, Int32 dy, Int32 dz)
Definition: Coord.h:105
openvdb::v3_2_0::math::CoordBBox::read
void read(std::istream &is)
Unserialize this bounding box from the given stream.
Definition: Coord.h:472
openvdb::v3_2_0::math::CoordBBox::reset
void reset()
Definition: Coord.h:338
openvdb::v3_2_0::math::Coord::reset
Coord & reset(Int32 x, Int32 y, Int32 z)
Definition: Coord.h:94
openvdb::v3_2_0::math::CoordBBox::maxExtent
size_t maxExtent() const
Return the index (0, 1 or 2) of the longest axis.
Definition: Coord.h:380
openvdb::v3_2_0::math::Coord::y
Int32 & y()
Definition: Coord.h:151
openvdb::v3_2_0::math::Vec3
Definition: Mat.h:146
openvdb::v3_2_0::math::Coord::operator-
Coord operator-(const Coord &rhs) const
Definition: Coord.h:131
openvdb::v3_2_0::math::Coord::minComponent
static Coord minComponent(const Coord &lhs, const Coord &rhs)
Return the component-wise minimum of the two Coords.
Definition: Coord.h:207
openvdb::v3_2_0::math::CoordBBox::minExtent
size_t minExtent() const
Return the index (0, 1 or 2) of the shortest axis.
Definition: Coord.h:377
openvdb::v3_2_0::math::Coord::asXYZ
void asXYZ(Int32 &x, Int32 &y, Int32 &z) const
Definition: Coord.h:163
openvdb::v3_2_0::math::Coord::ValueType
Int32 ValueType
Definition: Coord.h:55
openvdb::v3_2_0::math::CoordBBox::expand
void expand(const Coord &xyz)
Expand this bounding box to enclose point (x, y, z).
Definition: Coord.h:414
openvdb::v3_2_0::math::Coord::operator-
Coord operator-() const
Definition: Coord.h:135
openvdb::v3_2_0::math::CoordBBox::ValueType
Coord::ValueType ValueType
Definition: Coord.h:263
openvdb::v3_2_0::math::CoordBBox::is_divisible
bool is_divisible() const
Return true if this bounding box can be subdivided [mainly for use by TBB].
Definition: Coord.h:374
openvdb::v3_2_0::math::Ceil
int Ceil(float x)
Return the ceiling of x.
Definition: Math.h:822
openvdb::v3_2_0::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
openvdb::v3_2_0::math::CoordBBox::expand
void expand(const CoordBBox &bbox)
Union this bounding box with the given bounding box.
Definition: Coord.h:421
openvdb::v3_2_0::math::CoordBBox::CoordBBox
CoordBBox(CoordBBox &other, const tbb::split &)
Splitting constructor for use in TBB ranges.
Definition: Coord.h:316
openvdb::v3_2_0::math::CoordBBox::getStart
Coord getStart() const
Definition: Coord.h:343
openvdb::v3_2_0::math::Coord::maxComponent
void maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition: Coord.h:199
openvdb::v3_2_0::tools::composite::max
const boost::disable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:132
openvdb::v3_2_0::math::Coord::ceil
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:89
openvdb::v3_2_0::math::Coord::maxIndex
size_t maxIndex() const
Return the index (0, 1 or 2) with the largest value.
Definition: Coord.h:233
openvdb::v3_2_0::math::Coord::operator==
bool operator==(const Coord &rhs) const
Definition: Coord.h:165
openvdb::v3_2_0::math::Coord::asVec3s
Vec3s asVec3s() const
Definition: Coord.h:160
openvdb::v3_2_0::math::CoordBBox::Iterator::operator*
const Coord & operator*() const
Return a const reference to the coordinate currently pointed to.
Definition: Coord.h:286
openvdb::v3_2_0::math::Coord::operator>=
bool operator>=(const Coord &rhs) const
Lexicographic greater than or equal to.
Definition: Coord.h:188
openvdb::v3_2_0::math::Coord::x
Int32 x() const
Definition: Coord.h:146
openvdb::v3_2_0::math::Coord::offset
Coord & offset(Int32 n)
Definition: Coord.h:110
openvdb::v3_2_0::math::CoordBBox::operator==
bool operator==(const CoordBBox &rhs) const
Definition: Coord.h:347
openvdb::v3_2_0::math::Vec3i
Vec3< int32_t > Vec3i
Definition: Vec3.h:648
openvdb::v3_2_0::math::CoordBBox::inf
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition: Coord.h:330
openvdb::v3_2_0::math::Coord::setY
Coord & setY(Int32 y)
Definition: Coord.h:102
openvdb::v3_2_0::math::Coord::asVec3I
Vec3I asVec3I() const
Definition: Coord.h:162
openvdb::v3_2_0::math::CoordBBox::Iterator::operator++
Iterator & operator++()
Increments iterator to point to the next coordinate.
Definition: Coord.h:277
openvdb::v3_2_0::math::Coord::lessThan
static bool lessThan(const Coord &a, const Coord &b)
Definition: Coord.h:224
openvdb::v3_2_0::math::Coord::asPointer
Int32 * asPointer()
Definition: Coord.h:158
openvdb::v3_2_0::math::Coord::round
static Coord round(const Vec3< T > &xyz)
Return xyz rounded to the closest integer coordinates (cell centered conversion). ...
Definition: Coord.h:76
openvdb::v3_2_0::Int32
int32_t Int32
Definition: Types.h:60
openvdb::v3_2_0::Index64
uint64_t Index64
Definition: Types.h:57
openvdb::v3_2_0::math::Coord::operator<
bool operator<(const Coord &rhs) const
Lexicographic less than.
Definition: Coord.h:172
openvdb::v3_2_0::math::Coord::Index32
uint32_t Index32
Definition: Coord.h:51
openvdb::v3_2_0::math::Coord::operator!=
bool operator!=(const Coord &rhs) const
Definition: Coord.h:169
openvdb::v3_2_0::math::operator<<
std::ostream & operator<<(std::ostream &os, const CoordBBox &b)
Definition: Coord.h:542
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_2_0::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:651
openvdb::v3_2_0::math::CoordBBox::resetToCube
void resetToCube(const Coord &min, ValueType dim)
Definition: Coord.h:340
openvdb::v3_2_0::math::Coord::setZ
Coord & setZ(Int32 z)
Definition: Coord.h:103
openvdb::v3_2_0::math::CoordBBox::expand
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:401
openvdb::v3_2_0::math::Coord::Coord
Coord()
Definition: Coord.h:58
openvdb::v3_2_0::math::Coord::Coord
Coord(const Vec3i &v)
Definition: Coord.h:61
openvdb::v3_2_0::math::CoordBBox::operator>>=
CoordBBox & operator>>=(size_t n)
Bit-wise operations performed on both the min and max members.
Definition: Coord.h:464
openvdb::v3_2_0::math::CoordBBox::volume
Index64 volume() const
Return the integer volume of coordinates spanned by this bounding box.
Definition: Coord.h:368
openvdb::v3_2_0::math::CoordBBox::getCornerPoints
void getCornerPoints(Coord *p) const
Populates an array with the eight corner points of this bounding box.
Definition: Coord.h:446
openvdb::v3_2_0::math::CoordBBox::min
Coord & min()
Definition: Coord.h:335
openvdb::v3_2_0::math::CoordBBox::expandBy
CoordBBox expandBy(ValueType padding) const
Return a new instance that is expanded by the specified padding.
Definition: Coord.h:408
openvdb::v3_2_0::math::CoordBBox::extents
Coord extents() const
Definition: Coord.h:365
openvdb::v3_2_0::Vec3I
math::Vec3< Index32 > Vec3I
Definition: Types.h:77
openvdb::v3_2_0::math::Coord::asVec3d
Vec3d asVec3d() const
Definition: Coord.h:159
openvdb::v3_2_0::math::Coord::Vec3i
Vec3< Int32 > Vec3i
Definition: Coord.h:52
openvdb::v3_2_0::math::CoordBBox::translate
void translate(const Coord &t)
Translate this bounding box by .
Definition: Coord.h:440
openvdb::v3_2_0::math::Coord::operator[]
Int32 operator[](size_t i) const
Definition: Coord.h:149
openvdb::v3_2_0::math::Coord::offsetBy
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:111
openvdb::v3_2_0::math::Coord::floor
static Coord floor(const Vec3< T > &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion)...
Definition: Coord.h:82
openvdb
Definition: Exceptions.h:39
openvdb::v3_2_0::math::CoordBBox::Iterator::Iterator
Iterator(const CoordBBox &b)
C-tor from a bounding box.
Definition: Coord.h:273
openvdb::v3_2_0::Index32
uint32_t Index32
Definition: Types.h:56
openvdb::v3_2_0::math::Coord::data
const Int32 * data() const
Definition: Coord.h:155
openvdb::v3_2_0::math::Coord::Coord
Coord(Int32 x, Int32 y, Int32 z)
Definition: Coord.h:60
openvdb::v3_2_0::math::Coord::operator>>=
Coord & operator>>=(size_t n)
Definition: Coord.h:140
openvdb::v3_2_0::math::Coord::operator+
Coord operator+(const Coord &rhs) const
Definition: Coord.h:127
openvdb::v3_2_0::math::Coord::Vec3I
Vec3< Index32 > Vec3I
Definition: Coord.h:53
openvdb::v3_2_0::math::CoordBBox::dim
Coord dim() const
Return the dimensions of the coordinates spanned by this bounding box.
Definition: Coord.h:363
openvdb::v3_2_0::math::CoordBBox::CoordBBox
CoordBBox()
The default constructor produces an empty bounding box.
Definition: Coord.h:305
openvdb::v3_2_0::math::Coord::asVec3i
Vec3i asVec3i() const
Definition: Coord.h:161
openvdb::v3_2_0::math::Coord::z
Int32 z() const
Definition: Coord.h:148
openvdb::v3_2_0::math::CoordBBox::Index64
uint64_t Index64
Definition: Coord.h:262
openvdb::v3_2_0::math::CoordBBox::operator!=
bool operator!=(const CoordBBox &rhs) const
Definition: Coord.h:348
openvdb::v3_2_0::math::Coord::write
void write(std::ostream &os) const
Definition: Coord.h:236
openvdb::v3_2_0::math::Coord::Coord
Coord(const Vec3I &v)
Definition: Coord.h:62
openvdb::v3_2_0::math::Coord::Limits
std::numeric_limits< ValueType > Limits
Definition: Coord.h:56
openvdb::v3_2_0::math::CoordBBox::min
const Coord & min() const
Definition: Coord.h:332
openvdb::v3_2_0::math::Coord::Coord
Coord(Int32 xyz)
Definition: Coord.h:59
openvdb::v3_2_0::math::operator+
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:505
openvdb::v3_2_0::math::Coord::operator>
bool operator>(const Coord &rhs) const
Lexicographic greater than.
Definition: Coord.h:186
openvdb::v3_2_0::math::Coord::maxComponent
static Coord maxComponent(const Coord &lhs, const Coord &rhs)
Return the component-wise maximum of the two Coords.
Definition: Coord.h:215
openvdb::v3_2_0::math::Coord::min
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:69
openvdb::v3_2_0::math::Floor
int Floor(float x)
Return the floor of x.
Definition: Math.h:814
openvdb::v3_2_0::math::CoordBBox::hasOverlap
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:395
openvdb::v3_2_0::math::CoordBBox::max
const Coord & max() const
Definition: Coord.h:333
openvdb::v3_2_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:259
openvdb::v3_2_0::math::Coord::read
void read(std::istream &is)
Definition: Coord.h:235
tbb
Definition: Coord.h:38
openvdb::v3_2_0::math::Coord::offsetBy
Coord offsetBy(Int32 n) const
Definition: Coord.h:115
openvdb::v3_2_0::math::Coord::operator-=
Coord & operator-=(const Coord &rhs)
Definition: Coord.h:122
openvdb::v3_2_0::math::Coord::y
Int32 y() const
Definition: Coord.h:147
openvdb::v3_2_0::math::Coord::operator<=
bool operator<=(const Coord &rhs) const
Lexicographic less than or equal to.
Definition: Coord.h:179
openvdb::v3_2_0::math::MaxIndex
size_t MaxIndex(const Vec3T &v)
Return the index [0,1,2] of the largest value in a 3D vector.
Definition: Math.h:911
openvdb::v3_2_0::math::CoordBBox::CoordBBox
CoordBBox(const Coord &min, const Coord &max)
Construct a bounding box with the given min and max bounds.
Definition: Coord.h:307
openvdb::v3_2_0::math::Coord::x
Int32 & x()
Definition: Coord.h:150
openvdb::v3_2_0::math::CoordBBox::intersect
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:427
openvdb::v3_2_0::math::Coord::Coord
Coord(const Int32 *v)
Definition: Coord.h:66
openvdb::v3_2_0::math::CoordBBox::getEnd
Coord getEnd() const
Definition: Coord.h:345
openvdb::v3_2_0::math::Coord::operator<<=
Coord & operator<<=(size_t n)
Definition: Coord.h:139
openvdb::v3_2_0::math::Coord::data
Int32 * data()
Definition: Coord.h:156
openvdb::v3_2_0::math::CoordBBox::isInside
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:383
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_2_0::math::CoordBBox::Iterator
Iterator over Coord domain covered by a CoordBBox.
Definition: Coord.h:270
openvdb::v3_2_0::math::Coord::operator[]
Int32 & operator[](size_t i)
Definition: Coord.h:153
openvdb::v3_2_0::math::CoordBBox::write
void write(std::ostream &os) const
Serialize this bounding box to the given stream.
Definition: Coord.h:474
openvdb::v3_2_0::math::CoordBBox::getCenter
Vec3d getCenter() const
Return the floating-point position of the center of this bounding box.
Definition: Coord.h:358
openvdb::v3_2_0::math::CoordBBox::empty
bool empty() const
Definition: Coord.h:350
openvdb::v3_2_0::math::operator-
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:531
openvdb::v3_2_0::math::Coord::asPointer
const Int32 * asPointer() const
Definition: Coord.h:157
openvdb::v3_2_0::math::MinIndex
size_t MinIndex(const Vec3T &v)
Return the index [0,1,2] of the smallest value in a 3D vector.
Definition: Math.h:890
openvdb::v3_2_0::math::CoordBBox::hasVolume
bool hasVolume() const
Return true if this bounding box is nonempty.
Definition: Coord.h:354
openvdb::v3_2_0::math::Round
float Round(float x)
Return x rounded to the nearest integer.
Definition: Math.h:785
openvdb::v3_2_0::math::CoordBBox::CoordBBox
CoordBBox(ValueType x_min, ValueType y_min, ValueType z_min, ValueType x_max, ValueType y_max, ValueType z_max)
Construct from individual components of the min and max bounds.
Definition: Coord.h:309
openvdb::v3_2_0::math::CoordBBox::operator<<=
CoordBBox & operator<<=(size_t n)
Bit-wise operations performed on both the min and max members.
Definition: Coord.h:463
openvdb::v3_2_0::math::CoordBBox::createCube
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:324
Platform.h
openvdb::v3_2_0::math::Coord::reset
Coord & reset(Int32 xyz)
Definition: Coord.h:99
openvdb::v3_2_0::tools::composite::min
const boost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128
openvdb::v3_2_0::math::CoordBBox::reset
void reset(const Coord &min, const Coord &max)
Definition: Coord.h:339