OpenVDB: UT_VDBTools.h Source File

OpenVDB 8.0.0

UT_VDBTools.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 //
7
8 #ifndef OPENVDB_HOUDINI_UT_VDBTOOLS_HAS_BEEN_INCLUDED
9 #define OPENVDB_HOUDINI_UT_VDBTOOLS_HAS_BEEN_INCLUDED
10
11 #include <openvdb/openvdb.h>
12 #include <openvdb/tools/GridTransformer.h>
13 #include "Utils.h" // for GridPtr
14
15 namespace openvdb_houdini {
16
38 template<typename Sampler>
39 class GridTransformOp
40 {
41 public:
48 GridTransformOp(GridPtr& outGrid, const openvdb::tools::GridTransformer& t):
49 mOutGrid(outGrid), mTransformer(t) {}
50
51 template<typename GridType>
52 void operator()(const GridType& inGrid)
53 {
54 typename GridType::Ptr outGrid = openvdb::gridPtrCast<GridType>(mOutGrid);
55
56 Interrupter interrupter;
57 mTransformer.setInterrupter(interrupter);
58
59 mTransformer.transformGrid<Sampler, GridType>(inGrid, *outGrid);
60 }
61
62 private:
63 GridPtr mOutGrid;
64 openvdb::tools::GridTransformer mTransformer;
65 };
66
67
69
70
99 template<typename Sampler, typename TransformerType>
100 class GridResampleOp
101 {
102 public:
108 GridResampleOp(GridPtr& outGrid, const TransformerType& t):
109 mOutGrid(outGrid), mTransformer(t) {}
110
111 template<typename GridType>
112 void operator()(const GridType& inGrid)
113 {
114 typename GridType::Ptr outGrid = openvdb::gridPtrCast<GridType>(mOutGrid);
115
116 openvdb::tools::GridResampler resampler;
117
118 Interrupter interrupter;
119 resampler.setInterrupter(interrupter);
120
121 resampler.transformGrid<Sampler>(mTransformer, inGrid, *outGrid);
122 }
123
124 private:
125 GridPtr mOutGrid;
126 const TransformerType mTransformer;
127 };
128
129
131
132
152 template<typename Sampler>
153 class GridResampleToMatchOp
154 {
155 public:
156 GridResampleToMatchOp(GridPtr outGrid): mOutGrid(outGrid) {}
157
158 template<typename GridType>
159 void operator()(const GridType& inGrid)
160 {
161 typename GridType::Ptr outGrid = openvdb::gridPtrCast<GridType>(mOutGrid);
162 Interrupter interrupter;
163 openvdb::tools::resampleToMatch<Sampler>(inGrid, *outGrid, interrupter);
164 }
165
166 private:
167 GridPtr mOutGrid;
168 };
169
170 } // namespace openvdb_houdini
171
172 #endif // OPENVDB_HOUDINI_UT_VDBTOOLS_HAS_BEEN_INCLUDED
openvdb_houdini
Definition: AttributeTransferUtil.h:33
openvdb_houdini::GridResampleOp::operator()
void operator()(const GridType &inGrid)
Definition: UT_VDBTools.h:112
openvdb_houdini::Interrupter
Wrapper class that adapts a Houdini UT_Interrupt object for use with OpenVDB library routines.
Definition: openvdb_houdini/openvdb_houdini/Utils.h:174
openvdb_houdini::GridResampleToMatchOp
GridResampleToMatchOp is a functor class for use with GridBase::apply() that samples an input grid in...
Definition: UT_VDBTools.h:154
openvdb_houdini::GridResampleToMatchOp::operator()
void operator()(const GridType &inGrid)
Definition: UT_VDBTools.h:159
openvdb_houdini::GridTransformOp
GridTransformOp is a functor class for use with GridBase::apply() that samples an input grid into an ...
Definition: UT_VDBTools.h:40
openvdb_houdini::GridResampleToMatchOp::GridResampleToMatchOp
GridResampleToMatchOp(GridPtr outGrid)
Definition: UT_VDBTools.h:156
openvdb_houdini::GridPtr
openvdb::GridBase::Ptr GridPtr
Definition: openvdb_houdini/openvdb_houdini/Utils.h:34
Utils.h
Utility code generation methods for performing various llvm operations.
openvdb_houdini::GridResampleOp
GridResampleOp is a functor class for use with UTvdbProcessTypedGrid() that samples an input grid int...
Definition: UT_VDBTools.h:101
GridTransformer.h
openvdb_houdini::GridResampleOp::GridResampleOp
GridResampleOp(GridPtr &outGrid, const TransformerType &t)
Definition: UT_VDBTools.h:108
openvdb_houdini::GridTransformOp::GridTransformOp
GridTransformOp(GridPtr &outGrid, const openvdb::tools::GridTransformer &t)
Definition: UT_VDBTools.h:48
openvdb_houdini::GridTransformOp::operator()
void operator()(const GridType &inGrid)
Definition: UT_VDBTools.h:52
openvdb.h