VTK  9.0.20200925
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
vtkDataAssembly Class Reference

hierarchical representation to use with vtkPartitionedDataSetCollection More...

#include <vtkDataAssembly.h>

Inheritance diagram for vtkDataAssembly:
[legend]
Collaboration diagram for vtkDataAssembly:
[legend]

Public Types

enum  TraversalOrder { DepthFirst = 0, BreadthFirst }
 
typedef vtkObject Superclass
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkDataAssemblyNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
void Initialize ()
 Initializes the data-assembly. More...
 
bool InitializeFromXML (const char *xmlcontents)
 Initializes a data-assembly using an XML representation of the assembly. More...
 
std::string SerializeToXML (vtkIndent indent) const
 Saves the data-assembly as a XML. More...
 
void SetRootNodeName (const char *name)
 Get/Set root node name. More...
 
const char * GetRootNodeName () const
 
int AddNode (const char *name, int parent=0)
 Adds a node to the assembly with the given name and returns its id. More...
 
std::vector< int > AddNodes (const std::vector< std::string > &names, int parent=0)
 Same as AddNode except allows adding multiple nodes in one go. More...
 
bool RemoveNode (int id)
 Removes a node from the assembly. More...
 
void SetNodeName (int id, const char *name)
 Get/Set a node's name. More...
 
const char * GetNodeName (int id) const
 
std::string GetNodePath (int id) const
 Returns the path for a node. More...
 
bool AddDataSetIndex (int id, unsigned int dataset_index)
 Add a dataset index to a node. More...
 
bool AddDataSetIndices (int id, const std::vector< unsigned int > &dataset_indices)
 Same as AddDataSetIndex except supported adding multiple dataset indices in one go. More...
 
bool RemoveDataSetIndex (int id, unsigned int dataset_index)
 Removes a dataset index from a node. More...
 
bool RemoveAllDataSetIndices (int id, bool traverse_subtree=true)
 Clears all dataset indices from the node. More...
 
int FindFirstNodeWithName (const char *name, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
 Finds first node that is encountered in a breadth first traversal of the assembly with the given name. More...
 
std::vector< int > FindNodesWithName (const char *name, int sort_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
 Finds all nodes with the given name. More...
 
std::vector< int > GetChildNodes (int parent, bool traverse_subtree=true, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
 Returns ids for all child nodes. More...
 
int GetNumberOfChildren (int parent) const
 Returns the number of child nodes. More...
 
int GetChild (int parent, int index) const
 Returns the id for a child not at the given index, if valid, otherwise -1. More...
 
int GetChildIndex (int parent, int child) const
 Returns the index for a child under a given. More...
 
int GetParent (int id) const
 Returns the id for the parent node, if any. More...
 
void Visit (vtkDataAssemblyVisitor *visitor, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
 Visit each node in the assembly for processing. More...
 
void Visit (int id, vtkDataAssemblyVisitor *visitor, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
 
std::vector< unsigned int > GetDataSetIndices (int id, bool traverse_subtree=true, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
 Returns the dataset indices associated with the node. More...
 
std::vector< int > SelectNodes (const std::vector< std::string > &path_queries, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
 Returns ids for nodes matching the path_queries. More...
 
bool RemapDataSetIndices (const std::map< unsigned int, unsigned int > &mapping, bool remove_unmapped)
 Remap dataset indices. More...
 
void SubsetCopy (vtkDataAssembly *other, const std::vector< int > &selected_branches)
 Create a deep-copy of other by only passing the chosen branches. More...
 
void DeepCopy (vtkDataAssembly *other)
 Deep copy the other. More...
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on. More...
 
virtual void DebugOff ()
 Turn debugging output off. More...
 
bool GetDebug ()
 Get the value of the debug flag. More...
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag. More...
 
virtual void Modified ()
 Update the modification time for this object. More...
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time. More...
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 
vtkCommandGetCommand (unsigned long tag)
 
void RemoveObserver (vtkCommand *)
 
void RemoveObservers (unsigned long event, vtkCommand *)
 
void RemoveObservers (const char *event, vtkCommand *)
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method. More...
 
int InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
int InvokeEvent (const char *event, void *callData)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual vtkIdType GetNumberOfGenerationsFromBase (const char *name)
 Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
virtual void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
bool GetIsInMemkind () const
 A local state flag that remembers whether this object lives in the normal or extended memory space. More...
 

Static Public Member Functions

static vtkDataAssemblyNew ()
 
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkDataAssemblySafeDownCast (vtkObjectBase *o)
 
static int GetRootNode ()
 Returns the ID for the root node. More...
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes. More...
 
static void SetGlobalWarningDisplay (int val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static int GetGlobalWarningDisplay ()
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkIdType GetNumberOfGenerationsFromBaseType (const char *name)
 Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void SetMemkindDirectory (const char *directoryname)
 The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More...
 
static bool GetUsingMemkind ()
 A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More...
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkDataAssembly ()
 
 ~vtkDataAssembly () override
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events. More...
 
void InternalReleaseFocus ()
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Additional Inherited Members

- Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction GetCurrentMallocFunction ()
 
static vtkReallocingFunction GetCurrentReallocFunction ()
 
static vtkFreeingFunction GetCurrentFreeFunction ()
 
static vtkFreeingFunction GetAlternateFreeFunction ()
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

hierarchical representation to use with vtkPartitionedDataSetCollection

vtkDataAssembly is a mechanism to represent hierarchical organization of items (or vtkPartitionedDataSet instances) in a vtkPartitionedDataSetCollection. vtkPartitionedDataSetCollection is similar to a vtkMultiBlockDataSet since it provides a means for putting together multiple non-composite datasets. However, vtkPartitionedDataSetCollection itself doesn't provide any mechanism to define relationships between items in the collections. That is done using vtkDataAssembly.

Overview

At its core, vtkDataAssembly is simply a tree comprising on nodes starting with the root node. Each node has a unique id and a string name (names need not be unique). On initialization, vtkDataAssembly::Initialize a empty tree with a root node is created. The root node's id and name can be obtained using vtkDataAssembly::GetRootNode and vtkDataAssembly::GetRootNodeName. The root node's id is fixed (vtkDataAssembly::GetRootNode), however the name can be changed using vtkDataAssembly::SetRootNodeName.

Child nodes can be added using vtkDataAssembly::AddNode or vtkDataAssembly::AddNodes, each of which returns the ids for every child node added. A non-root node can be removed using vtkDataAssembly::RemoveNode.

Each node in the tree (including the root node) can has associated dataset indices. For a vtkDataAssembly associated with a vtkPartitionedDataSetCollection, these indices refer to the item index, or partioned-dataset-index for items in the collection. Dataset indices can be specified using vtkDataAssembly::AddDataSetIndex, vtkDataAssembly::AddDataSetIndices and removed using vtkDataAssembly::RemoveDataSetIndex, vtkDataAssembly::RemoveAllDataSetIndices. vtkDataAssembly::GetDataSetIndices provides a mechanism to get the database indices associated with a node, and optionally, the entire subtree rooted at the chosen node.

Searching

Each node in the vtkDataAssembly is assigned a unique id. vtkDataAssembly::FindFirstNodeWithName and vtkDataAssembly::FindNodesWithName can be used to get the id(s) for node(s) with given name.

vtkDataAssembly::SelectNodes provides a more flexible mechanism to find nodes using name-based queries. Section Supported Path Queries covers supported queries.

Traversal

vtkDataAssemblyVisitor defines a visitor API. An instance of concretized vtkDataAssemblyVisitor subclass can be passed to vtkDataAssembly::Visit to traverse the data-assembly hierarchy either in depth-first or breadth-first order.

Supported Path Queries

vtkDataAssembly::SelectNodes can be used find nodes that match the specified query (or queries). The syntax for queries, which is a minimal/simplified subset of XPath location queries, is as follows:

Applications

The separation of dataset storage (vtkPartitionedDataSetCollection) and organization (vtkDataAssembly) enables development of algorithms that can expose APIs that are not tightly coupled to dataset storage. Together, vtkPartitionedDataSetCollection and vtkDataAssembly can be thought of as a different way of organizing data that was previously organized as a vtkMultiBlockDataSet. The advantage of the this newer approach is that filters can support specifying parameters using paths or path queries rather than composite indices. The composite indices suffered from the fact that they made no sense except for the specific vtkMultiBlockDataSet they were applied too. Thus, if the filters input was changed, the composite ids rarely made any sense and needed to be updated. Paths and path queries, however, do not suffer from this issue.

Definition at line 129 of file vtkDataAssembly.h.

Member Typedef Documentation

◆ Superclass

Definition at line 133 of file vtkDataAssembly.h.

Member Enumeration Documentation

◆ TraversalOrder

Enumerator
DepthFirst 
BreadthFirst 

Definition at line 257 of file vtkDataAssembly.h.

Constructor & Destructor Documentation

◆ vtkDataAssembly()

vtkDataAssembly::vtkDataAssembly ( )
protected

◆ ~vtkDataAssembly()

vtkDataAssembly::~vtkDataAssembly ( )
overrideprotected

Member Function Documentation

◆ New()

static vtkDataAssembly* vtkDataAssembly::New ( )
static

◆ IsTypeOf()

static vtkTypeBool vtkDataAssembly::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual vtkTypeBool vtkDataAssembly::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class.

Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

static vtkDataAssembly* vtkDataAssembly::SafeDownCast ( vtkObjectBase o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase* vtkDataAssembly::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkDataAssembly* vtkDataAssembly::NewInstance ( ) const

◆ PrintSelf()

void vtkDataAssembly::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

Methods invoked by print to print information about the object including superclasses.

Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

◆ Initialize()

void vtkDataAssembly::Initialize ( )

Initializes the data-assembly.

When a new vtkDataAssembly instance is created, it is in initialized form and it is not required to call this method to initialize it.

◆ InitializeFromXML()

bool vtkDataAssembly::InitializeFromXML ( const char *  xmlcontents)

Initializes a data-assembly using an XML representation of the assembly.

Returns true if the initialization was successful, otherwise the assembly is set a clean state and returns false.

◆ SerializeToXML()

std::string vtkDataAssembly::SerializeToXML ( vtkIndent  indent) const

Saves the data-assembly as a XML.

◆ GetRootNode()

static int vtkDataAssembly::GetRootNode ( )
inlinestatic

Returns the ID for the root node.

This always returns 0.

Definition at line 163 of file vtkDataAssembly.h.

◆ SetRootNodeName()

void vtkDataAssembly::SetRootNodeName ( const char *  name)
inline

Get/Set root node name.

Defaults to DataAssembly.

Definition at line 169 of file vtkDataAssembly.h.

◆ GetRootNodeName()

const char* vtkDataAssembly::GetRootNodeName ( ) const
inline

Definition at line 170 of file vtkDataAssembly.h.

◆ AddNode()

int vtkDataAssembly::AddNode ( const char *  name,
int  parent = 0 
)

Adds a node to the assembly with the given name and returns its id.

parent is the id for the parent node which defaults to the root node id (i.e. GetRootNode).

If parent is invalid, the add will fail.

Returns
id of the newly added node on success, else -1.

◆ AddNodes()

std::vector<int> vtkDataAssembly::AddNodes ( const std::vector< std::string > &  names,
int  parent = 0 
)

Same as AddNode except allows adding multiple nodes in one go.

If parent is invalid, the add will fail.

Returns
vectors of corresponding indices for each of the names added.

◆ RemoveNode()

bool vtkDataAssembly::RemoveNode ( int  id)

Removes a node from the assembly.

The node identified by the id and all its children are removed.

Root node cannot be removed.

Returns
true if removal was successful, false if the id is invalid or root node id.

◆ SetNodeName()

void vtkDataAssembly::SetNodeName ( int  id,
const char *  name 
)

Get/Set a node's name.

If node id is invalid, SetNodeName will raise an error; GetNodeName will also raise an error and return nullptr.

SetNodeName will raise an error if the name is not valid. Name cannot be empty or nullptr.

◆ GetNodeName()

const char* vtkDataAssembly::GetNodeName ( int  id) const

◆ GetNodePath()

std::string vtkDataAssembly::GetNodePath ( int  id) const

Returns the path for a node.

◆ AddDataSetIndex()

bool vtkDataAssembly::AddDataSetIndex ( int  id,
unsigned int  dataset_index 
)

Add a dataset index to a node.

The node id can refer to any valid node in the assembly, including the root.

While the same dataset can be added multiple times in the assembly, it cannot be added multiple times to the same node. Additional adds will fail.

Returns
true if addition succeeded else false.

◆ AddDataSetIndices()

bool vtkDataAssembly::AddDataSetIndices ( int  id,
const std::vector< unsigned int > &  dataset_indices 
)

Same as AddDataSetIndex except supported adding multiple dataset indices in one go.

Note, a dataset index only gets added once.

Returns
true if any dataset index was successfully added.

◆ RemoveDataSetIndex()

bool vtkDataAssembly::RemoveDataSetIndex ( int  id,
unsigned int  dataset_index 
)

Removes a dataset index from a node.

Returns
true if the removal was successful, else returns false.

◆ RemoveAllDataSetIndices()

bool vtkDataAssembly::RemoveAllDataSetIndices ( int  id,
bool  traverse_subtree = true 
)

Clears all dataset indices from the node.

If traverse_subtree is true (default), recursively removes all dataset indices from all the child nodes.

Returns
true on success, else returns false.

◆ FindFirstNodeWithName()

int vtkDataAssembly::FindFirstNodeWithName ( const char *  name,
int  traversal_order = vtkDataAssembly::TraversalOrder::DepthFirst 
) const

Finds first node that is encountered in a breadth first traversal of the assembly with the given name.

Returns
the if of the node if found, else -1.

◆ FindNodesWithName()

std::vector<int> vtkDataAssembly::FindNodesWithName ( const char *  name,
int  sort_order = vtkDataAssembly::TraversalOrder::DepthFirst 
) const

Finds all nodes with the given name.

The nodes can be ordered depth first or breadth first, based on the sort_order flag.

◆ GetChildNodes()

std::vector<int> vtkDataAssembly::GetChildNodes ( int  parent,
bool  traverse_subtree = true,
int  traversal_order = vtkDataAssembly::TraversalOrder::DepthFirst 
) const

Returns ids for all child nodes.

If traverse_subtree is true (default), recursively builds the child node list. The traversal order can be specified using traversal_order flag; defaults to depth-first.

See also
vtkDataAssembly::Visit, vtkDataAssemblyVisitor

◆ GetNumberOfChildren()

int vtkDataAssembly::GetNumberOfChildren ( int  parent) const

Returns the number of child nodes.

Returns
the number of child nodes for the parent node or 0 if the parent is invalid.

◆ GetChild()

int vtkDataAssembly::GetChild ( int  parent,
int  index 
) const

Returns the id for a child not at the given index, if valid, otherwise -1.

◆ GetChildIndex()

int vtkDataAssembly::GetChildIndex ( int  parent,
int  child 
) const

Returns the index for a child under a given.

-1 if invalid.

◆ GetParent()

int vtkDataAssembly::GetParent ( int  id) const

Returns the id for the parent node, if any.

Returns -1 if the node is invalid or has no parent (i.e. is the root node).

◆ Visit() [1/2]

void vtkDataAssembly::Visit ( vtkDataAssemblyVisitor visitor,
int  traversal_order = vtkDataAssembly::TraversalOrder::DepthFirst 
) const
inline

Visit each node in the assembly for processing.

The traversal order can be specified using traversal_order which defaults to depth-first.

Definition at line 321 of file vtkDataAssembly.h.

◆ Visit() [2/2]

void vtkDataAssembly::Visit ( int  id,
vtkDataAssemblyVisitor visitor,
int  traversal_order = vtkDataAssembly::TraversalOrder::DepthFirst 
) const

◆ GetDataSetIndices()

std::vector<unsigned int> vtkDataAssembly::GetDataSetIndices ( int  id,
bool  traverse_subtree = true,
int  traversal_order = vtkDataAssembly::TraversalOrder::DepthFirst 
) const

Returns the dataset indices associated with the node.

If traverse_subtree is true (default), recursively builds the dataset indices list for the node and all its child nodes. Note, a dataset index will only appear once in the output even if it is encountered on multiple nodes in the subtree.

When traverse_subtree is true, the traversal order can be specified using traversal_order. Defaults to depth-first.

◆ SelectNodes()

std::vector<int> vtkDataAssembly::SelectNodes ( const std::vector< std::string > &  path_queries,
int  traversal_order = vtkDataAssembly::TraversalOrder::DepthFirst 
) const

Returns ids for nodes matching the path_queries.

See Section Supported Path Queries for supported query expressions.

Will return an empty vector is no nodes match the requested query.

Returns
node ids matching the query in traversal order chosen using traversal_order.

◆ RemapDataSetIndices()

bool vtkDataAssembly::RemapDataSetIndices ( const std::map< unsigned int, unsigned int > &  mapping,
bool  remove_unmapped 
)

Remap dataset indices.

mapping is map where the key is the old index and value is the new index. If remove_unmapped is true, then any dataset not in the map will be removed.

◆ SubsetCopy()

void vtkDataAssembly::SubsetCopy ( vtkDataAssembly other,
const std::vector< int > &  selected_branches 
)

Create a deep-copy of other by only passing the chosen branches.

All other branches of the tree will be pruned. Note this method never affects the depth of the selected branches or dataset indices attached to any of the nodes in pruned output.

◆ DeepCopy()

void vtkDataAssembly::DeepCopy ( vtkDataAssembly other)

Deep copy the other.


The documentation for this class was generated from the following file: