- This topic has 1 reply, 2 voices, and was last updated 5 years, 11 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Using SOFA › How to search Node?
Tagged: 64_bits, search node, SOFA_1712, Windows_10
Hello everyone,
I want to search node by tags. The code I wrote is shown below:
simulation::Node* node = context->get<simulation::Node>(this->getTags(), sofa::core::objectmodel::BaseContext::SearchRoot);
However, it does not work. The value of the node is still NULL after all.
What is the problem?
Wong
Hi Wong,
The “get” function from the Context class only search for components contained inside a Node, but not the nodes themselves. Unfortunately, I don’t think such search function for nodes exists. You can however convert your current context to a “DAGNode”:
#include <SofaSimulationGraph/DAGNode.h>
auto DNode = dynamic_cast<const sofa::simulation::graph::DAGNode *> (context);
And then, use the following methods from your DAGNode to traverse the simulation tree:
sofa::helper::vector< BaseNode* > getParents() const override;
BaseNode* getFirstParent() const;
sofa::helper::vector< BaseNode* > getChildren() const override;
bool hasTag( Tag t ) const;
const TagSet& getTags() const;
Hope this helps,
Jean-Nicolas
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.