10 #include <AtomsGraph/Globals.h>
11 #include <AtomsGraph/Nodes/NodeIds.h>
12 #include <AtomsGraph/Node.h>
13 #include <AtomsGraph/Ports.h>
14 #include <AtomsUtils/AtomsMath.h>
20 ATOMSGRAPH_EXPORT
void registerCompareNodes();
27 inline bool compareValues(
const T& A,
const T& B,
int op);
29 static unsigned int staticTypeId();
33 static std::string staticTypeStr();
43 virtual ~CompareNode();
45 virtual bool compute(
const ComputeData* computeData);
49 PortTemplate<T> *m_in1;
51 PortTemplate<T> *m_in2;
55 PortTemplate<bool> *m_out;
59 inline bool CompareNode<T>::compareValues(
const T& A,
const T& B,
int op)
81 inline bool CompareNode<AtomsMath::Vector3>::compareValues(
const AtomsMath::Vector3& A,
const AtomsMath::Vector3& B,
int op)
95 inline bool CompareNode<AtomsMath::Vector2>::compareValues(
const AtomsMath::Vector2& A,
const AtomsMath::Vector2& B,
int op)
109 inline bool CompareNode<AtomsMath::Quaternion>::compareValues(
const AtomsMath::Quaternion& A,
const AtomsMath::Quaternion& B,
int op)
123 inline bool CompareNode<AtomsMath::Matrix>::compareValues(
const AtomsMath::Matrix& A,
const AtomsMath::Matrix& B,
int op)
136 template <
typename T>
143 for (
auto portIt = inputPortCBegin(); portIt != inputPortCEnd(); ++portIt)
145 if ((*portIt)->numConnections() > 0)
153 template <
typename T>
157 m_out->set(compareValues(m_in1->getRef(), m_in2->getRef(), m_compType->get()));
161 template <
typename T>
166 template <
typename T>
167 CompareNode<T>::CompareNode()
169 m_in1 =
new PortTemplate<T>(
"in1");
170 m_in2 =
new PortTemplate<T>(
"in2");
171 m_compType =
new LongPort(
"operation");
172 m_out =
new PortTemplate<bool>(
"out");
178 addInputPort(m_compType);
179 addOutputPort(m_out);
182 ATOMS_IMPLEMENT_NODE(CompareNode<bool>, CompareBool, COMPARE_BOOL_NODE_ID)
183 ATOMS_IMPLEMENT_NODE(CompareNode<long>, CompareLong, COMPARE_LONG_NODE_ID)
184 ATOMS_IMPLEMENT_NODE(CompareNode<double>, CompareDouble, COMPARE_DOUBLE_NODE_ID)
185 ATOMS_IMPLEMENT_NODE(CompareNode<std::string>, CompareString, COMPARE_STRING_NODE_ID)
186 ATOMS_IMPLEMENT_NODE(CompareNode<AtomsMath::Matrix>, CompareMatrix, COMPARE_MATRIX_NODE_ID)
187 ATOMS_IMPLEMENT_NODE(CompareNode<AtomsMath::Vector3>, CompareVector, COMPARE_VECTOR_NODE_ID)
188 ATOMS_IMPLEMENT_NODE(CompareNode<AtomsMath::Quaternion>, CompareQuaternion, COMPARE_QUATERNION_NODE_ID)
Definition: CompareNodes.h:24
virtual bool compute(const ComputeData *computeData)
Compute function.
Definition: CompareNodes.h:154
virtual std::string typeStr() const
Type string.
Definition: CompareNodes.h:35
unsigned int typeId() const
Type id.
Definition: CompareNodes.h:31
virtual Node * clone()
clone object
Definition: CompareNodes.h:137
void setName(const std::string &name)
Sets the node name.
Definition: Node.impl.h:56
T * getInputPort(const std::string &name)
Gets input port.
Definition: Node.impl.h:84
BasePort class.
Definition: Port.h:26
virtual void copyValue(Port *other)
Copy the data from another port.
AtomsGraph namespace.
Definition: PosePort.h:15