feat: add geometryOpDef
This commit is contained in:
@@ -48,6 +48,7 @@ qt_add_executable(${AppExec}
|
||||
src/Engine/Operator/Geometry.cpp
|
||||
src/Engine/Operator/GeometryOperator.cpp
|
||||
src/Engine/Operator/GeometryConnection.cpp
|
||||
src/Engine/Operator/GeometryOpDef.cpp
|
||||
src/Engine/Network/NetworkManager.cpp
|
||||
)
|
||||
|
||||
@@ -65,6 +66,7 @@ add_executable(${TestExec}
|
||||
src/Engine/Operator/GeometryOperator.cpp
|
||||
src/Engine/Network/NetworkManager.cpp
|
||||
src/Engine/Operator/GeometryConnection.cpp
|
||||
src/Engine/Operator/GeometryOpDef.cpp
|
||||
)
|
||||
find_package(Catch2 3 REQUIRED)
|
||||
target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core )
|
||||
|
||||
@@ -75,6 +75,7 @@ void enzo::nt::NetworkManager::setDisplayOp(OpId opId)
|
||||
|
||||
// --------
|
||||
|
||||
std::cout << "size: " << dependencyGraph.size() << "\n";
|
||||
for(enzo::nt::OpId opId : dependencyGraph)
|
||||
{
|
||||
prevGeometry = cookOp(opId, prevGeometry);
|
||||
@@ -87,6 +88,8 @@ enzo::geo::Geometry enzo::nt::NetworkManager::cookOp(enzo::nt::OpId opId, enzo::
|
||||
std::shared_ptr<ga::Attribute> PAttr = inputGeometry.getAttribByName(ga::AttrOwner::POINT, "P");
|
||||
ga::AttributeHandleVector3 PAttrHandle = ga::AttributeHandleVector3(PAttr);
|
||||
|
||||
enzo::nt::GeometryOperator& op = getGeoOperator(opId);
|
||||
op.cookOp();
|
||||
|
||||
for(int i=0; i<PAttrHandle.getAllValues().size(); ++i)
|
||||
{
|
||||
|
||||
63
src/Engine/Operator/GeometryOpDef.cpp
Normal file
63
src/Engine/Operator/GeometryOpDef.cpp
Normal 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);
|
||||
// }
|
||||
}
|
||||
23
src/Engine/Operator/GeometryOpDef.h
Normal file
23
src/Engine/Operator/GeometryOpDef.h
Normal 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);
|
||||
};
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user