feat(engine): add geometry class
This commit is contained in:
55
src/Engine/Operator/Geometry.cpp
Normal file
55
src/Engine/Operator/Geometry.cpp
Normal 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user