OpenVDB  8.1.1
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>
13 #include "Utils.h" // for GridPtr
14 
15 namespace openvdb_houdini {
16 
38 template<typename Sampler>
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>
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>
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
GridResampleToMatchOp(GridPtr outGrid)
Definition: UT_VDBTools.h:156
GridResampleOp is a functor class for use with UTvdbProcessTypedGrid() that samples an input grid int...
Definition: UT_VDBTools.h:100
GridResampleOp(GridPtr &outGrid, const TransformerType &t)
Definition: UT_VDBTools.h:108
Utility classes and functions for OpenVDB plugins.
openvdb::GridBase::Ptr GridPtr
Definition: openvdb_houdini/openvdb_houdini/Utils.h:34
GridTransformOp is a functor class for use with GridBase::apply() that samples an input grid into an ...
Definition: UT_VDBTools.h:39
GridTransformOp(GridPtr &outGrid, const openvdb::tools::GridTransformer &t)
Definition: UT_VDBTools.h:48
Wrapper class that adapts a Houdini UT_Interrupt object for use with OpenVDB library routines...
Definition: openvdb_houdini/openvdb_houdini/Utils.h:173
void operator()(const GridType &inGrid)
Definition: UT_VDBTools.h:52
Definition: AttributeTransferUtil.h:33
GridResampleToMatchOp is a functor class for use with GridBase::apply() that samples an input grid in...
Definition: UT_VDBTools.h:153
void operator()(const GridType &inGrid)
Definition: UT_VDBTools.h:112
void operator()(const GridType &inGrid)
Definition: UT_VDBTools.h:159