Skip to content

Commit c7ea149

Browse files
authored
Minor fixes around yield and compact node (#333)
* Fix yield node to return hasField() according to its map * Require a field that is actually used by the compact node * Fix case when hasField is called before yield node has finished executing
1 parent bd194c7 commit c7ea149

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/graph/NodesCore.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct CompactByFieldPointsNode : IPointsNodeSingleInput
8484
void enqueueExecImpl() override;
8585

8686
// Node requirements
87-
std::vector<rgl_field_t> getRequiredFieldList() const override { return {IS_HIT_I32, IS_GROUND_I32}; }
87+
std::vector<rgl_field_t> getRequiredFieldList() const override { return {fieldToCompactBy}; }
8888

8989
// Point cloud description
9090
bool isDense() const override { return true; }
@@ -399,8 +399,15 @@ struct YieldPointsNode : IPointsNodeSingleInput
399399
// Node requirements
400400
std::vector<rgl_field_t> getRequiredFieldList() const override { return fields; }
401401

402+
// Point cloud description
403+
bool hasField(rgl_field_t field) const override
404+
{
405+
// The `results` map cannot be relied on because the hasField() may be called before the node has finished executing.
406+
return std::find(fields.begin(), fields.end(), field) != fields.end();
407+
}
408+
402409
// Data getters
403-
IAnyArray::ConstPtr getFieldData(rgl_field_t field) override { return results.at(field); }
410+
IAnyArray::ConstPtr getFieldData(rgl_field_t field) override;
404411

405412
HostPinnedArray<Field<XYZ_VEC3_F32>::type>::Ptr getXYZCache() { return xyzHostCache; }
406413

src/graph/YieldPointsNode.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
void YieldPointsNode::setParameters(const std::vector<rgl_field_t>& fields)
1818
{
19+
results.clear();
1920
if (std::find(fields.begin(), fields.end(), RGL_FIELD_DYNAMIC_FORMAT) != fields.end()) {
2021
throw InvalidAPIArgument("cannot yield field 'RGL_FIELD_DYNAMIC_FORMAT'"); // TODO: Yeah, but dummies are OK?
2122
}
@@ -33,3 +34,11 @@ void YieldPointsNode::enqueueExecImpl()
3334
xyzHostCache->getCount() * xyzHostCache->getSizeOf(), cudaMemcpyDefault, getStreamHandle()));
3435
}
3536
}
37+
38+
IAnyArray::ConstPtr YieldPointsNode::getFieldData(rgl_field_t field)
39+
{
40+
if (!results.contains(field)) {
41+
throw std::runtime_error("Field data is not ready yet. It was requested without waiting for results.");
42+
}
43+
return results.at(field);
44+
}

0 commit comments

Comments
 (0)