OpenVDB 7.0.0

io.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #ifndef OPENVDB_IO_IO_HAS_BEEN_INCLUDED
5 #define OPENVDB_IO_IO_HAS_BEEN_INCLUDED
6
7 #include <openvdb/Platform.h>
8 #include <openvdb/Types.h> // for SharedPtr
9 #include <openvdb/version.h>
10 #include <boost/any.hpp>
11 #include <functional>
12 #include <iosfwd> // for std::ios_base
13 #include <map>
14 #include <memory>
15 #include <string>
16
17 class TestMappedFile;
18
19 namespace openvdb {
20 OPENVDB_USE_VERSION_NAMESPACE
21 namespace OPENVDB_VERSION_NAME {
22
23 class MetaMap;
24
25 namespace io {
26
30 class OPENVDB_API StreamMetadata
31 {
32 public:
33 using Ptr = SharedPtr<StreamMetadata>;
34 using ConstPtr = SharedPtr<const StreamMetadata>;
35
36 StreamMetadata();
37 StreamMetadata(const StreamMetadata&);
38 explicit StreamMetadata(std::ios_base&);
39 ~StreamMetadata();
40
41 StreamMetadata& operator=(const StreamMetadata&);
42
45 void transferTo(std::ios_base&) const;
46
47 uint32_t fileVersion() const;
48 void setFileVersion(uint32_t);
49
50 VersionId libraryVersion() const;
51 void setLibraryVersion(VersionId);
52
53 uint32_t compression() const;
54 void setCompression(uint32_t);
55
56 uint32_t gridClass() const;
57 void setGridClass(uint32_t);
58
59 const void* backgroundPtr() const;
60 void setBackgroundPtr(const void*);
61
62 bool halfFloat() const;
63 void setHalfFloat(bool);
64
65 bool writeGridStats() const;
66 void setWriteGridStats(bool);
67
68 bool seekable() const;
69 void setSeekable(bool);
70
71 bool delayedLoadMeta() const;
72
73 bool countingPasses() const;
74 void setCountingPasses(bool);
75
76 uint32_t pass() const;
77 void setPass(uint32_t);
78
79 uint64_t leaf() const;
80 void setLeaf(uint64_t);
81
83 MetaMap& gridMetadata();
89 const MetaMap& gridMetadata() const;
91
92 using AuxDataMap = std::map<std::string, boost::any>;
94 AuxDataMap& auxData();
96 const AuxDataMap& auxData() const;
98
100 uint32_t __test() const;
102 void __setTest(uint32_t);
103
105 std::string str() const;
106
107 private:
108 struct Impl;
109 std::unique_ptr<Impl> mImpl;
110 }; // class StreamMetadata
111
112
114 std::ostream& operator<<(std::ostream&, const StreamMetadata&);
115
116 std::ostream& operator<<(std::ostream&, const StreamMetadata::AuxDataMap&);
117
118
120
121
124 struct MultiPass {};
125
126
128
129
130 class File;
131
133 class OPENVDB_API MappedFile
134 {
135 public:
136 using Ptr = SharedPtr<MappedFile>;
137
138 ~MappedFile();
139 MappedFile(const MappedFile&) = delete; // not copyable
140 MappedFile& operator=(const MappedFile&) = delete;
141
143 std::string filename() const;
144
154 SharedPtr<std::streambuf> createBuffer() const;
155
156 using Notifier = std::function<void(std::string /*filename*/)>;
159 void setNotifier(const Notifier&);
161 void clearNotifier();
162
163 private:
164 friend class File;
165 friend class ::TestMappedFile;
166
167 explicit MappedFile(const std::string& filename, bool autoDelete = false);
168
169 class Impl;
170 std::unique_ptr<Impl> mImpl;
171 }; // class MappedFile
172
173
175
176
178 std::string getErrorString(int errorNum);
179
180
182 std::string getErrorString();
183
184
186
187
190 OPENVDB_API uint32_t getFormatVersion(std::ios_base&);
191
194 OPENVDB_API VersionId getLibraryVersion(std::ios_base&);
195
198 OPENVDB_API std::string getVersion(std::ios_base&);
199
201 OPENVDB_API void setCurrentVersion(std::istream&);
202
206 OPENVDB_API void setVersion(std::ios_base&, const VersionId& libraryVersion, uint32_t fileVersion);
207
211 OPENVDB_API uint32_t getDataCompression(std::ios_base&);
215 OPENVDB_API void setDataCompression(std::ios_base&, uint32_t compressionFlags);
216
219 OPENVDB_API uint32_t getGridClass(std::ios_base&);
222 OPENVDB_API void setGridClass(std::ios_base&, uint32_t);
223
226 OPENVDB_API bool getHalfFloat(std::ios_base&);
229 OPENVDB_API void setHalfFloat(std::ios_base&, bool);
230
233 OPENVDB_API const void* getGridBackgroundValuePtr(std::ios_base&);
237 OPENVDB_API void setGridBackgroundValuePtr(std::ios_base&, const void* background);
238
241 OPENVDB_API bool getWriteGridStatsMetadata(std::ios_base&);
244 OPENVDB_API void setWriteGridStatsMetadata(std::ios_base&, bool writeGridStats);
245
248 OPENVDB_API SharedPtr<MappedFile> getMappedFilePtr(std::ios_base&);
252 OPENVDB_API void setMappedFilePtr(std::ios_base&, SharedPtr<MappedFile>&);
253
256 OPENVDB_API SharedPtr<StreamMetadata> getStreamMetadataPtr(std::ios_base&);
264 OPENVDB_API void setStreamMetadataPtr(std::ios_base&,
265 SharedPtr<StreamMetadata>&, bool transfer = true);
268 OPENVDB_API SharedPtr<StreamMetadata> clearStreamMetadataPtr(std::ios_base&);
269
270 } // namespace io
271 } // namespace OPENVDB_VERSION_NAME
272 } // namespace openvdb
273
274 #endif // OPENVDB_IO_IO_HAS_BEEN_INCLUDED
openvdb::v7_0::io::setGridClass
OPENVDB_API void setGridClass(std::ios_base &, uint32_t)
Associate with the given stream the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently ...
openvdb::v7_0::io::File
Grid archive associated with a file on disk.
Definition: File.h:30
openvdb::v7_0::io::MappedFile
Handle to control the lifetime of a memory-mapped .vdb file.
Definition: io.h:133
openvdb::v7_0::io::getHalfFloat
OPENVDB_API bool getHalfFloat(std::ios_base &)
Return true if floating-point values should be quantized to 16 bits when writing to the given stream ...
Types.h
openvdb::v7_0::io::MappedFile::Ptr
SharedPtr< MappedFile > Ptr
Definition: io.h:136
openvdb::v7_0::io::getVersion
OPENVDB_API std::string getVersion(std::ios_base &)
Return a string of the form "<major>.<minor>/<format>", giving the library and file format version nu...
openvdb::v7_0::io::setCurrentVersion
OPENVDB_API void setCurrentVersion(std::istream &)
Associate the current file format and library version numbers with the given input stream.
openvdb::v7_0::io::setGridBackgroundValuePtr
OPENVDB_API void setGridBackgroundValuePtr(std::ios_base &, const void *background)
Specify (a pointer to) the background value of the grid currently being read from or written to the g...
openvdb::v7_0::io::operator<<
std::ostream & operator<<(std::ostream &, const StreamMetadata::AuxDataMap &)
version.h
Library and file format version numbers.
openvdb::v7_0::VersionId
Definition: version.h:210
Platform.h
openvdb::v7_0::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
openvdb::v7_0::io::setDataCompression
OPENVDB_API void setDataCompression(std::ios_base &, uint32_t compressionFlags)
Associate with the given stream a bitwise OR of compression option flags (COMPRESS_ZIP,...
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:230
openvdb::v7_0::io::getDataCompression
OPENVDB_API uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK,...
openvdb::v7_0::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:19
openvdb::v7_0::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::v7_0::io::setMappedFilePtr
OPENVDB_API void setMappedFilePtr(std::ios_base &, SharedPtr< MappedFile > &)
Associate the given stream with (a shared pointer to) a memory-mapped file.
openvdb::v7_0::io::clearStreamMetadataPtr
OPENVDB_API SharedPtr< StreamMetadata > clearStreamMetadataPtr(std::ios_base &)
Dissociate the given stream from its metadata object (if it has one) and return a shared pointer to t...
openvdb::v7_0::io::setStreamMetadataPtr
OPENVDB_API void setStreamMetadataPtr(std::ios_base &, SharedPtr< StreamMetadata > &, bool transfer=true)
Associate the given stream with (a shared pointer to) an object that stores metadata (file format,...
openvdb::v7_0::io::StreamMetadata::ConstPtr
SharedPtr< const StreamMetadata > ConstPtr
Definition: io.h:34
openvdb::v7_0::io::getErrorString
std::string getErrorString()
Return a string (possibly empty) describing the most recent system error.
openvdb::v7_0::io::getLibraryVersion
OPENVDB_API VersionId getLibraryVersion(std::ios_base &)
Return the (major, minor) library version number associated with the given input stream.
openvdb::v7_0::io::MultiPass
Leaf nodes that require multi-pass I/O must inherit from this struct.
Definition: io.h:124
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
openvdb::v7_0::io::StreamMetadata
Container for metadata describing how to unserialize grids from and/or serialize grids to a stream (w...
Definition: io.h:30
openvdb::v7_0::io::getWriteGridStatsMetadata
OPENVDB_API bool getWriteGridStatsMetadata(std::ios_base &)
Return true if grid statistics (active voxel count and bounding box, etc.) should be computed and sto...
openvdb::v7_0::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v7_0::io::MappedFile::Notifier
std::function< void(std::string)> Notifier
Definition: io.h:156
openvdb::v7_0::io::getMappedFilePtr
OPENVDB_API SharedPtr< MappedFile > getMappedFilePtr(std::ios_base &)
Return a shared pointer to the memory-mapped file with which the given stream is associated,...
openvdb::v7_0::io::getGridBackgroundValuePtr
const OPENVDB_API 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_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
openvdb::v7_0::io::setHalfFloat
OPENVDB_API void setHalfFloat(std::ios_base &, bool)
Specify whether floating-point values should be quantized to 16 bits when writing to the given stream...
openvdb::v7_0::io::getGridClass
OPENVDB_API uint32_t getGridClass(std::ios_base &)
Return the class (GRID_LEVEL_SET, GRID_UNKNOWN, etc.) of the grid currently being read from or writte...
openvdb
Definition: Exceptions.h:13
openvdb::v7_0::io::setVersion
OPENVDB_API void setVersion(std::ios_base &, const VersionId &libraryVersion, uint32_t fileVersion)
Associate specific file format and library version numbers with the given stream.
openvdb::v7_0::io::StreamMetadata::Ptr
SharedPtr< StreamMetadata > Ptr
Definition: io.h:33
openvdb::v7_0::io::StreamMetadata::AuxDataMap
std::map< std::string, boost::any > AuxDataMap
Definition: io.h:92
openvdb::v7_0::io::setWriteGridStatsMetadata
OPENVDB_API void setWriteGridStatsMetadata(std::ios_base &, bool writeGridStats)
Specify whether to compute grid statistics (active voxel count and bounding box, etc....