OpenVDB  7.2.1
PointExecutable.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
11 
12 #ifndef OPENVDB_AX_COMPILER_POINT_EXECUTABLE_HAS_BEEN_INCLUDED
13 #define OPENVDB_AX_COMPILER_POINT_EXECUTABLE_HAS_BEEN_INCLUDED
14 
15 #include "CustomData.h"
16 #include "AttributeRegistry.h"
17 
18 #include <openvdb/openvdb.h>
19 #include <openvdb/version.h>
21 
22 #include <unordered_map>
23 
24 class TestPointExecutable;
25 
26 namespace llvm {
27 class ExecutionEngine;
28 class LLVMContext;
29 }
30 
31 namespace openvdb {
33 namespace OPENVDB_VERSION_NAME {
34 namespace ax {
35 
36 class Compiler;
37 
40 {
41 public:
42  using Ptr = std::shared_ptr<PointExecutable>;
44 
49 
51 
53  void execute(points::PointDataGrid& grid) const;
54 
56 
63  void setGroupExecution(const std::string& name);
66  const std::string& getGroupExecution() const;
67 
73  void setCreateMissing(const bool flag);
75  bool getCreateMissing() const;
76 
80  void setGrainSize(const size_t grain);
82  size_t getGrainSize() const;
83 
85 
86  // @brief deprecated methods
89  const std::string* const group,
90  const bool create) const
91  {
92  PointExecutable copy(*this);
93  if (group) copy.setGroupExecution(*group);
94  copy.setCreateMissing(create);
95  copy.execute(grid);
96  }
97 
100  const std::string* const group) const
101  {
102  PointExecutable copy(*this);
103  if (group) copy.setGroupExecution(*group);
104  copy.execute(grid);
105  }
106 
108 
109  // foward declaration of settings for this executable
110  struct Settings;
111 
112 private:
113  friend class Compiler;
114  friend class ::TestPointExecutable;
115 
127  PointExecutable(const std::shared_ptr<const llvm::LLVMContext>& context,
128  const std::shared_ptr<const llvm::ExecutionEngine>& engine,
129  const AttributeRegistry::ConstPtr& attributeRegistry,
130  const CustomData::ConstPtr& customData,
131  const std::unordered_map<std::string, uint64_t>& functions);
132 
133 private:
134  // The Context and ExecutionEngine must exist _only_ for object lifetime
135  // management. The ExecutionEngine must be destroyed before the Context
136  const std::shared_ptr<const llvm::LLVMContext> mContext;
137  const std::shared_ptr<const llvm::ExecutionEngine> mExecutionEngine;
138  const AttributeRegistry::ConstPtr mAttributeRegistry;
139  const CustomData::ConstPtr mCustomData;
140  const std::unordered_map<std::string, uint64_t> mFunctionAddresses;
141  std::unique_ptr<Settings> mSettings;
142 };
143 
144 } // namespace ax
145 } // namespace OPENVDB_VERSION_NAME
146 } // namespace openvdb
147 
148 #endif // OPENVDB_AX_COMPILER_POINT_EXECUTABLE_HAS_BEEN_INCLUDED
149 
openvdb::v7_2::ax::PointExecutable::execute
void execute(points::PointDataGrid &grid) const
executes compiled AX code on target grid
openvdb::v7_2::ax::PointExecutable::setGrainSize
void setGrainSize(const size_t grain)
Set the threading grain size. Default is 1. A value of 0 has the effect of disabling multi-threading.
llvm
Definition: Compiler.h:31
openvdb::v7_2::ax::PointExecutable::execute
OPENVDB_DEPRECATED void execute(points::PointDataGrid &grid, const std::string *const group) const
Definition: PointExecutable.h:99
openvdb::v7_2::ax::CustomData::ConstPtr
std::shared_ptr< const CustomData > ConstPtr
Definition: CustomData.h:47
CustomData.h
Access to the CustomData class which can provide custom user user data to the OpenVDB AX Compiler.
version.h
Library and file format version numbers.
openvdb::v7_2::ax::PointExecutable::Ptr
std::shared_ptr< PointExecutable > Ptr
Definition: PointExecutable.h:42
openvdb::v7_2::ax::PointExecutable
Object that encapsulates compiled AX code which can be executed on a target point grid.
Definition: PointExecutable.h:40
openvdb::v7_2::ax::PointExecutable::getCreateMissing
bool getCreateMissing() const
openvdb::v7_2::Grid
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:572
OPENVDB_DEPRECATED
#define OPENVDB_DEPRECATED
Definition: Platform.h:42
openvdb::v7_2::ax::PointExecutable::setCreateMissing
void setCreateMissing(const bool flag)
Set the behaviour when missing point attributes are accessed. Default behaviour is true,...
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
openvdb::v7_2::ax::PointExecutable::~PointExecutable
~PointExecutable()
openvdb::v7_2::ax::Compiler
The compiler class. This holds an llvm context and set of compiler options, and constructs executable...
Definition: Compiler.h:50
openvdb::v7_2::ax::PointExecutable::execute
OPENVDB_DEPRECATED void execute(points::PointDataGrid &grid, const std::string *const group, const bool create) const
Definition: PointExecutable.h:88
openvdb::v7_2::ax::PointExecutable::PointExecutable
PointExecutable(const PointExecutable &other)
Copy constructor. Shares the LLVM constructs but deep copies the settings. Multiple copies of an exec...
openvdb::v7_2::ax::PointExecutable::getGrainSize
size_t getGrainSize() const
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:147
openvdb::v7_2::ax::PointExecutable::getGroupExecution
const std::string & getGroupExecution() const
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:95
openvdb::v7_2::ax::PointExecutable::setGroupExecution
void setGroupExecution(const std::string &name)
Set a specific point group to execute over. The default is none, which corresponds to all points....
AttributeRegistry.h
These classes contain lists of expected attributes and volumes which are populated by compiler during...
openvdb::v7_2::ax::AttributeRegistry::ConstPtr
std::shared_ptr< const AttributeRegistry > ConstPtr
Definition: AttributeRegistry.h:40
openvdb
Definition: openvdb/Exceptions.h:13
openvdb.h