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.
Methods
addMissingNode
Add a child view node to this node, created from the renderable given as argument If the node creation fails or the argument is falsy, returns undefined Otherwise, returns the newly created node or the existing node
Argument
Type
Required
Description
dobj
Yes
addMissingNodes
Argument
Type
Required
Description
dataObjs
Yes
apply
Argument
Type
Required
Description
renderPass
vtkRenderPass
Yes
prepass
Yes
build
Builds myself.
Argument
Type
Required
Description
prepass
Yes
createViewNode
Argument
Type
Required
Description
dataObj
Yes
extend
Method used to decorate a given object (publicAPI+model) with vtkViewNode characteristics.
Argument
Type
Required
Description
publicAPI
Yes
object on which methods will be bounds (public)
model
Yes
object on which data structure will be bounds (protected)
initialValues
IViewNodeInitialValues
No
(default: {})
getChildren
getChildrenByReference
getFirstAncestorOfType
Find the first parent/grandparent of the desired type
Argument
Type
Required
Description
type
Yes
getLastAncestorOfType
Find the last parent/grandparent of the desired type
Argument
Type
Required
Description
type
Yes
getMyFactory
getParent
getRenderable
Get The data object (thing to be rendered).
getViewNodeFor
Returns the view node that corresponding to the provided object Will return NULL if a match is not found in self or descendents
Argument
Type
Required
Description
dataObject
Yes
getVisited
newInstance
Method used to create a new instance of vtkViewNode.
Argument
Type
Required
Description
initialValues
IViewNodeInitialValues
No
for pre-setting some of its content
prepareNodes
removeNode
Removes a child view node If the node is not found, returns false Otherwise, removes the node from the children list and returns true
Argument
Type
Required
Description
dobj
Yes
removeUnusedNodes
render
Makes calls to make self visible.
Argument
Type
Required
Description
prepass
Yes
setMyFactory
Argument
Type
Required
Description
myFactory
Yes
setParent
Argument
Type
Required
Description
parent
Yes
setRenderable
Argument
Type
Required
Description
renderable
Yes
setVisited
Argument
Type
Required
Description
val
Yes
traverse
Traverse this node with the specified pass. If you want to traverse your children in a specific order or way override this method
export interface vtkViewNode extends vtkObject { /** * Add a child view node to this node, created from the renderable given as argument * If the node creation fails or the argument is falsy, returns undefined * Otherwise, returns the newly created node or the existing node * @paramdobj */ addMissingNode(dobj: any): vtkViewNode | undefined;
/** * Removes a child view node * If the node is not found, returns false * Otherwise, removes the node from the children list and returns true * @paramdobj */ removeNode(dobj: any): boolean;
/** * Find the first parent/grandparent of the desired type * @paramtype */ getFirstAncestorOfType(type: any): void;
/** * Find the last parent/grandparent of the desired type * @paramtype */ getLastAncestorOfType(type: any): void;
/** * */ getMyFactory(): any;
/** * */ getParent(): any;
/** * Get The data object (thing to be rendered). */ getRenderable(): any;
/** * Returns the view node that corresponding to the provided object * Will return NULL if a match is not found in self or descendents * @paramdataObject */ getViewNodeFor(dataObject: any): any;
/** * Traverse this node with the specified pass. If you want to traverse your * children in a specific order or way override this method * @param {vtkRenderPass} renderPass */ traverse(renderPass: vtkRenderPass): void; }
/** * Method used to decorate a given object (publicAPI+model) with vtkViewNode characteristics. * * @param publicAPI object on which methods will be bounds (public) * @param model object on which data structure will be bounds (protected) * @param {IViewNodeInitialValues} [initialValues] (default: {}) */ exportfunctionextend( publicAPI: object, model: object, initialValues?: IViewNodeInitialValues ): void;
/** * Method used to create a new instance of vtkViewNode. * @param {IViewNodeInitialValues} [initialValues] for pre-setting some of its content */ exportfunctionnewInstance( initialValues?: IViewNodeInitialValues ): vtkViewNode;
/** * a node within a VTK scene graph * * 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. */ export declare constvtkViewNode: { newInstance: typeof newInstance; extend: typeof extend; }; exportdefault vtkViewNode;
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.getLastAncestorOfType = (type) => { if (!model._parent) { returnnull; } const lastAncestor = model._parent.getLastAncestorOfType(type); if (lastAncestor) { return lastAncestor; } if (model._parent.isA(type)) { return model._parent; } returnnull; };
// add a missing node/child for the passed in renderables. This should // be called only in between prepareNodes and removeUnusedNodes publicAPI.addMissingNode = (dobj) => { if (!dobj) { returnundefined; }
// if found just mark as visited const result = model._renderableChildMap.get(dobj); if (result !== undefined) { result.setVisited(true); return result; }
// 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); return newNode; }
returnundefined; };
// add missing nodes/children for the passed in renderables. This should // be called only in between prepareNodes and removeUnusedNodes publicAPI.addMissingNodes = (dataObjs) => { if (!dataObjs || !dataObjs.length) { return; }
for (let index = 0; index < dataObjs.length; ++index) { const dobj = dataObjs[index]; publicAPI.addMissingNode(dobj); } };
// ability to add children that have no renderable use in the same manner // as addMissingNodes This case is when a normal viewnode wants to // delegate passes to a helper or child that doeasn't map to a clear // renderable or any renderable publicAPI.addMissingChildren = (children) => { if (!children || !children.length) { return; }
for (let index = 0; index < children.length; ++index) { const child = children[index]; const cindex = model.children.indexOf(child); if (cindex === -1) { child.setParent(publicAPI); model.children.push(child); const childRenderable = child.getRenderable(); if (childRenderable) { model._renderableChildMap.set(childRenderable, child); } } child.setVisited(true); } };
publicAPI.removeUnusedNodes = () => { let visitedCount = 0; for (let index = 0; index < model.children.length; ++index) { const child = model.children[index]; const visited = child.getVisited(); if (visited) { model.children[visitedCount++] = child; child.setVisited(false); } else { const renderable = child.getRenderable(); if (renderable) { model._renderableChildMap.delete(renderable); } child.delete(); } }
model.children.length = visitedCount; };
publicAPI.createViewNode = (dataObj) => { if (!model.myFactory) { vtkErrorMacro('Cannot create view nodes without my own factory'); returnnull; } const ret = model.myFactory.createNode(dataObj); if (ret) { ret.setRenderable(dataObj); } return ret; };
const parentDelete = publicAPI.delete; publicAPI.delete = () => { for (let i = 0; i < model.children.length; i++) { model.children[i].delete(); } parentDelete(); }; }