feat: setup GopTransform

This commit is contained in:
parker
2025-07-13 16:48:56 +01:00
parent b13c7bc498
commit db5da8a2e8
8 changed files with 154 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.30)
# set vars
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -18,6 +18,7 @@ set(ENGINE_SOURCES
src/Engine/Operator/GeometryOperator.cpp
src/Engine/Operator/GeometryConnection.cpp
src/Engine/Operator/GeometryOpDef.cpp
src/Engine/Operator/OperatorTable.cpp
src/Engine/Operator/GOP_test.cpp
src/Engine/Operator/GOP_transform.cpp
src/Engine/Network/NetworkManager.cpp
@@ -57,6 +58,8 @@ find_package (Eigen3 3.3 REQUIRED NO_MODULE)
# tbb
find_package(TBB REQUIRED COMPONENTS TBB::tbb)
find_package(Boost REQUIRED COMPONENTS filesystem system)
qt_add_executable(${AppExec}
@@ -84,9 +87,12 @@ add_executable(${TestExec}
tests/OperatorTests.cpp
tests/NetworkTests.cpp
)
target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb)
target_link_libraries(${TestExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen Qt6::Core TBB::tbb Boost::filesystem Boost::system)
target_compile_definitions(${TestExec} PRIVATE UNIT_TEST)
target_include_directories(${TestExec} PUBLIC src)
target_include_directories(${TestExec} PUBLIC
src
${BOOST_INCLUDE_DIRS}
)
# benchmarks
add_executable(${BenchExec}
@@ -98,3 +104,4 @@ target_link_libraries(${BenchExec} PRIVATE Catch2::Catch2WithMain Eigen3::Eigen
target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST)
target_include_directories(${BenchExec} PUBLIC src)
add_subdirectory(src/OpDefs)

View File

@@ -1,11 +1,12 @@
#pragma once
#include "Engine/Operator/Geometry.h"
#include "Engine/Types.h"
#include <boost/config.hpp>
namespace enzo::nt
{
class GeometryOpDef
class BOOST_SYMBOL_EXPORT GeometryOpDef
{
public:
GeometryOpDef(enzo::nt::OpId opId);

View File

@@ -0,0 +1,10 @@
#include "Engine/Operator/OperatorTable.h"
#include <iostream>
void enzo::op::OperatorTable::addOperator(nt::opConstructor ctorFunc)
{
std::cout << "OPERATOR TABLE ADDED\n";
// ctorFunc(5);
ctorStore_.push_back(ctorFunc);
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include <boost/config.hpp>
#include "Engine/Network/NetworkManager.h"
namespace enzo::op
{
class BOOST_SYMBOL_EXPORT OperatorTable
{
public:
void addOperator(nt::opConstructor ctorFunc);
private:
std::vector<nt::opConstructor> ctorStore_;
};
}

23
src/OpDefs/CMakeLists.txt Normal file
View File

@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.30)
project(enzoOps1)
find_package(Boost REQUIRED)
# eigen (math)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
set(libName enzoOps1)
add_library(${libName} SHARED
main.cpp
../Engine/Operator/OperatorTable.cpp
../Engine/Operator/GeometryOpDef.cpp
../Engine/Operator/Geometry.cpp
../Engine/Operator/Attribute.cpp
../Engine/Network/NetworkManager.cpp
)
target_link_libraries(${libName} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets Qt6::OpenGLWidgets glm::glm Eigen3::Eigen TBB::tbb)
MESSAGE("CURRENT SOURCE DIR" ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${libName} PUBLIC ../)
target_include_directories(${libName} PUBLIC .)

View File

@@ -0,0 +1,15 @@
#pragma once
#include "Engine/Operator/GeometryOpDef.h"
class GopTransform
: public enzo::nt::GeometryOpDef
{
public:
GopTransform(enzo::nt::OpId opId);
virtual void cookOp();
static enzo::nt::GeometryOpDef* ctor(enzo::nt::OpId opId)
{
return new GopTransform(opId);
}
};

56
src/OpDefs/main.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include "Engine/Operator/OperatorTable.h"
#include "OpDefs/GopTransform.hpp"
#include <boost/config.hpp>
#include <boost/dll.hpp>
#include <string>
#include "Engine/Operator/AttributeHandle.h"
#include <iostream>
extern "C"
{ BOOST_SYMBOL_EXPORT std::string myVar = "hello world";
BOOST_SYMBOL_EXPORT void newSopOperator(enzo::op::OperatorTable* table)
{
table->addOperator(
&GopTransform::ctor
);
}
}
GopTransform::GopTransform(enzo::nt::OpId opId)
: enzo::nt::GeometryOpDef(opId)
{
}
void GopTransform::cookOp()
{
using namespace enzo;
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);
}
}

View File

@@ -1,6 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include <oneapi/tbb/parallel_for.h>
#include <iostream>
#include <boost/dll/import.hpp>
TEST_CASE("foo")
{
@@ -17,3 +18,25 @@ TEST_CASE("tbb")
<< std::this_thread::get_id() << std::endl;
});
}
TEST_CASE("boost dll")
{
std::cout << "Using Boost "
<< BOOST_VERSION / 100000 << "." // major version
<< BOOST_VERSION / 100 % 1000 << "." // minor version
<< BOOST_VERSION % 100 // patch level
<< std::endl;
boost::shared_ptr<std::string> cpp_var = boost::dll::import_symbol<std::string>(
"build/src/OpDefs/libenzoOps1.so", "myVar"
);
std::cout << "VAR: " << *cpp_var << "\n";
auto cpp11_func = boost::dll::import_symbol<void(int&&)>(
"build/src/OpDefs/libenzoOps1.so", "newSopOperator"
);
cpp11_func(5);
}