feat: pass network manager reference to operatorDef
This commit is contained in:
@@ -20,7 +20,6 @@ set(ENGINE_SOURCES
|
|||||||
src/Engine/Operator/GeometryOpDef.cpp
|
src/Engine/Operator/GeometryOpDef.cpp
|
||||||
src/Engine/Operator/OperatorTable.cpp
|
src/Engine/Operator/OperatorTable.cpp
|
||||||
src/Engine/Operator/GOP_test.cpp
|
src/Engine/Operator/GOP_test.cpp
|
||||||
src/Engine/Operator/GOP_transform.cpp
|
|
||||||
src/Engine/Network/NetworkManager.cpp
|
src/Engine/Network/NetworkManager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#include "Engine/Operator/AttributeHandle.h"
|
#include "Engine/Operator/AttributeHandle.h"
|
||||||
#include <oneapi/tbb/parallel_for.h>
|
#include <oneapi/tbb/parallel_for.h>
|
||||||
|
|
||||||
GOP_test::GOP_test(enzo::nt::OpId opId)
|
GOP_test::GOP_test(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager)
|
||||||
: enzo::nt::GeometryOpDef(opId)
|
: enzo::nt::GeometryOpDef(opId, networkManager)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ class GOP_test
|
|||||||
: public enzo::nt::GeometryOpDef
|
: public enzo::nt::GeometryOpDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GOP_test(enzo::nt::OpId opId);
|
GOP_test(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager);
|
||||||
virtual void cookOp();
|
virtual void cookOp();
|
||||||
static enzo::nt::GeometryOpDef* ctor(enzo::nt::OpId opId)
|
static enzo::nt::GeometryOpDef* ctor(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager)
|
||||||
{
|
{
|
||||||
return new GOP_test(opId);
|
return new GOP_test(opId, networkManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
#include "Engine/Operator/GOP_transform.h"
|
|
||||||
#include "Engine/Operator/AttributeHandle.h"
|
|
||||||
#include <oneapi/tbb/parallel_for.h>
|
|
||||||
|
|
||||||
GOP_transform::GOP_transform(enzo::nt::OpId opId)
|
|
||||||
: enzo::nt::GeometryOpDef(opId)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void GOP_transform::cookOp()
|
|
||||||
{
|
|
||||||
using namespace enzo;
|
|
||||||
// std::cout << "COOKING\n";
|
|
||||||
|
|
||||||
if(outputRequested(0))
|
|
||||||
{
|
|
||||||
// copy input geometry
|
|
||||||
geo::Geometry geo = cloneInputGeo(0);
|
|
||||||
|
|
||||||
// ----
|
|
||||||
// create geometry start
|
|
||||||
// ----
|
|
||||||
auto PAttr = geo.getAttribByName(ga::AttrOwner::POINT, "P");
|
|
||||||
ga::AttributeHandleVector3 PAttrHandle(PAttr);
|
|
||||||
|
|
||||||
for(int i=0; i<PAttrHandle.getAllValues().size(); ++i)
|
|
||||||
{
|
|
||||||
enzo::bt::Vector3 vector = PAttrHandle.getValue(i);
|
|
||||||
vector.y()+=2.5;
|
|
||||||
PAttrHandle.setValue(i, vector);
|
|
||||||
}
|
|
||||||
// ----
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// set output geometry
|
|
||||||
setOutputGeometry(0, geo);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Engine/Operator/GeometryOpDef.h"
|
|
||||||
|
|
||||||
class GOP_transform
|
|
||||||
: public enzo::nt::GeometryOpDef
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GOP_transform(enzo::nt::OpId opId);
|
|
||||||
virtual void cookOp();
|
|
||||||
static enzo::nt::GeometryOpDef* ctor(enzo::nt::OpId opId)
|
|
||||||
{
|
|
||||||
return new GOP_transform(opId);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -22,9 +22,8 @@ const enzo::geo::Geometry& enzo::nt::GeometryOpDef::getInputGeoView(unsigned int
|
|||||||
|
|
||||||
enzo::geo::Geometry enzo::nt::GeometryOpDef::cloneInputGeo(unsigned int inputIndex)
|
enzo::geo::Geometry enzo::nt::GeometryOpDef::cloneInputGeo(unsigned int inputIndex)
|
||||||
{
|
{
|
||||||
auto& nm = nt::nm();
|
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
enzo::nt::GeometryOperator& selfOp = nm.getGeoOperator(opId_);
|
enzo::nt::GeometryOperator& selfOp = networkManager_.getGeoOperator(opId_);
|
||||||
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections = selfOp.getInputConnections();
|
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections = selfOp.getInputConnections();
|
||||||
if(inputConnections.size()==0)
|
if(inputConnections.size()==0)
|
||||||
{
|
{
|
||||||
@@ -32,7 +31,7 @@ enzo::geo::Geometry enzo::nt::GeometryOpDef::cloneInputGeo(unsigned int inputInd
|
|||||||
return enzo::geo::Geometry();
|
return enzo::geo::Geometry();
|
||||||
}
|
}
|
||||||
std::shared_ptr<const nt::GeometryConnection> inputConnection = inputConnections.at(inputIndex);
|
std::shared_ptr<const nt::GeometryConnection> inputConnection = inputConnections.at(inputIndex);
|
||||||
return nm.getGeoOperator(inputConnection->getInputOpId()).getOutputGeo(inputConnection->getInputIndex());
|
return networkManager_.getGeoOperator(inputConnection->getInputOpId()).getOutputGeo(inputConnection->getInputIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void enzo::nt::GeometryOpDef::setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry)
|
void enzo::nt::GeometryOpDef::setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry)
|
||||||
@@ -44,8 +43,8 @@ void enzo::nt::GeometryOpDef::setOutputGeometry(unsigned int outputIndex, enzo::
|
|||||||
outputGeometry_[outputIndex] = geometry;
|
outputGeometry_[outputIndex] = geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
enzo::nt::GeometryOpDef::GeometryOpDef(enzo::nt::OpId opId)
|
enzo::nt::GeometryOpDef::GeometryOpDef(enzo::nt::OpId opId, NetworkManager& networkManager)
|
||||||
: opId_{opId}
|
: opId_{opId}, networkManager_{networkManager}
|
||||||
{
|
{
|
||||||
minInputs_=1;
|
minInputs_=1;
|
||||||
maxInputs_=4;
|
maxInputs_=4;
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
#include "Engine/Types.h"
|
#include "Engine/Types.h"
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace enzo::nt
|
namespace enzo::nt
|
||||||
{
|
{
|
||||||
|
class NetworkManager;
|
||||||
|
|
||||||
class BOOST_SYMBOL_EXPORT GeometryOpDef
|
class BOOST_SYMBOL_EXPORT GeometryOpDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GeometryOpDef(enzo::nt::OpId opId);
|
GeometryOpDef(enzo::nt::OpId opId, NetworkManager& networkManager);
|
||||||
virtual void cookOp() = 0;
|
virtual void cookOp() = 0;
|
||||||
geo::Geometry& getOutputGeo(unsigned outputIndex);
|
geo::Geometry& getOutputGeo(unsigned outputIndex);
|
||||||
private:
|
private:
|
||||||
@@ -17,6 +19,7 @@ private:
|
|||||||
unsigned int minInputs_;
|
unsigned int minInputs_;
|
||||||
unsigned int maxInputs_;
|
unsigned int maxInputs_;
|
||||||
unsigned int maxOutputs_;
|
unsigned int maxOutputs_;
|
||||||
|
NetworkManager& networkManager_;
|
||||||
protected:
|
protected:
|
||||||
enzo::nt::OpId opId_;
|
enzo::nt::OpId opId_;
|
||||||
const enzo::geo::Geometry& getInputGeoView(unsigned int inputIndex);
|
const enzo::geo::Geometry& getInputGeoView(unsigned int inputIndex);
|
||||||
@@ -27,5 +30,5 @@ protected:
|
|||||||
void setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry);
|
void setOutputGeometry(unsigned int outputIndex, enzo::geo::Geometry geometry);
|
||||||
};
|
};
|
||||||
|
|
||||||
using opConstructor = GeometryOpDef* (*)(enzo::nt::OpId);
|
using opConstructor = GeometryOpDef* (*)(enzo::nt::OpId, enzo::nt::NetworkManager&);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ void enzo::nt::connectOperators(enzo::nt::OpId inputOpId, unsigned int inputInde
|
|||||||
}
|
}
|
||||||
|
|
||||||
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, nt::opConstructor ctorFunc)
|
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, nt::opConstructor ctorFunc)
|
||||||
: opId_{opId}, opDef_(ctorFunc(opId))
|
: opId_{opId}, opDef_(ctorFunc(opId, nt::nm()))
|
||||||
{
|
{
|
||||||
// TODO: drive by geometry definition
|
// TODO: drive by geometry definition
|
||||||
maxInputs_=4;
|
maxInputs_=4;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ void connectOperators(enzo::nt::OpId inputOpId, unsigned int inputIndex, enzo::n
|
|||||||
class GeometryOperator
|
class GeometryOperator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GeometryOperator(enzo::nt::OpId opId, enzo::nt::GeometryOpDef* (*ctorFunc)(enzo::nt::OpId));
|
GeometryOperator(enzo::nt::OpId opId, nt::opConstructor ctorFunc);
|
||||||
|
|
||||||
// disable copying
|
// disable copying
|
||||||
GeometryOperator(const GeometryOperator&) = delete;
|
GeometryOperator(const GeometryOperator&) = delete;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <QLine>
|
#include <QLine>
|
||||||
#include "Engine/Operator/GOP_test.h"
|
#include "Engine/Operator/GOP_test.h"
|
||||||
#include "Engine/Operator/GOP_transform.h"
|
|
||||||
|
|
||||||
using namespace enzo;
|
using namespace enzo;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ add_library(${libName} SHARED
|
|||||||
main.cpp
|
main.cpp
|
||||||
../Engine/Operator/OperatorTable.cpp
|
../Engine/Operator/OperatorTable.cpp
|
||||||
../Engine/Operator/GeometryOpDef.cpp
|
../Engine/Operator/GeometryOpDef.cpp
|
||||||
|
../Engine/Operator/GeometryOperator.cpp
|
||||||
|
../Engine/Operator/GeometryConnection.cpp
|
||||||
../Engine/Operator/Geometry.cpp
|
../Engine/Operator/Geometry.cpp
|
||||||
../Engine/Operator/Attribute.cpp
|
../Engine/Operator/Attribute.cpp
|
||||||
../Engine/Network/NetworkManager.cpp
|
../Engine/Network/NetworkManager.cpp
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ class GopTransform
|
|||||||
: public enzo::nt::GeometryOpDef
|
: public enzo::nt::GeometryOpDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GopTransform(enzo::nt::OpId opId);
|
GopTransform(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager);
|
||||||
virtual void cookOp();
|
virtual void cookOp();
|
||||||
static enzo::nt::GeometryOpDef* ctor(enzo::nt::OpId opId)
|
static enzo::nt::GeometryOpDef* ctor(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager)
|
||||||
{
|
{
|
||||||
return new GopTransform(opId);
|
return new GopTransform(opId, networkManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ extern "C"
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GopTransform::GopTransform(enzo::nt::OpId opId)
|
GopTransform::GopTransform(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager)
|
||||||
: enzo::nt::GeometryOpDef(opId)
|
: enzo::nt::GeometryOpDef(opId, networkManager)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user