OpenVDB  7.1.0
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 
146  OP_ERROR duplicateSourceStealable(const unsigned index,
147  OP_Context& context, GU_Detail **pgdp, GU_DetailHandle& gdh, bool clean = true);
148 
168  OP_ERROR duplicateSourceStealable(const unsigned index, OP_Context& context);
169 
171 
172 private:
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
openvdb::v7_1::math::Vec3
Definition: Vec3.h:24
openvdb_houdini::SOP_NodeVDB::evalVec3R
openvdb::Vec3R evalVec3R(const char *name, fpreal time) const
Evaluate a vector-valued parameter.
openvdb_houdini::node_info_text::ApplyGridSpecificInfoText
void(*)(std::ostream &, const openvdb::GridBase &) ApplyGridSpecificInfoText
Definition: SOP_NodeVDB.h:207
openvdb::v7_1::GridBase
Abstract base class for typed grids.
Definition: Grid.h:78
openvdb_houdini::SOP_NodeVDB::fillInfoTreeNodeSpecific
void fillInfoTreeNodeSpecific(UT_InfoTree &, const OP_NodeInfoTreeParms &) override
openvdb_houdini
Definition: AttributeTransferUtil.h:33
openvdb_houdini::SOP_NodeVDB::evalVec2R
openvdb::Vec2R evalVec2R(const char *name, fpreal time) const
Evaluate a vector-valued parameter.
openvdb_houdini::SOP_NodeVDB::matchGroup
const GA_PrimitiveGroup * matchGroup(GU_Detail &, const std::string &pattern)
Retrieve a group from a geometry detail by parsing a pattern (typically, the value of a Group paramet...
openvdb_houdini::SOP_NodeVDB::matchGroup
const GA_PrimitiveGroup * matchGroup(const GU_Detail &, const std::string &pattern)
Retrieve a group from a geometry detail by parsing a pattern (typically, the value of a Group paramet...
openvdb_houdini::SOP_NodeVDB::duplicateSourceStealable
OPENVDB_DEPRECATED OP_ERROR duplicateSourceStealable(const unsigned index, OP_Context &context)
Steal the geometry on the specified input if possible, instead of copying the data.
openvdb::v7_1::math::Vec3i
Vec3< int32_t > Vec3i
Definition: Vec3.h:659
openvdb_houdini::SOP_NodeVDB::cookMyGuide1
OP_ERROR cookMyGuide1(OP_Context &) override
Platform.h
openvdb::v7_1::math::Vec2i
Vec2< int32_t > Vec2i
Definition: Vec2.h:529
OPENVDB_DEPRECATED
#define OPENVDB_DEPRECATED
Definition: Platform.h:42
openvdb::v7_1::math::Vec2
Definition: Vec2.h:24
openvdb_houdini::SOP_NodeVDB::SOP_NodeVDB
SOP_NodeVDB(OP_Network *, const char *, OP_Operator *)
openvdb_houdini::SOP_NodeVDB::~SOP_NodeVDB
~SOP_NodeVDB() override=default
openvdb_houdini::SOP_NodeVDB::evalVec3f
openvdb::Vec3f evalVec3f(const char *name, fpreal time) const
Evaluate a vector-valued parameter.
openvdb_houdini::SOP_NodeVDB::evalVec3i
openvdb::Vec3i evalVec3i(const char *name, fpreal time) const
Evaluate a vector-valued parameter.
openvdb_houdini::SOP_NodeVDB::cookVDBSop
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
openvdb_houdini::SOP_NodeVDB::cookMySop
OP_ERROR cookMySop(OP_Context &) override final
To facilitate compilable SOPs, cookMySop() is now final. Instead, either override SOP_NodeVDB::cookVD...
openvdb_houdini::SOP_NodeVDB::resolveRenamedParm
void resolveRenamedParm(PRM_ParmList &obsoleteParms, const char *oldName, const char *newName)
Transfer the value of an obsolete parameter that was renamed to the parameter with the new name.
openvdb_houdini::SOP_NodeVDB::duplicateSourceStealable
OPENVDB_DEPRECATED OP_ERROR duplicateSourceStealable(const unsigned index, OP_Context &context, GU_Detail **pgdp, GU_DetailHandle &gdh, bool clean=true)
Steal the geometry on the specified input if possible, instead of copying the data.
openvdb_houdini::node_info_text::registerGridSpecificInfoText
void registerGridSpecificInfoText(const std::string &gridType, ApplyGridSpecificInfoText callback)
Register an info text callback to a specific grid type.
houdini_utils::OpFactory::OpFlavor
OpFlavor
Definition: ParmFactory.h:379
openvdb_houdini::SOP_NodeVDB::evalStdString
std::string evalStdString(const char *name, fpreal time, int index=0) const
Evaluate a string-valued parameter as an STL string.
houdini_utils::OpFactory
Helper class to simplify operator registration.
Definition: ParmFactory.h:377
openvdb_houdini::SOP_NodeVDB
Base class from which to derive OpenVDB-related Houdini SOPs.
Definition: SOP_NodeVDB.h:52
openvdb_houdini::SOP_NodeVDB::getNodeSpecificInfoText
void getNodeSpecificInfoText(OP_Context &, OP_NodeInfoParms &) override
openvdb_houdini::SOP_NodeVDB::evalVec2i
openvdb::Vec2i evalVec2i(const char *name, fpreal time) const
Evaluate a vector-valued parameter.
OPENVDB_HOUDINI_API
#define OPENVDB_HOUDINI_API
Definition: Platform.h:238
openvdb_houdini::SOP_NodeVDB::cookVerb
const SOP_NodeVerb * cookVerb() const override
Return this node's registered verb.
houdini_utils::ParmList
Parameter template list that is always terminated.
Definition: ParmFactory.h:74
openvdb.h
openvdb_houdini::OpenVDBOpFactory::setNativeName
OpenVDBOpFactory & setNativeName(const std::string &name)
Set the name of the equivalent native operator as shipped with Houdini.
SOP_VDBVerbUtils.h
openvdb_houdini::OpenVDBOpFactory
Use this class to register a new OpenVDB operator (SOP, POP, etc.)
Definition: SOP_NodeVDB.h:31
openvdb_houdini::OpenVDBOpFactory::OpenVDBOpFactory
OpenVDBOpFactory(const std::string &english, OP_Constructor, houdini_utils::ParmList &, OP_OperatorTable &, houdini_utils::OpFactory::OpFlavor=SOP)
Construct an OpFactory that on destruction registers a new OpenVDB operator type.