[New Component] Addition of new methods based on jira issue number 105 - #2
[New Component] Addition of new methods based on jira issue number 105#2bouamarakamelia wants to merge 8 commits into
Conversation
… file that has the needed data
f8c4580 to
fa0a675
Compare
| path.push_back(cur); | ||
| if (cur == m_rootId) break; | ||
| const auto& parents = parentsOf(cur); | ||
| if (parents.empty()) return {}; |
There was a problem hiding this comment.
Not sure to get this return, if you loop several time and suddently there si no more parents, it means you reach the root node no? For me you should exit the while loop and return path no?
| if (parents.empty()) return {}; | |
| if (parents.empty()) { std::reverse(path.begin(), path.end()); return path;} |
There was a problem hiding this comment.
I think this one should stay as-is, though the code didn't make the reason clear enoug
my fault, I've added a comment.
The root case is already handled by the check immediately above: ligne
if (cur == m_rootId) break; // root exits here
if (!parentsOf(cur, parents)) // so reaching this means: parentless AND not the root
So this branch only fires for a node whose parent chain never reaches the root . For esample, a vertex in a component disconnected from it.
If we reversed and returned the path there, the caller would get back a sequence that doesn't start at the root, with no way to tell it apart from a valid one. That would show up directly in the pathFromRoot column of the CSV export as plausible-looking but wrong paths for orphaned nodes.
Returning empty keeps the contract simple: a non-empty result always starts at the root and ends at the requested node.
| const std::vector<int>& childrenOf(int nodeId) const; | ||
| std::vector<int> pathFromRoot(int nodeId) const; | ||
| std::vector<int> subtree(int nodeId) const; | ||
| void exportReportCSV(const std::string& filename) const; |
There was a problem hiding this comment.
what does this report do? just add a comment: ///< export CSV report using @sa d_outReportFilename that will...
| sofa::core::objectmodel::DataFileName d_inSkeletonFilename; ///< Path to the skeleton polyline file to read (e.g. skeleton.txt) | ||
| sofa::core::objectmodel::Data<VecCoord> d_inVertices; ///< Optional input mesh vertices, to link skeleton nodes to the mesh | ||
| sofa::core::objectmodel::Data<Vec3> d_inEntryPoint; ///< Approx. entry point; closest node becomes the tree root | ||
| sofa::core::objectmodel::DataFileName d_outReportFilename; /// CSV report that guves out the ide, 3D coordinates, parent vertice and child vertice |
There was a problem hiding this comment.
| sofa::core::objectmodel::DataFileName d_outReportFilename; /// CSV report that guves out the ide, 3D coordinates, parent vertice and child vertice | |
| sofa::core::objectmodel::DataFileName d_outReportFilename; /// CSV report that gives out the ids, 3D coordinates, parent vertex and child vertex |
vertex or vertices
Co-authored-by: erik pernod <erik.pernod@gmail.com>
|
@epernod it's done and ready for correction |
1. Description
Extends
SkeletonGraph/SkeletonReaderwith node-level query methods (parents, children, path from root, subtree) and a new human-readable CSV export, so the skeleton tree can be inspected per-node without needing ParaView or writing custom code.2. Newest features
node(nodeId) : safe lookup by id
m_nodes.nullptrfor an invalid id instead of crashing.parentsOf(nodeId) / childrenOf(nodeId)
node().pathFromRoot(nodeId)
parentIds().front()) back to the root, then reverses the result to get root → ... →nodeId, inclusive.subtree(nodeId)
childrenIds, collecting every node reachable fromnodeId(itself included).exportReportCSV(filename)
id, x, y, z, parentId, childrenIds, pathFromRoot, loopParentIds.parentIdis the single primary (tree) parent for the common case; any extra parent from a loop-closing node is kept in a separateloopParentIdscolumn so nothing is silently dropped.SkeletonReaderas a new output Data field,outputReport.3. Results
exportReportCSVcompiled and run for real against what we have;outputReport="report.csv"on<SkeletonReader/>, no other component or file affected.4. Example of the componenet in the scene (use case)