OpenVDB  8.1.1
SOP_NodeVDB.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_SOP_NODEVDB_HAS_BEEN_INCLUDED
9 #define OPENVDB_HOUDINI_SOP_NODEVDB_HAS_BEEN_INCLUDED
10 
11 #include <houdini_utils/ParmFactory.h>
12 #include <openvdb/openvdb.h>
13 #include <openvdb/Platform.h>
14 #include <SOP/SOP_Node.h>
15 #ifndef SESI_OPENVDB
16 #include <UT/UT_DSOVersion.h>
17 #endif
18 #include "SOP_VDBVerbUtils.h"
19 #include <iosfwd>
20 #include <string>
21 
22 
23 class GU_Detail;
24 
25 namespace openvdb_houdini {
26 
31 {
32 public:
34  OpenVDBOpFactory(const std::string& english, OP_Constructor, houdini_utils::ParmList&,
35  OP_OperatorTable&, houdini_utils::OpFactory::OpFlavor = SOP);
36 
40  OpenVDBOpFactory& setNativeName(const std::string& name);
41 
42 private:
43  std::string mNativeName;
44 };
45 
46 
48 
49 
51 class OPENVDB_HOUDINI_API SOP_NodeVDB: public SOP_Node
52 {
53 public:
54  SOP_NodeVDB(OP_Network*, const char*, OP_Operator*);
55  ~SOP_NodeVDB() override = default;
56 
57  void fillInfoTreeNodeSpecific(UT_InfoTree&, const OP_NodeInfoTreeParms&) override;
58  void getNodeSpecificInfoText(OP_Context&, OP_NodeInfoParms&) override;
59 
61  const SOP_NodeVerb* cookVerb() const override;
62 
69  const GA_PrimitiveGroup* matchGroup(GU_Detail&, const std::string& pattern);
70  const GA_PrimitiveGroup* matchGroup(const GU_Detail&, const std::string& pattern);
72 
75 
77  openvdb::Vec3f evalVec3f(const char* name, fpreal time) const;
79  openvdb::Vec3R evalVec3R(const char* name, fpreal time) const;
81  openvdb::Vec3i evalVec3i(const char* name, fpreal time) const;
83  openvdb::Vec2R evalVec2R(const char* name, fpreal time) const;
85  openvdb::Vec2i evalVec2i(const char* name, fpreal time) const;
86 
93  std::string evalStdString(const char* name, fpreal time, int index = 0) const;
94 
96 
97 protected:
102  OP_ERROR cookMySop(OP_Context&) override final;
103 
104  virtual OP_ERROR cookVDBSop(OP_Context&) { return UT_ERROR_NONE; }
106 
107  OP_ERROR cookMyGuide1(OP_Context&) override;
108  //OP_ERROR cookMyGuide2(OP_Context&) override;
109 
114  void resolveRenamedParm(PRM_ParmList& obsoleteParms,
115  const char* oldName, const char* newName);
116 
119 
145  [[deprecated]]
146  OP_ERROR duplicateSourceStealable(const unsigned index,
147  OP_Context& context, GU_Detail **pgdp, GU_DetailHandle& gdh, bool clean = true);
148 
167  [[deprecated]]
168  OP_ERROR duplicateSourceStealable(const unsigned index, OP_Context& context);
169 
171 
172 private:
183  [[deprecated]]
184  bool isSourceStealable(const unsigned index, OP_Context& context) const;
185 }; // class SOP_NodeVDB
186 
187 
189 
190 
202 namespace node_info_text
203 {
204  // The function pointer signature expected when registering an grid type text
205  // callback. The grid is passed untyped but is guaranteed to match the registered
206  // type.
207  using ApplyGridSpecificInfoText = void (*)(std::ostream&, const openvdb::GridBase&);
208 
214  void registerGridSpecificInfoText(const std::string& gridType,
215  ApplyGridSpecificInfoText callback);
216 
220  template<typename GridType>
222  {
223  registerGridSpecificInfoText(GridType::gridType(), callback);
224  }
225 
226 } // namespace node_info_text
227 
228 
229 } // namespace openvdb_houdini
230 
231 #endif // OPENVDB_HOUDINI_SOP_NODEVDB_HAS_BEEN_INCLUDED
Definition: Vec2.h:23
Vec2< int32_t > Vec2i
Definition: Vec2.h:534
OpFlavor
Definition: ParmFactory.h:379
void registerGridSpecificInfoText(ApplyGridSpecificInfoText callback)
Register an info text callback to a templated grid type.
Definition: SOP_NodeVDB.h:221
#define OPENVDB_HOUDINI_API
Definition: Platform.h:248
Parameter template list that is always terminated.
Definition: ParmFactory.h:73
Vec3< int32_t > Vec3i
Definition: Vec3.h:665
Abstract base class for typed grids.
Definition: Grid.h:77
virtual OP_ERROR cookVDBSop(OP_Context &)
To facilitate compilable SOPs, cookMySop() is now final. Instead, either override SOP_NodeVDB::cookVD...
Definition: SOP_NodeVDB.h:104
Definition: Mat.h:187
Base class from which to derive OpenVDB-related Houdini SOPs.
Definition: SOP_NodeVDB.h:51
void(*)(std::ostream &, const openvdb::GridBase &) ApplyGridSpecificInfoText
Definition: SOP_NodeVDB.h:207
Helper class to simplify operator registration.
Definition: ParmFactory.h:376
Definition: AttributeTransferUtil.h:33
Use this class to register a new OpenVDB operator (SOP, POP, etc.)
Definition: SOP_NodeVDB.h:30