feat: add geometryOpDef

This commit is contained in:
parker
2025-07-08 16:39:15 +01:00
parent 504eb58fe4
commit 0be6512d33
6 changed files with 101 additions and 2 deletions

View File

@@ -0,0 +1,63 @@
#include "Engine/Operator/GeometryOpDef.h"
#include <stdexcept>
#include <iostream>
bool enzo::nt::GeometryOpDef::outputRequested(unsigned int outputIndex)
{
// TODO: implement
return true;
}
const enzo::geo::Geometry& enzo::nt::GeometryOpDef::getInputGeoView(unsigned int inputIndex)
{
// TODO: implement
return enzo::geo::Geometry();
}
enzo::geo::Geometry enzo::nt::GeometryOpDef::cloneInputGeo(unsigned int inputIndex)
{
// TODO: implement
return enzo::geo::Geometry();
}
void enzo::nt::GeometryOpDef::setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry)
{
if(outputIndex>maxOutputs_)
{
throw std::runtime_error("Cannot set output geometry to index > maxOutputs");
}
outputGeometry_[outputIndex] = geometry;
}
enzo::nt::GeometryOpDef::GeometryOpDef()
{
minInputs_=1;
maxInputs_=4;
maxOutputs_=4;
outputGeometry_ = std::vector<enzo::geo::Geometry>(4, enzo::geo::Geometry());
}
void enzo::nt::GeometryOpDef::cookOp()
{
using namespace enzo;
std::cout << "COOKING\n";
if(outputRequested(0))
{
// copy input geometry
geo::Geometry geo = cloneInputGeo(0);
// set output geometry
setOutputGeometry(0, geo);
}
// if(outputRequested(1))
// {
// // create new geometry
// const geo::Geometry& geo1 = getInputGeoView(0);
// geo::Geometry geo2;
// setOutputGeometry(1, geo2);
// }
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "Engine/Operator/Geometry.h"
namespace enzo::nt
{
class GeometryOpDef
{
public:
GeometryOpDef();
void cookOp();
private:
std::vector<enzo::geo::Geometry> outputGeometry_;
unsigned int minInputs_;
unsigned int maxInputs_;
unsigned int maxOutputs_;
protected:
const enzo::geo::Geometry& getInputGeoView(unsigned int inputIndex);
enzo::geo::Geometry cloneInputGeo(unsigned int inputIndex);
bool outputRequested(unsigned int outputIndex);
void setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry);
};
}

View File

@@ -28,8 +28,13 @@ nt::GeometryOperator::GeometryOperator()
// TODO: drive by geometry definition
maxInputs_=4;
maxOutputs_=4;
opDef_ = new enzo::nt::GeometryOpDef();
}
void enzo::nt::GeometryOperator::cookOp()
{
opDef_->cookOp();
}
void nt::GeometryOperator::addInputConnection(std::shared_ptr<nt::GeometryConnection> connection)
{

View File

@@ -1,5 +1,6 @@
#pragma once
#include "Engine/Operator/GeometryConnection.h"
#include "Engine/Operator/GeometryOpDef.h"
#include "Engine/Types.h"
#include <optional>
#include <memory>
@@ -16,6 +17,8 @@ public:
GeometryOperator(const GeometryOperator&) = delete;
GeometryOperator& operator=(const GeometryOperator&) = delete;
void cookOp();
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;
@@ -33,6 +36,6 @@ private:
std::vector<std::shared_ptr<nt::GeometryConnection>> outputConnections_;
unsigned int maxInputs_;
unsigned int maxOutputs_;
enzo::nt::GeometryOpDef* opDef_;
};
}