feat(engine): add geometry class

This commit is contained in:
parker
2025-06-29 20:49:30 +01:00
parent deb237e481
commit 7db66aedeb
9 changed files with 118 additions and 69 deletions

View File

@@ -0,0 +1,55 @@
#include "Engine/Operator/Geometry.h"
#include "Engine/Operator/Attribute.h"
#include "Engine/Operator/AttributeHandle.h"
#include "Engine/Types.h"
#include <memory>
#include <stdexcept>
using namespace enzo;
geo::Geometry::Geometry()
{
}
ga::AttributeHandle<int> geo::Geometry::addIntAttribute(ga::AttributeOwner owner, std::string name)
{
auto newAttribute = std::make_shared<ga::Attribute>(name, ga::AttrType::intT);
getOwnerVector(owner).push_back(newAttribute);
return ga::AttributeHandle<int>(newAttribute);
}
std::vector<std::shared_ptr<ga::Attribute>>& geo::Geometry::getOwnerVector(ga::AttributeOwner& owner)
{
switch(owner)
{
case ga::AttributeOwner::POINT:
return pointAttributes_;
break;
case ga::AttributeOwner::VERTEX:
return vertexAttributes_;
break;
case ga::AttributeOwner::PRIMITIVE:
return primitiveAttributes_;
break;
case ga::AttributeOwner::GLOBAL:
return globalAttributes_;
break;
default:
throw std::runtime_error("Unexpected, owner could not be found");
}
}
std::shared_ptr<ga::Attribute> geo::Geometry::getAttribByName(ga::AttributeOwner owner, std::string name)
{
auto& vector = getOwnerVector(owner);
for(auto it=vector.begin(); it!=vector.end(); ++it)
{
if((*it)->getName()==name)
{
return (*it);
}
}
return nullptr;
}