OpenVDB 5.1.0

Compression.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2018 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_IO_COMPRESSION_HAS_BEEN_INCLUDED
32 #define OPENVDB_IO_COMPRESSION_HAS_BEEN_INCLUDED
33
34 #include <openvdb/Types.h>
35 #include <openvdb/math/Math.h> // for negative()
36 #include "io.h" // for getDataCompression(), etc.
37 #include <algorithm>
38 #include <iostream>
39 #include <memory>
40 #include <string>
41 #include <vector>
42
43
44 namespace openvdb {
45 OPENVDB_USE_VERSION_NAMESPACE
46 namespace OPENVDB_VERSION_NAME {
47 namespace io {
48
77 enum {
78 COMPRESS_NONE = 0,
79 COMPRESS_ZIP = 0x1,
80 COMPRESS_ACTIVE_MASK = 0x2,
81 COMPRESS_BLOSC = 0x4
82 };
83
85 OPENVDB_API std::string compressionToString(uint32_t flags);
86
87
89
90
93 enum {
94 /*0*/ NO_MASK_OR_INACTIVE_VALS, // no inactive vals, or all inactive vals are +background
95 /*1*/ NO_MASK_AND_MINUS_BG, // all inactive vals are -background
96 /*2*/ NO_MASK_AND_ONE_INACTIVE_VAL, // all inactive vals have the same non-background val
97 /*3*/ MASK_AND_NO_INACTIVE_VALS, // mask selects between -background and +background
98 /*4*/ MASK_AND_ONE_INACTIVE_VAL, // mask selects between backgd and one other inactive val
99 /*5*/ MASK_AND_TWO_INACTIVE_VALS, // mask selects between two non-background inactive vals
100 /*6*/ NO_MASK_AND_ALL_VALS // > 2 inactive vals, so no mask compression at all
101 };
102
103
105
106
109 template<typename T>
110 struct RealToHalf {
111 enum { isReal = false }; // unless otherwise specified, type T is not a floating-point type
112 using HalfT = T; // type T's half float analogue is T itself
113 static HalfT convert(const T& val) { return val; }
114 };
115 template<> struct RealToHalf<float> {
116 enum { isReal = true };
117 using HalfT = half;
118 static HalfT convert(float val) { return HalfT(val); }
119 };
120 template<> struct RealToHalf<double> {
121 enum { isReal = true };
122 using HalfT = half;
123 // A half can only be constructed from a float, so cast the value to a float first.
124 static HalfT convert(double val) { return HalfT(float(val)); }
125 };
126 template<> struct RealToHalf<Vec2s> {
127 enum { isReal = true };
128 using HalfT = Vec2H;
129 static HalfT convert(const Vec2s& val) { return HalfT(val); }
130 };
131 template<> struct RealToHalf<Vec2d> {
132 enum { isReal = true };
133 using HalfT = Vec2H;
134 // A half can only be constructed from a float, so cast the vector's elements to floats first.
135 static HalfT convert(const Vec2d& val) { return HalfT(Vec2s(val)); }
136 };
137 template<> struct RealToHalf<Vec3s> {
138 enum { isReal = true };
139 using HalfT = Vec3H;
140 static HalfT convert(const Vec3s& val) { return HalfT(val); }
141 };
142 template<> struct RealToHalf<Vec3d> {
143 enum { isReal = true };
144 using HalfT = Vec3H;
145 // A half can only be constructed from a float, so cast the vector's elements to floats first.
146 static HalfT convert(const Vec3d& val) { return HalfT(Vec3s(val)); }
147 };
148
149
151 template<typename T>
152 inline T
153 truncateRealToHalf(const T& val)
154 {
155 return T(RealToHalf<T>::convert(val));
156 }
157
158
160
161
162 OPENVDB_API void zipToStream(std::ostream&, const char* data, size_t numBytes);
163 OPENVDB_API void unzipFromStream(std::istream&, char* data, size_t numBytes);
164 OPENVDB_API void bloscToStream(std::ostream&, const char* data, size_t valSize, size_t numVals);
165 OPENVDB_API void bloscFromStream(std::istream&, char* data, size_t numBytes);
166
177 template<typename T>
178 inline void
179 readData(std::istream& is, T* data, Index count, uint32_t compression)
180 {
181 if (compression & COMPRESS_BLOSC) {
182 bloscFromStream(is, reinterpret_cast<char*>(data), sizeof(T) * count);
183 } else if (compression & COMPRESS_ZIP) {
184 unzipFromStream(is, reinterpret_cast<char*>(data), sizeof(T) * count);
185 } else {
186 if (data == nullptr) {
187 assert(!getStreamMetadataPtr(is) || getStreamMetadataPtr(is)->seekable());
188 is.seekg(sizeof(T) * count, std::ios_base::cur);
189 } else {
190 is.read(reinterpret_cast<char*>(data), sizeof(T) * count);
191 }
192 }
193 }
194
196 template<>
197 inline void
198 readData<std::string>(std::istream& is, std::string* data, Index count, uint32_t /*compression*/)
199 {
200 for (Index i = 0; i < count; ++i) {
201 size_t len = 0;
202 is >> len;
203 //data[i].resize(len);
204 //is.read(&(data[i][0]), len);
205
206 std::string buffer(len+1, ' ');
207 is.read(&buffer[0], len+1);
208 if (data != nullptr) data[i].assign(buffer, 0, len);
209 }
210 }
211
216 template<bool IsReal, typename T> struct HalfReader;
218 template<typename T>
219 struct HalfReader</*IsReal=*/false, T> {
220 static inline void read(std::istream& is, T* data, Index count, uint32_t compression) {
221 readData(is, data, count, compression);
222 }
223 };
225 template<typename T>
226 struct HalfReader</*IsReal=*/true, T> {
227 using HalfT = typename RealToHalf<T>::HalfT;
228 static inline void read(std::istream& is, T* data, Index count, uint32_t compression) {
229 if (count < 1) return;
230 if (data == nullptr) {
231 // seek mode - pass through null pointer
232 readData<HalfT>(is, nullptr, count, compression);
233 } else {
234 std::vector<HalfT> halfData(count); // temp buffer into which to read half float values
235 readData<HalfT>(is, reinterpret_cast<HalfT*>(&halfData[0]), count, compression);
236 // Copy half float values from the temporary buffer to the full float output array.
237 std::copy(halfData.begin(), halfData.end(), data);
238 }
239 }
240 };
241
242
253 template<typename T>
254 inline void
255 writeData(std::ostream &os, const T *data, Index count, uint32_t compression)
256 {
257 if (compression & COMPRESS_BLOSC) {
258 bloscToStream(os, reinterpret_cast<const char*>(data), sizeof(T), count);
259 } else if (compression & COMPRESS_ZIP) {
260 zipToStream(os, reinterpret_cast<const char*>(data), sizeof(T) * count);
261 } else {
262 os.write(reinterpret_cast<const char*>(data), sizeof(T) * count);
263 }
264 }
265
267 template<>
268 inline void
269 writeData<std::string>(std::ostream& os, const std::string* data, Index count,
270 uint32_t /*compression*/)
271 {
272 for (Index i = 0; i < count; ++i) {
273 const size_t len = data[i].size();
274 os << len;
275 os.write(data[i].c_str(), len+1);
276 //os.write(&(data[i][0]), len );
277 }
278 }
279
284 template<bool IsReal, typename T> struct HalfWriter;
286 template<typename T>
287 struct HalfWriter</*IsReal=*/false, T> {
288 static inline void write(std::ostream& os, const T* data, Index count, uint32_t compression) {
289 writeData(os, data, count, compression);
290 }
291 };
293 template<typename T>
294 struct HalfWriter</*IsReal=*/true, T> {
295 using HalfT = typename RealToHalf<T>::HalfT;
296 static inline void write(std::ostream& os, const T* data, Index count, uint32_t compression) {
297 if (count < 1) return;
298 // Convert full float values to half float, then output the half float array.
299 std::vector<HalfT> halfData(count);
300 for (Index i = 0; i < count; ++i) halfData[i] = RealToHalf<T>::convert(data[i]);
301 writeData<HalfT>(os, reinterpret_cast<const HalfT*>(&halfData[0]), count, compression);
302 }
303 };
304 #ifdef _MSC_VER
305 template<>
307 struct HalfWriter</*IsReal=*/true, double> {
308 using HalfT = RealToHalf<double>::HalfT;
309 static inline void write(std::ostream& os, const double* data, Index count,
310 uint32_t compression)
311 {
312 if (count < 1) return;
313 // Convert full float values to half float, then output the half float array.
314 std::vector<HalfT> halfData(count);
315 for (Index i = 0; i < count; ++i) halfData[i] = RealToHalf<double>::convert(data[i]);
316 writeData<HalfT>(os, reinterpret_cast<const HalfT*>(&halfData[0]), count, compression);
317 }
318 };
319 #endif // _MSC_VER
320
321
323
324
337 template<typename ValueT, typename MaskT>
338 inline void
339 readCompressedValues(std::istream& is, ValueT* destBuf, Index destCount,
340 const MaskT& valueMask, bool fromHalf)
341 {
342 // Get the stream's compression settings.
343 const uint32_t compression = getDataCompression(is);
344 const bool maskCompressed = compression & COMPRESS_ACTIVE_MASK;
345
346 const bool seek = (destBuf == nullptr);
347 assert(!seek || (!getStreamMetadataPtr(is) || getStreamMetadataPtr(is)->seekable()));
348
349 int8_t metadata = NO_MASK_AND_ALL_VALS;
350 if (getFormatVersion(is) >= OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION) {
351 // Read the flag that specifies what, if any, additional metadata
352 // (selection mask and/or inactive value(s)) is saved.
353 if (seek && !maskCompressed) {
354 is.seekg(/*bytes=*/1, std::ios_base::cur);
355 } else {
356 is.read(reinterpret_cast<char*>(&metadata), /*bytes=*/1);
357 }
358 }
359
360 ValueT background = zeroVal<ValueT>();
361 if (const void* bgPtr = getGridBackgroundValuePtr(is)) {
362 background = *static_cast<const ValueT*>(bgPtr);
363 }
364 ValueT inactiveVal1 = background;
365 ValueT inactiveVal0 =
366 ((metadata == NO_MASK_OR_INACTIVE_VALS) ? background : math::negative(background));
367
368 if (metadata == NO_MASK_AND_ONE_INACTIVE_VAL ||
369 metadata == MASK_AND_ONE_INACTIVE_VAL ||
370 metadata == MASK_AND_TWO_INACTIVE_VALS)
371 {
372 // Read one of at most two distinct inactive values.
373 if (seek) {
374 is.seekg(/*bytes=*/sizeof(ValueT), std::ios_base::cur);
375 } else {
376 is.read(reinterpret_cast<char*>(&inactiveVal0), /*bytes=*/sizeof(ValueT));
377 }
378 if (metadata == MASK_AND_TWO_INACTIVE_VALS) {
379 // Read the second of two distinct inactive values.
380 if (seek) {
381 is.seekg(/*bytes=*/sizeof(ValueT), std::ios_base::cur);
382 } else {
383 is.read(reinterpret_cast<char*>(&inactiveVal1), /*bytes=*/sizeof(ValueT));
384 }
385 }
386 }
387
388 MaskT selectionMask;
389 if (metadata == MASK_AND_NO_INACTIVE_VALS ||
390 metadata == MASK_AND_ONE_INACTIVE_VAL ||
391 metadata == MASK_AND_TWO_INACTIVE_VALS)
392 {
393 // For use in mask compression (only), read the bitmask that selects
394 // between two distinct inactive values.
395 if (seek) {
396 is.seekg(/*bytes=*/selectionMask.memUsage(), std::ios_base::cur);
397 } else {
398 selectionMask.load(is);
399 }
400 }
401
402 ValueT* tempBuf = destBuf;
403 std::unique_ptr<ValueT[]> scopedTempBuf;
404
405 Index tempCount = destCount;
406
407 if (maskCompressed && metadata != NO_MASK_AND_ALL_VALS
408 && getFormatVersion(is) >= OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION)
409 {
410 tempCount = valueMask.countOn();
411 if (!seek && tempCount != destCount) {
412 // If this node has inactive voxels, allocate a temporary buffer
413 // into which to read just the active values.
414 scopedTempBuf.reset(new ValueT[tempCount]);
415 tempBuf = scopedTempBuf.get();
416 }
417 }
418
419 // Read in the buffer.
420 if (fromHalf) {
421 HalfReader<RealToHalf<ValueT>::isReal, ValueT>::read(
422 is, (seek ? nullptr : tempBuf), tempCount, compression);
423 } else {
424 readData<ValueT>(is, (seek ? nullptr : tempBuf), tempCount, compression);
425 }
426
427 // If mask compression is enabled and the number of active values read into
428 // the temp buffer is smaller than the size of the destination buffer,
429 // then there are missing (inactive) values.
430 if (!seek && maskCompressed && tempCount != destCount) {
431 // Restore inactive values, using the background value and, if available,
432 // the inside/outside mask. (For fog volumes, the destination buffer is assumed
433 // to be initialized to background value zero, so inactive values can be ignored.)
434 for (Index destIdx = 0, tempIdx = 0; destIdx < MaskT::SIZE; ++destIdx) {
435 if (valueMask.isOn(destIdx)) {
436 // Copy a saved active value into this node's buffer.
437 destBuf[destIdx] = tempBuf[tempIdx];
438 ++tempIdx;
439 } else {
440 // Reconstruct an unsaved inactive value and copy it into this node's buffer.
441 destBuf[destIdx] = (selectionMask.isOn(destIdx) ? inactiveVal1 : inactiveVal0);
442 }
443 }
444 }
445 }
446
447
460 template<typename ValueT, typename MaskT>
461 inline void
462 writeCompressedValues(std::ostream& os, ValueT* srcBuf, Index srcCount,
463 const MaskT& valueMask, const MaskT& childMask, bool toHalf)
464 {
465 struct Local {
466 // Comparison function for values
467 static inline bool eq(const ValueT& a, const ValueT& b) {
468 return math::isExactlyEqual(a, b);
469 }
470 };
471
472 // Get the stream's compression settings.
473 const uint32_t compress = getDataCompression(os);
474 const bool maskCompress = compress & COMPRESS_ACTIVE_MASK;
475
476 Index tempCount = srcCount;
477 ValueT* tempBuf = srcBuf;
478 std::unique_ptr<ValueT[]> scopedTempBuf;
479
480 int8_t metadata = NO_MASK_AND_ALL_VALS;
481
482 if (!maskCompress) {
483 os.write(reinterpret_cast<const char*>(&metadata), /*bytes=*/1);
484 } else {
485 // A valid level set's inactive values are either +background (outside)
486 // or -background (inside), and a fog volume's inactive values are all zero.
487 // Rather than write out all of these values, we can store just the active values
488 // (given that the value mask specifies their positions) and, if necessary,
489 // an inside/outside bitmask.
490
491 const ValueT zero = zeroVal<ValueT>();
492 ValueT background = zero;
493 if (const void* bgPtr = getGridBackgroundValuePtr(os)) {
494 background = *static_cast<const ValueT*>(bgPtr);
495 }
496
498 ValueT inactiveVal[2] = { background, background };
499 int numUniqueInactiveVals = 0;
500 for (typename MaskT::OffIterator it = valueMask.beginOff();
501 numUniqueInactiveVals < 3 && it; ++it)
502 {
503 const Index32 idx = it.pos();
504
505 // Skip inactive values that are actually child node pointers.
506 if (childMask.isOn(idx)) continue;
507
508 const ValueT& val = srcBuf[idx];
509 const bool unique = !(
510 (numUniqueInactiveVals > 0 && Local::eq(val, inactiveVal[0])) ||
511 (numUniqueInactiveVals > 1 && Local::eq(val, inactiveVal[1]))
512 );
513 if (unique) {
514 if (numUniqueInactiveVals < 2) inactiveVal[numUniqueInactiveVals] = val;
515 ++numUniqueInactiveVals;
516 }
517 }
518
519 metadata = NO_MASK_OR_INACTIVE_VALS;
520
521 if (numUniqueInactiveVals == 1) {
522 if (!Local::eq(inactiveVal[0], background)) {
523 if (Local::eq(inactiveVal[0], math::negative(background))) {
524 metadata = NO_MASK_AND_MINUS_BG;
525 } else {
526 metadata = NO_MASK_AND_ONE_INACTIVE_VAL;
527 }
528 }
529 } else if (numUniqueInactiveVals == 2) {
530 metadata = NO_MASK_OR_INACTIVE_VALS;
531 if (!Local::eq(inactiveVal[0], background) && !Local::eq(inactiveVal[1], background)) {
532 // If neither inactive value is equal to the background, both values
533 // need to be saved, along with a mask that selects between them.
534 metadata = MASK_AND_TWO_INACTIVE_VALS;
535
536 } else if (Local::eq(inactiveVal[1], background)) {
537 if (Local::eq(inactiveVal[0], math::negative(background))) {
538 // If the second inactive value is equal to the background and
539 // the first is equal to -background, neither value needs to be saved,
540 // but save a mask that selects between -background and +background.
541 metadata = MASK_AND_NO_INACTIVE_VALS;
542 } else {
543 // If the second inactive value is equal to the background, only
544 // the first value needs to be saved, along with a mask that selects
545 // between it and the background.
546 metadata = MASK_AND_ONE_INACTIVE_VAL;
547 }
548 } else if (Local::eq(inactiveVal[0], background)) {
549 if (Local::eq(inactiveVal[1], math::negative(background))) {
550 // If the first inactive value is equal to the background and
551 // the second is equal to -background, neither value needs to be saved,
552 // but save a mask that selects between -background and +background.
553 metadata = MASK_AND_NO_INACTIVE_VALS;
554 std::swap(inactiveVal[0], inactiveVal[1]);
555 } else {
556 // If the first inactive value is equal to the background, swap it
557 // with the second value and save only that value, along with a mask
558 // that selects between it and the background.
559 std::swap(inactiveVal[0], inactiveVal[1]);
560 metadata = MASK_AND_ONE_INACTIVE_VAL;
561 }
562 }
563 } else if (numUniqueInactiveVals > 2) {
564 metadata = NO_MASK_AND_ALL_VALS;
565 }
566
567 os.write(reinterpret_cast<const char*>(&metadata), /*bytes=*/1);
568
569 if (metadata == NO_MASK_AND_ONE_INACTIVE_VAL ||
570 metadata == MASK_AND_ONE_INACTIVE_VAL ||
571 metadata == MASK_AND_TWO_INACTIVE_VALS)
572 {
573 if (!toHalf) {
574 // Write one of at most two distinct inactive values.
575 os.write(reinterpret_cast<const char*>(&inactiveVal[0]), sizeof(ValueT));
576 if (metadata == MASK_AND_TWO_INACTIVE_VALS) {
577 // Write the second of two distinct inactive values.
578 os.write(reinterpret_cast<const char*>(&inactiveVal[1]), sizeof(ValueT));
579 }
580 } else {
581 // Write one of at most two distinct inactive values.
582 ValueT truncatedVal = static_cast<ValueT>(truncateRealToHalf(inactiveVal[0]));
583 os.write(reinterpret_cast<const char*>(&truncatedVal), sizeof(ValueT));
584 if (metadata == MASK_AND_TWO_INACTIVE_VALS) {
585 // Write the second of two distinct inactive values.
586 truncatedVal = truncateRealToHalf(inactiveVal[1]);
587 os.write(reinterpret_cast<const char*>(&truncatedVal), sizeof(ValueT));
588 }
589 }
590 }
591
592 if (metadata == NO_MASK_AND_ALL_VALS) {
593 // If there are more than two unique inactive values, the entire input buffer
594 // needs to be saved (both active and inactive values).
597 } else {
598 // Create a new array to hold just the active values.
599 scopedTempBuf.reset(new ValueT[srcCount]);
600 tempBuf = scopedTempBuf.get();
601
602 if (metadata == NO_MASK_OR_INACTIVE_VALS ||
603 metadata == NO_MASK_AND_MINUS_BG ||
604 metadata == NO_MASK_AND_ONE_INACTIVE_VAL)
605 {
606 // Copy active values to the contiguous array.
607 tempCount = 0;
608 for (typename MaskT::OnIterator it = valueMask.beginOn(); it; ++it, ++tempCount) {
609 tempBuf[tempCount] = srcBuf[it.pos()];
610 }
611 } else {
612 // Copy active values to a new, contiguous array and populate a bitmask
613 // that selects between two distinct inactive values.
614 MaskT selectionMask;
615 tempCount = 0;
616 for (Index srcIdx = 0; srcIdx < srcCount; ++srcIdx) {
617 if (valueMask.isOn(srcIdx)) { // active value
618 tempBuf[tempCount] = srcBuf[srcIdx];
619 ++tempCount;
620 } else { // inactive value
621 if (Local::eq(srcBuf[srcIdx], inactiveVal[1])) {
622 selectionMask.setOn(srcIdx); // inactive value 1
623 } // else inactive value 0
624 }
625 }
626 assert(tempCount == valueMask.countOn());
627
628 // Write out the mask that selects between two inactive values.
629 selectionMask.save(os);
630 }
631 }
632 }
633
634 // Write out the buffer.
635 if (toHalf) {
636 HalfWriter<RealToHalf<ValueT>::isReal, ValueT>::write(os, tempBuf, tempCount, compress);
637 } else {
638 writeData(os, tempBuf, tempCount, compress);
639 }
640 }
641
642 } // namespace io
643 } // namespace OPENVDB_VERSION_NAME
644 } // namespace openvdb
645
646 #endif // OPENVDB_IO_COMPRESSION_HAS_BEEN_INCLUDED
647
648 // Copyright (c) 2012-2018 DreamWorks Animation LLC
649 // All rights reserved. This software is distributed under the
650 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v5_1::math::isExactlyEqual
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:395
openvdb::v5_1::Index32
uint32_t Index32
Definition: Types.h:59
openvdb::v5_1::io::RealToHalf< Vec2s >::convert
static HalfT convert(const Vec2s &val)
Definition: Compression.h:129
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:194
openvdb::v5_1::io::bloscFromStream
OPENVDB_API void bloscFromStream(std::istream &, char *data, size_t numBytes)
openvdb::v5_1::io::NO_MASK_AND_ALL_VALS
Definition: Compression.h:100
openvdb::v5_1::io::readCompressedValues
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:339
Types.h
openvdb::v5_1::io::COMPRESS_ACTIVE_MASK
Definition: Compression.h:80
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v5_1::io::readData
void readData(std::istream &is, T *data, Index count, uint32_t compression)
Read data from a stream.
Definition: Compression.h:179
openvdb::v5_1::io::RealToHalf< float >::convert
static HalfT convert(float val)
Definition: Compression.h:118
openvdb::v5_1::io::RealToHalf::HalfT
T HalfT
Definition: Compression.h:112
openvdb::v5_1::Vec2H
math::Vec2< half > Vec2H
Definition: Types.h:73
openvdb::v5_1::io::HalfWriter< true, T >::write
static void write(std::ostream &os, const T *data, Index count, uint32_t compression)
Definition: Compression.h:296
openvdb::v5_1::io::HalfReader
Definition: Compression.h:216
openvdb::v5_1::math::negative
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:108
openvdb::v5_1::io::RealToHalf::convert
static HalfT convert(const T &val)
Definition: Compression.h:113
openvdb::v5_1::io::truncateRealToHalf
T truncateRealToHalf(const T &val)
Return the given value truncated to 16-bit float precision.
Definition: Compression.h:153
openvdb::v5_1::io::RealToHalf< Vec3s >::convert
static HalfT convert(const Vec3s &val)
Definition: Compression.h:140
openvdb::v5_1::math::Vec3
Definition: Mat.h:197
openvdb::v5_1::io::COMPRESS_NONE
Definition: Compression.h:78
openvdb::v5_1::io::getDataCompression
OPENVDB_API uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK, etc.) specifying whether and how input data is compressed or output data should be compressed.
openvdb::v5_1::io::HalfWriter< true, T >::HalfT
typename RealToHalf< T >::HalfT HalfT
Definition: Compression.h:295
io.h
openvdb::v5_1::math::Vec2d
Vec2< double > Vec2d
Definition: Vec2.h:559
openvdb::v5_1::io::RealToHalf< Vec2d >::convert
static HalfT convert(const Vec2d &val)
Definition: Compression.h:135
openvdb::v5_1::io::RealToHalf< double >::convert
static HalfT convert(double val)
Definition: Compression.h:124
openvdb::v5_1::io::RealToHalf< Vec3d >::convert
static HalfT convert(const Vec3d &val)
Definition: Compression.h:146
openvdb::v5_1::io::getGridBackgroundValuePtr
OPENVDB_API const void * getGridBackgroundValuePtr(std::ios_base &)
Return a pointer to the background value of the grid currently being read from or written to the give...
openvdb::v5_1::io::HalfWriter
Definition: Compression.h:284
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb::v5_1::io::NO_MASK_AND_ONE_INACTIVE_VAL
Definition: Compression.h:96
openvdb::v5_1::io::RealToHalf< double >::HalfT
half HalfT
Definition: Compression.h:122
openvdb::v5_1::io::RealToHalf
RealToHalf and its specializations define a mapping from floating-point data types to analogous half ...
Definition: Compression.h:110
openvdb::v5_1::io::compressionToString
OPENVDB_API std::string compressionToString(uint32_t flags)
Return a string describing the given compression flags.
openvdb::v5_1::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:679
openvdb::v5_1::io::COMPRESS_BLOSC
Definition: Compression.h:81
openvdb::v5_1::io::MASK_AND_ONE_INACTIVE_VAL
Definition: Compression.h:98
openvdb
Definition: Exceptions.h:40
openvdb::v5_1::io::COMPRESS_ZIP
Definition: Compression.h:79
openvdb::v5_1::io::writeData
void writeData(std::ostream &os, const T *data, Index count, uint32_t compression)
Definition: Compression.h:255
openvdb::v5_1::io::getStreamMetadataPtr
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme...
openvdb::v5_1::io::NO_MASK_OR_INACTIVE_VALS
Definition: Compression.h:94
openvdb::v5_1::math::Vec3s
Vec3< float > Vec3s
Definition: Vec3.h:678
openvdb::v5_1::io::writeCompressedValues
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:462
openvdb::v5_1::io::HalfReader< true, T >::HalfT
typename RealToHalf< T >::HalfT HalfT
Definition: Compression.h:227
openvdb::v5_1::io::bloscToStream
OPENVDB_API void bloscToStream(std::ostream &, const char *data, size_t valSize, size_t numVals)
openvdb::v5_1::io::MASK_AND_TWO_INACTIVE_VALS
Definition: Compression.h:99
openvdb::v5_1::io::MASK_AND_NO_INACTIVE_VALS
Definition: Compression.h:97
openvdb::v5_1::io::RealToHalf< float >::HalfT
half HalfT
Definition: Compression.h:117
openvdb::v5_1::io::zipToStream
OPENVDB_API void zipToStream(std::ostream &, const char *data, size_t numBytes)
openvdb::v5_1::io::HalfReader< true, T >::read
static void read(std::istream &is, T *data, Index count, uint32_t compression)
Definition: Compression.h:228
openvdb::v5_1::io::HalfWriter< false, T >::write
static void write(std::ostream &os, const T *data, Index count, uint32_t compression)
Definition: Compression.h:288
openvdb::v5_1::math::Vec2
Definition: Vec2.h:50
openvdb::v5_1::io::HalfReader< false, T >::read
static void read(std::istream &is, T *data, Index count, uint32_t compression)
Definition: Compression.h:220
openvdb::v5_1::io::unzipFromStream
OPENVDB_API void unzipFromStream(std::istream &, char *data, size_t numBytes)
openvdb::v5_1::Vec3H
math::Vec3< half > Vec3H
Definition: Types.h:82
openvdb::v5_1::math::Vec2s
Vec2< float > Vec2s
Definition: Vec2.h:558
openvdb::v5_1::Index
Index32 Index
Definition: Types.h:61
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v5_1::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v5_1::OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION
Definition: version.h:229
openvdb::v5_1::io::NO_MASK_AND_MINUS_BG
Definition: Compression.h:95