feat: add string parameter

This commit is contained in:
parker
2025-08-03 22:15:23 +01:00
parent abc9419998
commit 0af1c65996
14 changed files with 189 additions and 27 deletions

View File

@@ -5,7 +5,7 @@
#include <oneapi/tbb/parallel_for.h>
#include <fstream>
#include <string>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string.hpp>
GopGeometryImport::GopGeometryImport(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo)
: GeometryOpDef(network, opInfo)
@@ -19,11 +19,27 @@ void GopGeometryImport::cookOp(enzo::op::Context context)
if(outputRequested(0))
{
std::string filePath = "/home/parker/Downloads/Rat_Placeholder_Polycount_12.obj";
std::cout << "COOKING IMPORT NODE\n";
geo::Geometry geo;
bt::String filePath = context.evalStringParm("filePath");
boost::trim(filePath);
if(filePath.size()<4)
{
throwError("file path too small");
setOutputGeometry(0, geo);
return;
}
std::string fileExt = filePath.substr(filePath.size()-4, filePath.size());
if(fileExt!=".obj")
{
throwError("File path not accepted: " + fileExt);
setOutputGeometry(0, geo);
return;
}
auto PAttr = geo.getAttribByName(ga::AttrOwner::POINT, "P");
ga::AttributeHandleVector3 PAttrHandle(PAttr);
@@ -37,6 +53,7 @@ void GopGeometryImport::cookOp(enzo::op::Context context)
if(!file.is_open())
{
std::cerr << "Failed to open file " << filePath << "\n";
setOutputGeometry(0, geo);
return;
}
@@ -105,6 +122,7 @@ void GopGeometryImport::cookOp(enzo::op::Context context)
enzo::prm::Template GopGeometryImport::parameterList[] =
{
enzo::prm::Template(enzo::prm::Type::STRING, "filePath", 1),
enzo::prm::Template(enzo::prm::Type::FLOAT, "size", 1),
enzo::prm::Terminator
};