diff --git a/src/graph/NodesCore.hpp b/src/graph/NodesCore.hpp index 9e298e76..09b3c495 100644 --- a/src/graph/NodesCore.hpp +++ b/src/graph/NodesCore.hpp @@ -400,10 +400,14 @@ struct YieldPointsNode : IPointsNodeSingleInput std::vector getRequiredFieldList() const override { return fields; } // Point cloud description - bool hasField(rgl_field_t field) const override { return results.contains(field); } + bool hasField(rgl_field_t field) const override + { + // The `results` map cannot be relied on because the hasField() may be called before the node has finished executing. + return std::find(fields.begin(), fields.end(), field) != fields.end(); + } // Data getters - IAnyArray::ConstPtr getFieldData(rgl_field_t field) override { return results.at(field); } + IAnyArray::ConstPtr getFieldData(rgl_field_t field) override; HostPinnedArray::type>::Ptr getXYZCache() { return xyzHostCache; } diff --git a/src/graph/YieldPointsNode.cpp b/src/graph/YieldPointsNode.cpp index b6a0b6ba..d0bcb43a 100644 --- a/src/graph/YieldPointsNode.cpp +++ b/src/graph/YieldPointsNode.cpp @@ -16,6 +16,7 @@ void YieldPointsNode::setParameters(const std::vector& fields) { + results.clear(); if (std::find(fields.begin(), fields.end(), RGL_FIELD_DYNAMIC_FORMAT) != fields.end()) { throw InvalidAPIArgument("cannot yield field 'RGL_FIELD_DYNAMIC_FORMAT'"); // TODO: Yeah, but dummies are OK? } @@ -33,3 +34,11 @@ void YieldPointsNode::enqueueExecImpl() xyzHostCache->getCount() * xyzHostCache->getSizeOf(), cudaMemcpyDefault, getStreamHandle())); } } + +IAnyArray::ConstPtr YieldPointsNode::getFieldData(rgl_field_t field) +{ + if (!results.contains(field)) { + throw std::runtime_error("Field data is not ready yet. It was requested without waiting for results."); + } + return results.at(field); +}