fix math node and interpreter bugs
This commit is contained in:
@@ -44,7 +44,7 @@ void GetVariableLazyNodeBase::compute()
|
||||
{
|
||||
setValidationState(NodeValidationState::Error);
|
||||
setValidationMessage((boost::format("Error: variable \"%s\" of type \"%s\" does not match required type \"%s\".")
|
||||
% variable_name % it->second.first.c_str() % _out_ports[1].data_type->type().id.toStdString()).str().c_str());
|
||||
% variable_name % it->second.first.c_str() % _out_ports[0].data_type->type().id.toStdString()).str().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ void GetVariableNodeBase::compute()
|
||||
{
|
||||
setValidationState(NodeValidationState::Error);
|
||||
setValidationMessage((boost::format("Error: variable \"%s\" of type \"%s\" does not match required type \"%s\".")
|
||||
% variable_name % it->second.first.c_str() % _out_ports[1].data_type->type().id.toStdString()).str().c_str());
|
||||
% variable_name % it->second.first.c_str() % _out_ports[0].data_type->type().id.toStdString()).str().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -280,13 +280,13 @@ void MathNode::handleOperation(T first, T second)
|
||||
switch (_operation->currentIndex())
|
||||
{
|
||||
case 0: // Add
|
||||
result = first + first;
|
||||
result = first + second;
|
||||
break;
|
||||
case 1: // Subtract
|
||||
result = first - first;
|
||||
result = first - second;
|
||||
break;
|
||||
case 2: // Multiply
|
||||
result = first * first;
|
||||
result = first * second;
|
||||
break;
|
||||
case 3: // Divide
|
||||
if constexpr (std::is_same<T, int>::value || std::is_same<T, unsigned int>::value)
|
||||
@@ -298,11 +298,11 @@ void MathNode::handleOperation(T first, T second)
|
||||
return;
|
||||
}
|
||||
|
||||
result = first / first;
|
||||
result = first / second;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = first / first;
|
||||
result = first / second;
|
||||
}
|
||||
break;
|
||||
case 4: // Module
|
||||
@@ -319,7 +319,7 @@ void MathNode::handleOperation(T first, T second)
|
||||
}
|
||||
else
|
||||
{
|
||||
result = std::fmod(first, first);
|
||||
result = std::fmod(first, second);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -341,7 +341,7 @@ void MathNode::handleOperation(T first, T second)
|
||||
switch (_operation->currentIndex())
|
||||
{
|
||||
case 0: // Concatenate
|
||||
result = first + first;
|
||||
result = first + second;
|
||||
break;
|
||||
default:
|
||||
throw std::logic_error("String type only supports concatenation in MathNode.");
|
||||
|
||||
@@ -124,16 +124,35 @@ bool LogicBranch::executeNode(Node* node, Node* source_node)
|
||||
{
|
||||
setCurrentLoop(connected_node);
|
||||
int it_index = logic_model->getIterationindex();
|
||||
while (it_index >= 0 && it_index < logic_model->getNIteraitons() && !_return)
|
||||
|
||||
if (connected_model->name() == "LogicForLoopNode")
|
||||
{
|
||||
markNodesComputed(connected_node, false);
|
||||
while (it_index >= 0 && it_index < logic_model->getNIteraitons() && !_return)
|
||||
{
|
||||
markNodesComputed(connected_node, false);
|
||||
|
||||
if (!executeNode(connected_node, node))
|
||||
return false;
|
||||
if (!executeNode(connected_node, node))
|
||||
return false;
|
||||
|
||||
logic_model->setComputed(true);
|
||||
it_index = logic_model->getIterationindex();
|
||||
logic_model->setComputed(true);
|
||||
it_index = logic_model->getIterationindex();
|
||||
}
|
||||
}
|
||||
else // while loop
|
||||
{
|
||||
while (it_index >= 0 && it_index < logic_model->getNIteraitons() && !_return)
|
||||
{
|
||||
markNodesComputed(connected_node, false);
|
||||
executeNodeLeaves(connected_node, node);
|
||||
|
||||
if (!executeNode(connected_node, node))
|
||||
return false;
|
||||
|
||||
it_index = logic_model->getIterationindex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsetCurrentLoop();
|
||||
|
||||
}
|
||||
@@ -203,6 +222,7 @@ void LogicBranch::markNodesComputed(Node* start_node, bool state)
|
||||
auto& nodeState = start_node->nodeState();
|
||||
|
||||
model->setComputed(state);
|
||||
markNodeLeavesComputed(start_node, start_node, state);
|
||||
|
||||
for (int i = 0; i < model->nPorts(PortType::Out); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user