#include "Engine/Operator/Geometry.h" #include "Engine/Operator/Attribute.h" #include "Engine/Operator/AttributeHandle.h" #include "Engine/Types.h" #include #include using namespace enzo; geo::Geometry::Geometry() { addVector3Attribute(ga::AttrOwner::POINT, "P"); addIntAttribute(ga::AttrOwner::VERTEX, "point"); addIntAttribute(ga::AttrOwner::PRIMITIVE, "vertexCount"); } ga::AttributeHandle geo::Geometry::addIntAttribute(ga::AttributeOwner owner, std::string name) { auto newAttribute = std::make_shared(name, ga::AttrType::intT); getAttributeStore(owner).push_back(newAttribute); return ga::AttributeHandle(newAttribute); } ga::AttributeHandle geo::Geometry::addVector3Attribute(ga::AttributeOwner owner, std::string name) { auto newAttribute = std::make_shared(name, ga::AttrType::vectorT); getAttributeStore(owner).push_back(newAttribute); return ga::AttributeHandle(newAttribute); } std::vector>& geo::Geometry::getAttributeStore(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 geo::Geometry::getAttribByName(ga::AttributeOwner owner, std::string name) { auto& vector = getAttributeStore(owner); for(auto it=vector.begin(); it!=vector.end(); ++it) { if((*it)->getName()==name) { return (*it); } } return nullptr; }