117#ifndef vtkDataAssembly_h
118#define vtkDataAssembly_h
120#include "vtkCommonDataModelModule.h"
170 void SetRootNodeName(
const char* name) { this->SetNodeName(this->GetRootNode(), name); }
171 const char*
GetRootNodeName()
const {
return this->GetNodeName(this->GetRootNode()); }
182 int AddNode(
const char* name,
int parent = 0);
191 std::vector<int>
AddNodes(
const std::vector<std::string>& names,
int parent = 0);
350#if VTK_ID_TYPE_IMPL != VTK_INT
351 void SetAttribute(
int id,
const char* name,
vtkIdType value);
361 bool GetAttribute(
int id,
const char* name,
unsigned int& value)
const;
362#if VTK_ID_TYPE_IMPL != VTK_INT
363 bool GetAttribute(
int id,
const char* name,
vtkIdType& value)
const;
375#if VTK_ID_TYPE_IMPL != VTK_INT
376 vtkIdType GetAttributeOrDefault(
int id,
const char* name,
vtkIdType default_value)
const;
388 this->Visit(0, visitor, traversal_order);
410 bool traverse_subtree =
true,
423 std::vector<int>
SelectNodes(
const std::vector<std::string>& path_queries,
432 const std::map<unsigned int, unsigned int>& mapping,
bool remove_unmapped);
474 std::unique_ptr<vtkInternals> Internals;
visitor API for vtkDataAssembly
hierarchical representation to use with vtkPartitionedDataSetCollection
int GetParent(int id) const
Returns the id for the parent node, if any.
static int GetRootNode()
Returns the ID for the root node.
std::vector< int > GetChildNodes(int parent, bool traverse_subtree=true, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
Returns ids for all child nodes.
std::vector< int > FindNodesWithName(const char *name, int sort_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
Finds all nodes with the given name.
bool GetAttribute(int id, const char *name, const char *&value) const
Get an attribute value.
bool InitializeFromXML(const char *xmlcontents)
Initializes a data-assembly using an XML representation of the assembly.
void SetAttribute(int id, const char *name, unsigned int value)
Set an attribute.
void DeepCopy(vtkDataAssembly *other)
Deep copy the other.
static bool IsNodeNameValid(const char *name)
Validates a node name.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Visit(int id, vtkDataAssemblyVisitor *visitor, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
Visit each node in the assembly for processing.
bool AddDataSetIndexRange(int id, unsigned int index_start, int count)
Same as AddDataSetIndices except this supports adding a contiguous range of dataset indices in one go...
bool GetAttribute(int id, const char *name, int &value) const
Get an attribute value.
bool AddDataSetIndex(int id, unsigned int dataset_index)
Add a dataset index to a node.
int GetNumberOfChildren(int parent) const
Returns the number of child nodes.
~vtkDataAssembly() override
static vtkDataAssembly * New()
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.
static std::string MakeValidNodeName(const char *name)
Converts any string to a string that is a valid node name.
const char * GetNodeName(int id) const
Get/Set a node's name.
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.
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...
int GetChildIndex(int parent, int child) const
Returns the index for a child under a given.
std::string SerializeToXML(vtkIndent indent) const
Saves the data-assembly as a XML.
void SubsetCopy(vtkDataAssembly *other, const std::vector< int > &selected_branches)
Create a deep-copy of other by only passing the chosen branches.
const char * GetRootNodeName() const
Get/Set root node name.
int AddNode(const char *name, int parent=0)
Adds a node to the assembly with the given name and returns its id.
bool AddDataSetIndices(int id, const std::vector< unsigned int > &dataset_indices)
Same as AddDataSetIndex except supports adding multiple dataset indices in one go.
std::vector< unsigned int > GetDataSetIndices(const std::vector< int > &ids, bool traverse_subtree=true, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
Returns the dataset indices associated with the node.
bool GetAttribute(int id, const char *name, unsigned int &value) const
Get an attribute value.
void SetAttribute(int id, const char *name, int value)
Set an attribute.
void SetNodeName(int id, const char *name)
Get/Set a node's name.
int GetFirstNodeByPath(const char *path) const
Return a node id given the path.
void Visit(vtkDataAssemblyVisitor *visitor, int traversal_order=vtkDataAssembly::TraversalOrder::DepthFirst) const
Visit each node in the assembly for processing.
const char * GetAttributeOrDefault(int id, const char *name, const char *default_value) const
Get an attribute value.
bool HasAttribute(int id, const char *name) const
Returns true if attribute with the given name is present on the chosen node.
bool RemapDataSetIndices(const std::map< unsigned int, unsigned int > &mapping, bool remove_unmapped)
Remap dataset indices.
void Initialize()
Initializes the data-assembly.
int GetAttributeOrDefault(int id, const char *name, int default_value) const
Get an attribute value.
void SetRootNodeName(const char *name)
Get/Set root node name.
int AddSubtree(int parent, vtkDataAssembly *other, int otherParent=0)
Add a subtree by copy the nodes from another tree starting with the specified parent index.
bool RemoveDataSetIndex(int id, unsigned int dataset_index)
Removes a dataset index from a node.
int GetChild(int parent, int index) const
Returns the id for a child not at the given index, if valid, otherwise -1.
std::vector< int > AddNodes(const std::vector< std::string > &names, int parent=0)
Same as AddNode except allows adding multiple nodes in one go.
static bool IsNodeNameReserved(const char *name)
Returns true for node names that are reserved.
bool RemoveAllDataSetIndices(int id, bool traverse_subtree=true)
Clears all dataset indices from the node.
void SetAttribute(int id, const char *name, const char *value)
Set an attribute.
bool RemoveNode(int id)
Removes a node from the assembly.
unsigned int GetAttributeOrDefault(int id, const char *name, unsigned int default_value) const
Get an attribute value.
std::string GetNodePath(int id) const
Returns the path for a node.
a simple class to control print indentation
abstract base class for most VTK objects