Enzo
Loading...
Searching...
No Matches
GeometryOperator.h
1#pragma once
2#include "Engine/Operator/GeometryConnection.h"
3#include "Engine/Operator/OpInfo.h"
4#include "Engine/Operator/GeometryOpDef.h"
5#include "Engine/Parameter/Parameter.h"
6#include "Engine/Types.h"
7#include <functional>
8#include <optional>
9#include <memory>
10
11namespace enzo::nt {
12std::weak_ptr<GeometryConnection> connectOperators(enzo::nt::OpId inputOpId, unsigned int inputIndex, enzo::nt::OpId outputOpId, unsigned int outputIndex);
13
19{
20public:
31
36
39 void cookOp(op::Context context);
40
48 geo::Geometry& getOutputGeo(unsigned int outputIndex) const;
49
57 void addInputConnection(std::shared_ptr<nt::GeometryConnection> connection);
58
66 void addOutputConnection(std::shared_ptr<nt::GeometryConnection> connection);
67
76 void removeInputConnection(unsigned int inputIndex);
77
86 void removeOutputConnection(const nt::GeometryConnection* connection);
87
94 std::vector<std::weak_ptr<const GeometryConnection>> getInputConnections() const;
95
102 std::vector<std::weak_ptr<const GeometryConnection>> getOutputConnections() const;
103
109 std::optional<std::reference_wrapper<const GeometryConnection>> getInputConnection(size_t index) const;
110
112 std::vector<std::weak_ptr<prm::Parameter>> getParameters();
113
116 std::weak_ptr<prm::Parameter> getParameter(std::string parameterName);
117
122 std::string getLabel(); // TODO: implement node labels
123
131 std::string getTypeName();
132
140 void dirtyNode(bool dirtyDescendents=true);
141
143 bool isDirty();
144
148 unsigned int getMinInputs() const;
150 unsigned int getMaxInputs() const;
152 unsigned int getMaxOutputs() const;
153
155 boost::signals2::signal<void (nt::OpId opId, bool dirtyDescendents)> nodeDirtied;
156
157private:
158 void initParameters();
159
160 // TODO: avoid duplicate connections
161 std::vector<std::shared_ptr<nt::GeometryConnection>> inputConnections_;
162 std::vector<std::shared_ptr<nt::GeometryConnection>> outputConnections_;
163 std::vector<std::shared_ptr<prm::Parameter>> parameters_;
164 std::unique_ptr<enzo::nt::GeometryOpDef> opDef_;
165 enzo::nt::OpId opId_;
166 enzo::op::OpInfo opInfo_;
167 bool dirty_ = true;
168};
169}
Basic attribute, parameter, and node types for Enzo.
uint64_t OpId
The unique ID assigned to each node in the network.
Definition Types.h:80
Attribute based geometry container exchanged and modified by nodes.
Directional edges to connect nodes.
Definition GeometryConnection.h:27
The unique runtime representation of a node.
Definition GeometryOperator.h:19
void addInputConnection(std::shared_ptr< nt::GeometryConnection > connection)
Adds a GeometryConnection to one of the inputs. Replacing old connections if needed.
Definition GeometryOperator.cpp:79
std::string getLabel()
NOT YET IMPLEMENTED. Returns the runtime label given to this node as a unique identifier within it's ...
Definition GeometryOperator.cpp:167
boost::signals2::signal< void(nt::OpId opId, bool dirtyDescendents)> nodeDirtied
A signal emitted when the node is dirtied. This will usually notify the NetworkManager.
Definition GeometryOperator.h:155
unsigned int getMaxInputs() const
Returns the maximum number of input connections accepted by the node.
Definition GeometryOperator.cpp:217
std::vector< std::weak_ptr< const GeometryConnection > > getInputConnections() const
Returns a vector containing weak pointers for all input connections.
Definition GeometryOperator.cpp:158
geo::Geometry & getOutputGeo(unsigned int outputIndex) const
Returns the current output geometry.
Definition GeometryOperator.cpp:74
std::optional< std::reference_wrapper< const GeometryConnection > > getInputConnection(size_t index) const
Returns an optional connection from a specific input index.
Definition GeometryOperator.cpp:184
unsigned int getMaxOutputs() const
Returns the number of available outputs the node provides.
Definition GeometryOperator.cpp:221
unsigned int getMinInputs() const
Returns the minimum number of input connections required for the node to function....
Definition GeometryOperator.cpp:225
bool isDirty()
Returns true if the node is dirty and false if the node is clean (does not need cooking).
Definition GeometryOperator.cpp:61
void addOutputConnection(std::shared_ptr< nt::GeometryConnection > connection)
Adds a GeometryConnection to one of the outputs. Replacing old connections if needed.
Definition GeometryOperator.cpp:103
void removeInputConnection(unsigned int inputIndex)
Removes an input from the node's container.
Definition GeometryOperator.cpp:111
void removeOutputConnection(const nt::GeometryConnection *connection)
Removes an output from the node's container.
Definition GeometryOperator.cpp:127
void cookOp(op::Context context)
Computes the output geometry based on the cookOp definition in nt::GeometryOpDef. This is set by the ...
Definition GeometryOperator.cpp:67
std::vector< std::weak_ptr< const GeometryConnection > > getOutputConnections() const
Returns a vector containing weak pointers for all output connections.
Definition GeometryOperator.cpp:173
void dirtyNode(bool dirtyDescendents=true)
Marks the outputed geometry as outdated and notifies the network.
Definition GeometryOperator.cpp:54
std::weak_ptr< prm::Parameter > getParameter(std::string parameterName)
Returns a parameter with the given name belonging to this node.
Definition GeometryOperator.cpp:145
std::string getTypeName()
Returns the name belonging to this type of node (eg. grid or transform). Not to be confused with the ...
Definition GeometryOperator.cpp:178
GeometryOperator(const GeometryOperator &)=delete
Deleted copy constructor to avoid accidental copies.
GeometryOperator & operator=(const GeometryOperator &)=delete
Deleted copy assignment operator to avoid accidental copies.
GeometryOperator(enzo::nt::OpId opId, op::OpInfo opInfo)
Constructs a new node.
Definition GeometryOperator.cpp:33
std::vector< std::weak_ptr< prm::Parameter > > getParameters()
Returns all parameters belonging to this node.
Definition GeometryOperator.cpp:162
Provides network context for the cookOp function.
Definition Context.h:20
Definition OpInfo.h:20