This is the superclass for all nodes within a VTK scene graph. It contains the API for a node. It supports the essential operations such as graph creation, state storage and traversal. Child classes adapt this to VTK’s major rendering classes. Grandchild classes adapt those to for APIs of different rendering libraries.
build(prepass)
Builds myself.
synchronize(prepass )
Ensures that my state agrees with my Renderable’s.
render( prepass )
Makes calls to make self visible.
parent
The view node that owns this view node
children
The View nodes gthat this nodeowns
//A factory that creates particular subclasses for different //rendering back ends. virtual void SetMyFactory(vtkViewNodeFactory*); vtkGetObjectMacro(MyFactory, vtkViewNodeFactory);
getViewNodeFor ( dataObject )
Returns the view node that corresponding to the provided object Will return NULL if a match is not found in self or descendents
getFirstAncestorOfType( type )
Find the first parent/grandparent of the desired type
renderable
The data object (thing to be rendered)
traverse ( operation )
Traverse this node with the specified pass. If you want to traverse your children in a specific order or way override this method
publicAPI.traverse = (renderPass) => { // we can choose to do special // traversal here based on pass const passTraversal = renderPass.getTraverseOperation(); const fn = publicAPI[passTraversal]; if (fn) { fn(renderPass); return; }
for (let index = 0; index < model.children.length; ++index) { const child = model.children[index]; const vn = child.getViewNodeFor(dataObject); if (vn) { return vn; } } returnundefined; };
publicAPI.getFirstAncestorOfType = (type) => { if (!model.parent) { returnnull; } if (model.parent.isA(type)) { return model.parent; } return model.parent.getFirstAncestorOfType(type); };
publicAPI.addMissingNode = (dobj) => { if (!dobj) { return; } const result = model.renderableChildMap.get(dobj); // if found just mark as visited if (result !== undefined) { result.setVisited(true); } else { // otherwise create a node const newNode = publicAPI.createViewNode(dobj); if (newNode) { newNode.setParent(publicAPI); newNode.setVisited(true); model.renderableChildMap.set(dobj, newNode); model.children.push(newNode); } } };
for (let index = 0; index < dataObjs.length; ++index) { const dobj = dataObjs[index]; const result = model.renderableChildMap.get(dobj); // if found just mark as visited if (result !== undefined) { result.setVisited(true); } else { // otherwise create a node const newNode = publicAPI.createViewNode(dobj); if (newNode) { newNode.setParent(publicAPI); newNode.setVisited(true); model.renderableChildMap.set(dobj, newNode); model.children.push(newNode); } } } };
publicAPI.prepareNodes = () => { for (let index = 0; index < model.children.length; ++index) { model.children[index].setVisited(false); } };