Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RootNode and InternalNode Probe Methods #1936

Conversation

danrbailey
Copy link
Contributor

This PR adds a bunch of new "probe" methods to fill in some gaps in the API in being able to query child nodes as well as adds some additional convenience methods.

RootNode

The root node adds convenience methods to query the child nodes (as opposed to needing to supply a template parameter probeNode<ChildT>(const Coord&)). In addition, there are new probe() methods that query whether a key exists (and returns false if not) and returns either a child node or a value and active state otherwise. Finally, a templated probeNode() method that can be called on a const RootNode has been added.

Here are all the new RootNode methods:

ChildNodeType*       RootNode::probeChild(const Coord&);
const ChildNodeType* RootNode::probeConstChild(const Coord&) const;
const ChildNodeType* RootNode::probeChild(const Coord&) const;
bool                 RootNode::probe(const Coord&, ChildNodeType*&, ValueType&, bool&);
bool                 RootNode::probeConst(const Coord&, const ChildNodeType*&, ValueType&, bool&) const;
bool                 RootNode::probe(const Coord&, const ChildNodeType*&, ValueType&, bool&) const;
template <typename NodeT> 
const NodeT*         RootNode::probeNode(const Coord&) const;

InternalNode

The internal node adds convenience methods to query the child nodes (as opposed to needing to supply a template parameter probeNode<ChildT>(const Coord&)). In addition, there are also methods that allow querying from an offset (and ensures the offset is not out-of-bounds) as well as being able to pass in value and active state reference variables that are populated if a child node is not present. Finally, a templated probeNode() method that can be called on a const InternalNode has been added.

Here are all the new InternalNode methods:

ChildNodeType*       InternalNode::probeChild(const Coord&);
const ChildNodeType* InternalNode::probeConstChild(const Coord&) const;
const ChildNodeType* InternalNode::probeChild(const Coord&) const;
ChildNodeType*       InternalNode::probeChild(const Coord&, ValueType&, bool&);
const ChildNodeType* InternalNode::probeConstChild(const Coord&, ValueType&, bool&) const;
const ChildNodeType* InternalNode::probeChild(const Coord&, ValueType&, bool&) const;
ChildNodeType*       InternalNode::probeChild(Index);
const ChildNodeType* InternalNode::probeConstChild(Index) const;
const ChildNodeType* InternalNode::probeChild(Index) const;
ChildNodeType*       InternalNode::probeChild(Index, ValueType&, bool&);
const ChildNodeType* InternalNode::probeConstChild(Index, ValueType&, bool&) const;
const ChildNodeType* InternalNode::probeChild(Index, ValueType&, bool&) const;
template<typename NodeType>
const NodeType*      InternalNode::probeNode(const Coord&) const;

Signed-off-by: Dan Bailey <[email protected]>
Signed-off-by: Dan Bailey <[email protected]>
Copy link
Contributor

@kmuseth kmuseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see omments

openvdb/openvdb/tree/InternalNode.h Outdated Show resolved Hide resolved
openvdb/openvdb/tree/InternalNode.h Outdated Show resolved Hide resolved
openvdb/openvdb/tree/InternalNode.h Outdated Show resolved Hide resolved
openvdb/openvdb/tree/InternalNode.h Outdated Show resolved Hide resolved
openvdb/openvdb/tree/RootNode.h Show resolved Hide resolved
openvdb/openvdb/tree/RootNode.h Outdated Show resolved Hide resolved
openvdb/openvdb/tree/RootNode.h Show resolved Hide resolved
openvdb/openvdb/tree/RootNode.h Outdated Show resolved Hide resolved
openvdb/openvdb/tree/RootNode.h Show resolved Hide resolved
Signed-off-by: Dan Bailey <[email protected]>
@danrbailey
Copy link
Contributor Author

Addressed all the feedback in this PR, thanks!

@danrbailey danrbailey merged commit 57d4201 into AcademySoftwareFoundation:feature/tree_api_tests Oct 29, 2024
40 checks passed
@danrbailey danrbailey deleted the tree_api_probe branch October 29, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants