From caf1510d11a8eec0114073fb8c50a320668ca7a4 Mon Sep 17 00:00:00 2001 From: parker Date: Sun, 17 Aug 2025 22:19:53 +0100 Subject: [PATCH] fix: tests --- CMakeLists.txt | 2 ++ src/Engine/Operator/Attribute.cpp | 24 +++++++++++++++++++++++ src/Engine/Operator/Attribute.h | 1 + src/Engine/Operator/Geometry.cpp | 32 +++++++++++++++++++++++++++++++ src/Engine/Operator/Geometry.h | 2 ++ tests/NetworkTests.cpp | 3 ++- tests/OperatorTests.cpp | 2 +- 7 files changed, 64 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2c9dbe..7f6b57b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,6 +202,7 @@ target_include_directories(${TestExec} PUBLIC ${ENGINE_INCLUDE_DIRECTORIES} ${BOOST_INCLUDE_DIRS} ) +target_compile_definitions(${TestExec} PRIVATE ENZO_DEV_LIB_DIR="${ENZO_DEV_LIB_DIR}") # benchmarks add_executable(${BenchExec} @@ -214,4 +215,5 @@ target_compile_definitions(${BenchExec} PRIVATE UNIT_TEST) target_include_directories(${BenchExec} PUBLIC ${ENGINE_INCLUDE_DIRECTORIES} ) +target_compile_definitions(${BenchExec} PRIVATE ENZO_DEV_LIB_DIR="${ENZO_DEV_LIB_DIR}") diff --git a/src/Engine/Operator/Attribute.cpp b/src/Engine/Operator/Attribute.cpp index 9849f19..09d5e22 100644 --- a/src/Engine/Operator/Attribute.cpp +++ b/src/Engine/Operator/Attribute.cpp @@ -42,6 +42,30 @@ unsigned int ga::Attribute::Attribute::getTypeSize() const } +void ga::Attribute::resize(size_t size) +{ + using namespace enzo::ga; + switch(type_) + { + case AttributeType::intT: + intStore_->resize(size); + break; + case AttributeType::floatT: + floatStore_->resize(size); + break; + case AttributeType::boolT: + boolStore_->resize(size); + break; + case AttributeType::vectorT: + vector3Store_->resize(size); + break; + default: + throw std::runtime_error("type not accounted for"); + + } + +} + ga::Attribute::Attribute(const Attribute& other) { diff --git a/src/Engine/Operator/Attribute.h b/src/Engine/Operator/Attribute.h index abd2745..cb96ef0 100644 --- a/src/Engine/Operator/Attribute.h +++ b/src/Engine/Operator/Attribute.h @@ -24,6 +24,7 @@ namespace enzo{ std::string getName() const; unsigned int getTypeSize() const; + void resize(size_t size); template diff --git a/src/Engine/Operator/Geometry.cpp b/src/Engine/Operator/Geometry.cpp index 266724d..db1f1d3 100644 --- a/src/Engine/Operator/Geometry.cpp +++ b/src/Engine/Operator/Geometry.cpp @@ -66,6 +66,38 @@ enzo::geo::Geometry& enzo::geo::Geometry::operator=(const enzo::geo::Geometry& r return *this; } +// void geo::Geometry::merge(Geometry& other) +// { +// pointAttributes_.reserve(pointAttributes_.size()+other.pointAttributes_.size()); +// ga::Offset attributeSize = getNumPoints(); + +// // add each other attribute to self +// for(std::shared_ptr otherAttribute : other.pointAttributes_) +// { +// bt::String otherAttributeName = otherAttribute->getName(); +// bool alreadyExists = false; +// for(std::shared_ptr attribute : pointAttributes_) +// { +// if(otherAttributeName == attribute->getName()) +// { +// alreadyExists = true; +// break; +// } +// } + +// if(alreadyExists) +// { +// for +// } +// else +// { +// otherAttribute->resize(attributeSize); +// } +// +// } + +// } + void geo::Geometry::addFace(const std::vector& pointOffsets, bool closed) { const ga::Offset primNum = vertexCountHandlePrim_.getSize(); diff --git a/src/Engine/Operator/Geometry.h b/src/Engine/Operator/Geometry.h index 666b905..3960e9d 100644 --- a/src/Engine/Operator/Geometry.h +++ b/src/Engine/Operator/Geometry.h @@ -72,6 +72,8 @@ public: bt::boolT isClosed(ga::Offset primOffset) const; + void merge(Geometry& other); + void computePrimStartVertices() const; private: using attribVector = std::vector>; diff --git a/tests/NetworkTests.cpp b/tests/NetworkTests.cpp index 3a370b6..01cba82 100644 --- a/tests/NetworkTests.cpp +++ b/tests/NetworkTests.cpp @@ -26,7 +26,8 @@ struct OperatorTableInit OperatorTableInit() { enzo::op::OperatorTable::initPlugins(); } }; static OperatorTableInit _operatorTableInit; -auto testOpInfo = enzo::op::OperatorTable::getOpInfo("house").value(); +auto testOpInfoOptional = enzo::op::OperatorTable::getOpInfo("grid"); +auto testOpInfo = testOpInfoOptional.value(); TEST_CASE_METHOD(NMReset, "network fixture separation start") { diff --git a/tests/OperatorTests.cpp b/tests/OperatorTests.cpp index cd662ff..6bdf31c 100644 --- a/tests/OperatorTests.cpp +++ b/tests/OperatorTests.cpp @@ -32,7 +32,7 @@ TEST_CASE("geometry") // check getter std::shared_ptr myAttribute = geo.getAttribByName(ga::AttrOwner::POINT, "index"); - ga::AttributeHandle myHandle2(myAttribute); + ga::AttributeHandle myHandle2(myAttribute); REQUIRE(myHandle2.getValue(0)==5); REQUIRE(myHandle2.getValue(1)==6);