pub struct Tree { /* private fields */ }tree only.Expand description
FBX data tree.
§Tree manipulation methods
You can use the methods below to access and/or modify the tree.
- Access
- Create nodes / modify tree
- Modify node
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn root(&self) -> NodeHandle<'_>
pub fn root(&self) -> NodeHandle<'_>
Returns the root node.
Sourcepub fn create_node(&mut self, name: &str) -> NodeId
pub fn create_node(&mut self, name: &str) -> NodeId
Creates an orphan node in the arena.
The created node can be inserted nearby some other nodes (in the same arena) later.
Sourcepub fn append(&mut self, new_last_child: NodeId, parent: NodeId)
pub fn append(&mut self, new_last_child: NodeId, parent: NodeId)
Detaches the node and appends it to the given parent node.
§Panics
Panics if:
- any of the given node IDs are not used in the tree,
- the
new_last_childisparent, or - the
new_last_childis an ancestor ofparent.
Sourcepub fn prepend(&mut self, new_first_child: NodeId, parent: NodeId)
pub fn prepend(&mut self, new_first_child: NodeId, parent: NodeId)
Detaches the node and prepends it to the given parent node.
§Panics
Panics if:
- any of the given node IDs are not used in the tree,
- the
new_first_childisparent, or - the
new_first_childis an ancestor ofparent.
Sourcepub fn insert_after(&mut self, new_next_sibling: NodeId, prev_sibling: NodeId)
pub fn insert_after(&mut self, new_next_sibling: NodeId, prev_sibling: NodeId)
Detaches the node and inserts it after the given base node.
§Panics
Panics if:
- any of the given node IDs are not used in the tree,
- the
new_next_siblingisprev_sibling.
Sourcepub fn insert_before(&mut self, new_prev_sibling: NodeId, next_sibling: NodeId)
pub fn insert_before(&mut self, new_prev_sibling: NodeId, next_sibling: NodeId)
Detaches the node and inserts it after the given base node.
§Panics
Panics if:
- any of the given node IDs are not used in the tree,
- the
new_prev_siblingisnext_sibling.
Sourcepub fn append_new(&mut self, parent: NodeId, name: &str) -> NodeId
pub fn append_new(&mut self, parent: NodeId, name: &str) -> NodeId
Creates a new node and appends to the given parent node.
§Panics
Panics if the given node ID is not used in the tree.
Sourcepub fn prepend_new(&mut self, parent: NodeId, name: &str) -> NodeId
pub fn prepend_new(&mut self, parent: NodeId, name: &str) -> NodeId
Creates a new node and prepends to the given parent node.
§Panics
Panics if the given node ID is not used in the tree.
Sourcepub fn insert_new_after(&mut self, sibling: NodeId, name: &str) -> NodeId
pub fn insert_new_after(&mut self, sibling: NodeId, name: &str) -> NodeId
Creates a new node and inserts after the given sibling node.
§Panics
Panics if the given node ID is invalid (i.e. not used or root node).
Sourcepub fn insert_new_before(&mut self, sibling: NodeId, name: &str) -> NodeId
pub fn insert_new_before(&mut self, sibling: NodeId, name: &str) -> NodeId
Creates a new node and inserts before the given sibling node.
§Panics
Panics if the given node ID is invalid (i.e. not used or root node).
Sourcepub fn detach(&mut self, subtree_root: NodeId)
pub fn detach(&mut self, subtree_root: NodeId)
Detaches the subtree from the tree.
If the subtree is the root node, does nothing.
The detached node and its descendants are kept in the arena, so they can be inserted nearby some other nodes (in the same arena) later.
Sourcepub fn append_attribute(
&mut self,
node_id: NodeId,
v: impl Into<AttributeValue>,
)
pub fn append_attribute( &mut self, node_id: NodeId, v: impl Into<AttributeValue>, )
Creates a new node and inserts before the given sibling node.
§Panics
Panics if the given node ID is invalid (i.e. not used or root node).
Sourcepub fn get_attribute_mut(
&mut self,
node_id: NodeId,
i: usize,
) -> Option<&mut AttributeValue>
pub fn get_attribute_mut( &mut self, node_id: NodeId, i: usize, ) -> Option<&mut AttributeValue>
Returns a mutable reference to the node attribute at the given index.
§Panics
Panics if the given node ID is invalid (i.e. not used or root node).
Sourcepub fn take_attributes_vec(&mut self, node_id: NodeId) -> Vec<AttributeValue>
pub fn take_attributes_vec(&mut self, node_id: NodeId) -> Vec<AttributeValue>
Takes all attributes as a Vec.
After calling this, the node will have no attributes (until other values are set).
§Panics
Panics if the given node ID is invalid (i.e. not used or root node).
Sourcepub fn set_attributes_vec(&mut self, node_id: NodeId, new: Vec<AttributeValue>)
pub fn set_attributes_vec(&mut self, node_id: NodeId, new: Vec<AttributeValue>)
Sets the given Vec of attribute values as the node attributes.
After calling this, the node will have only the given attributes.
§Panics
Panics if the given node ID is invalid (i.e. not used or root node).
Sourcepub fn strict_eq(&self, other: &Self) -> bool
pub fn strict_eq(&self, other: &Self) -> bool
Compares trees strictly.
Returns true if the two trees are same.
Note that f32 and f64 values are compared bitwise.
Note that this method compares tree data, not internal states of the objects.
Sourcepub fn debug_tree(&self) -> impl Debug + '_
pub fn debug_tree(&self) -> impl Debug + '_
Pretty-print the tree for debugging purpose.
Be careful, this output format may change in future.