fix: remove duplicate inputs graphically

This commit is contained in:
parker
2025-07-28 21:28:10 +01:00
parent 7347db34ea
commit dabe7c860d
7 changed files with 57 additions and 25 deletions

View File

@@ -3,6 +3,7 @@
#include "Engine/Parameter/Parameter.h"
#include <iostream>
#include <memory>
#include <stdexcept>
enzo::op::Context::Context(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager)
@@ -15,14 +16,21 @@ enzo::geo::Geometry enzo::op::Context::cloneInputGeo(unsigned int inputIndex)
{
// TODO: implement
enzo::nt::GeometryOperator& selfOp = networkManager_.getGeoOperator(opId_);
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections = selfOp.getInputConnections();
std::vector<std::weak_ptr<const nt::GeometryConnection>> inputConnections = selfOp.getInputConnections();
if(inputConnections.size()==0)
{
std::cout << "no input\n";
return enzo::geo::Geometry();
}
std::shared_ptr<const nt::GeometryConnection> inputConnection = inputConnections.at(inputIndex);
return networkManager_.getGeoOperator(inputConnection->getInputOpId()).getOutputGeo(inputConnection->getInputIndex());
auto inputConnection = inputConnections.at(inputIndex);
if(auto inputConnectionSP = inputConnection.lock())
{
return networkManager_.getGeoOperator(inputConnectionSP->getInputOpId()).getOutputGeo(inputConnectionSP->getInputIndex());
}
else
{
throw std::runtime_error("Connection weak ptr doesn't exist");
}
}
enzo::bt::floatT enzo::op::Context::evalFloatParm(const char* parmName) const
@@ -34,4 +42,8 @@ enzo::bt::floatT enzo::op::Context::evalFloatParm(const char* parmName) const
{
return sharedParm->evalFloat();
}
else
{
throw std::runtime_error("Parameter weak ptr invalid");
}
}

View File

@@ -70,13 +70,10 @@ geo::Geometry& enzo::nt::GeometryOperator::getOutputGeo(unsigned outputIndex)
void nt::GeometryOperator::addInputConnection(std::shared_ptr<nt::GeometryConnection> newConnection)
{
// delete previous input
IC();
for(auto it=inputConnections_.begin(); it!=inputConnections_.end();)
{
IC();
if((*it)->getOutputIndex()==newConnection->getOutputIndex())
{
IC();
inputConnections_.erase(it);
}
else
@@ -84,7 +81,6 @@ void nt::GeometryOperator::addInputConnection(std::shared_ptr<nt::GeometryConnec
++it;
}
}
IC();
std::cout << "Input newConnection added\nConnecting ops " << newConnection->getInputOpId() << " -> " << newConnection->getOutputOpId() << "\n";
std::cout << "Connecting index " << newConnection->getInputIndex() << " -> " << newConnection->getOutputIndex() << "\n";
@@ -114,28 +110,30 @@ std::weak_ptr<prm::Parameter> nt::GeometryOperator::getParameter(std::string par
}
std::vector<std::shared_ptr<const nt::GeometryConnection>> nt::GeometryOperator::getInputConnections() const
std::vector<std::weak_ptr<const nt::GeometryConnection>> nt::GeometryOperator::getInputConnections() const
{
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections;
for(std::shared_ptr<nt::GeometryConnection> connection : inputConnections_)
{
inputConnections.push_back(connection);
}
return inputConnections;
return {inputConnections_.begin(), inputConnections_.end()};
}
std::vector<std::weak_ptr<prm::Parameter>> nt::GeometryOperator::getParameters()
{
return {parameters_.begin(), parameters_.end()};
}
std::vector<std::shared_ptr<const nt::GeometryConnection>> nt::GeometryOperator::getOutputConnections() const
std::vector<std::weak_ptr<const nt::GeometryConnection>> nt::GeometryOperator::getOutputConnections() const
{
std::vector<std::shared_ptr<const nt::GeometryConnection>> outputConnections;
for(std::shared_ptr<nt::GeometryConnection> connection : outputConnections_)
return {outputConnections_.begin(), outputConnections_.end()};
}
std::optional<const nt::GeometryConnection> nt::GeometryOperator::getInputConnection(size_t index) const
{
for(auto it=inputConnections_.begin(); it!=inputConnections_.end();)
{
outputConnections.push_back(connection);
if((*it)->getOutputIndex()==index)
{
return std::optional<const nt::GeometryConnection>(**it);
}
}
return outputConnections;
return std::nullopt;
}

View File

@@ -24,8 +24,9 @@ public:
void addInputConnection(std::shared_ptr<nt::GeometryConnection> connection);
void addOutputConnection(std::shared_ptr<nt::GeometryConnection> connection);
std::vector<std::shared_ptr<const GeometryConnection>> getInputConnections() const;
std::vector<std::shared_ptr<const GeometryConnection>> getOutputConnections() const;
std::vector<std::weak_ptr<const GeometryConnection>> getInputConnections() const;
std::vector<std::weak_ptr<const GeometryConnection>> getOutputConnections() const;
std::optional<const GeometryConnection> getInputConnection(size_t index) const;
std::vector<std::weak_ptr<prm::Parameter>> getParameters();
std::weak_ptr<prm::Parameter> getParameter(std::string parameterName);