OpenVDB: GridDescriptor.h Source File

OpenVDB 3.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

GridDescriptor.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2015 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_GRIDDESCRIPTOR_HAS_BEEN_INCLUDED
32 #define OPENVDB_IO_GRIDDESCRIPTOR_HAS_BEEN_INCLUDED
33
34 #include <openvdb/Grid.h>
35 #include <iostream>
36 #include <boost/cstdint.hpp>
37
38 namespace openvdb {
39 OPENVDB_USE_VERSION_NAMESPACE
40 namespace OPENVDB_VERSION_NAME {
41 namespace io {
42
46 class OPENVDB_API GridDescriptor
47 {
48 public:
49 GridDescriptor();
50 GridDescriptor(const Name& name, const Name& gridType, bool saveFloatAsHalf = false);
51
52 ~GridDescriptor();
53
54 const Name& gridType() const { return mGridType; }
55 const Name& gridName() const { return mGridName; }
56 const Name& uniqueName() const { return mUniqueName; }
57
58 const Name& instanceParentName() const { return mInstanceParentName; }
59 void setInstanceParentName(const Name& name) { mInstanceParentName = name; }
60 bool isInstance() const { return !mInstanceParentName.empty(); }
61
62 bool saveFloatAsHalf() const { return mSaveFloatAsHalf; }
63
64 void setGridPos(boost::int64_t pos) { mGridPos = pos; }
65 boost::int64_t getGridPos() const { return mGridPos; }
66
67 void setBlockPos(boost::int64_t pos) { mBlockPos = pos; }
68 boost::int64_t getBlockPos() const { return mBlockPos; }
69
70 void setEndPos(boost::int64_t pos) { mEndPos = pos; }
71 boost::int64_t getEndPos() const { return mEndPos; }
72
73 // These methods seek to the right position in the given stream.
74 void seekToGrid(std::istream&) const;
75 void seekToBlocks(std::istream&) const;
76 void seekToEnd(std::istream&) const;
77
78 void seekToGrid(std::ostream&) const;
79 void seekToBlocks(std::ostream&) const;
80 void seekToEnd(std::ostream&) const;
81
84 void writeHeader(std::ostream&) const;
85
88 void writeStreamPos(std::ostream&) const;
89
92 GridBase::Ptr read(std::istream&);
93
96 static Name addSuffix(const Name&, int n);
99 static Name stripSuffix(const Name&);
102 static std::string nameAsString(const Name&);
106 static Name stringAsUniqueName(const std::string&);
107
108 private:
110 Name mGridName;
112 Name mUniqueName;
114 Name mInstanceParentName;
116 Name mGridType;
118 bool mSaveFloatAsHalf;
120 boost::int64_t mGridPos;
122 boost::int64_t mBlockPos;
124 boost::int64_t mEndPos;
125 };
126
127 } // namespace io
128 } // namespace OPENVDB_VERSION_NAME
129 } // namespace openvdb
130
131 #endif // OPENVDB_IO_GRIDDESCRIPTOR_HAS_BEEN_INCLUDED
132
133 // Copyright (c) 2012-2015 DreamWorks Animation LLC
134 // All rights reserved. This software is distributed under the
135 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:195
openvdb::v3_1_0::io::GridDescriptor
Definition: GridDescriptor.h:46
openvdb::v3_1_0::io::GridDescriptor::saveFloatAsHalf
bool saveFloatAsHalf() const
Definition: GridDescriptor.h:62
openvdb::v3_1_0::io::GridDescriptor::setEndPos
void setEndPos(boost::int64_t pos)
Definition: GridDescriptor.h:70
openvdb::v3_1_0::GridBase::Ptr
boost::shared_ptr< GridBase > Ptr
Definition: Grid.h:106
openvdb::v3_1_0::io::GridDescriptor::getGridPos
boost::int64_t getGridPos() const
Definition: GridDescriptor.h:65
openvdb::v3_1_0::io::GridDescriptor::setInstanceParentName
void setInstanceParentName(const Name &name)
Definition: GridDescriptor.h:59
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_1_0::io::GridDescriptor::isInstance
bool isInstance() const
Definition: GridDescriptor.h:60
openvdb::v3_1_0::Name
std::string Name
Definition: Name.h:44
openvdb
Definition: Exceptions.h:39
openvdb::v3_1_0::io::GridDescriptor::instanceParentName
const Name & instanceParentName() const
Definition: GridDescriptor.h:58
openvdb::v3_1_0::io::GridDescriptor::gridType
const Name & gridType() const
Definition: GridDescriptor.h:54
openvdb::v3_1_0::io::GridDescriptor::setBlockPos
void setBlockPos(boost::int64_t pos)
Definition: GridDescriptor.h:67
openvdb::v3_1_0::io::GridDescriptor::gridName
const Name & gridName() const
Definition: GridDescriptor.h:55
openvdb::v3_1_0::io::GridDescriptor::getBlockPos
boost::int64_t getBlockPos() const
Definition: GridDescriptor.h:68
Grid.h
openvdb::v3_1_0::io::GridDescriptor::getEndPos
boost::int64_t getEndPos() const
Definition: GridDescriptor.h:71
openvdb::v3_1_0::io::GridDescriptor::setGridPos
void setGridPos(boost::int64_t pos)
Definition: GridDescriptor.h:64
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_1_0::io::GridDescriptor::uniqueName
const Name & uniqueName() const
Definition: GridDescriptor.h:56