Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OSCAR::Node Class Reference
[ObstacleAvoidance]

A Node a tree modeling structure containing instances of the primitives and child nodes, as well as methods to update the locations of the Node and the modeling objects contained within this Node and its children. Basically, a Node has a list of Node's inside it. This list of nodes constitutes its children. A Node also has a list of Primitive's in it. This list of Primitives constitutes the obstacles associated with just itself. More...

#include <Node.hpp>

Inheritance diagram for OSCAR::Node:

Inheritance graph
[legend]
List of all members.

Public Methods

 Node (const Xform &local=Xform(), const String &name=String(), OSCARError &err=DUMMY_ERROR(noError))
 Node (const Node &rhs)
Node & operator= (const Node &rhs)
virtual ~Node ()
Node * GetParent () const
const NodeListGetChildren () const
NodeListGetChildren ()
const PrimitiveListGetPrimitives () const
PrimitiveListGetPrimitives ()
bool Add (Node *node)
bool Remove (Node *node)
bool Add (const Primitive *primitive)
bool Remove (Primitive *primitive)
bool Move (Node *from, Node *node)
bool Move (Node &from, Primitive *primitive)
const XformGetLocalXform () const
Xform GetLocalXform ()
const XformGetGlobalXform () const
Xform GetGlobalXform ()
bool IsRoot () const
unsigned int NumChildren (bool thisNodeOnly=false) const
unsigned int NumPrimitives (bool thisNodeOnly=false) const
bool Update (const Xform &transform)

Protected Methods

bool deallocate ()
bool update ()

Protected Attributes

Xform toParent
Xform toGlobal
Node * parent
NodeList children
PrimitiveList primitives

Detailed Description

Author:
Chalongrath Pholsiri and Andrew Spencer


Constructor & Destructor Documentation

OSCAR::Node::Node const Xform   local = Xform(),
const String   name = String(),
OSCARError   err = DUMMY_ERROR(noError)
 

Contructor.

Construct a node from the Xform that gives the nodes local transformation from its parent node, w.r.t. the parents local frame. The constructed node, if not meant to be a root node, should then be added to its parent by the Add method called from the parent node.

Parameters:
local The local transformation matrix from the nodes parent node w.r.t. the parent node's local frame. Default to identity.
name An String that specifies the name of the Base object being created. The default is an empty String.
err A reference to an object of type OSCARError. The default OSCARError object holds values that imply a "No Error" state.

OSCAR::Node::Node const Node &    rhs
 

Copy Constructor. This will copy all the contents (including all the child nodes and primitives) of rhs to the newly-constructed (or this) node. The parent of this node will be the same as the parent of rhs but this node will NOT be added the parent's children node list. The user must explicitly add this node to a parent node and may also have to change the name of this node by calling SetName() because the ModelingObjectMap requires that each node has a unique name.

Parameters:
rhs The node to be copied from.

virtual OSCAR::Node::~Node   [virtual]
 

Destructor.


Member Function Documentation

bool OSCAR::Node::Add const Primitive   primitive
 

Add a primitive to this node. This adds a primitive to the end of the primitive list contained within this Node. This function will COPY the primitive and add the copy to this node. Also, the primitive will be updated using the global transformation of this node.

Parameters:
primitive A pointer to Primitive to be added.

bool OSCAR::Node::Add Node *    node
 

Add a child node to this node. This adds a node to the end of the node list contained within this Node. It does this by swapping the contents of the argument into the calling object. This basically renders the node and primitive lists inside the argument object as empty lists. Also, the newly-added node will be updated using the global transformation of this node.

Parameters:
node A pointer to Node to be added. It's important to note that after this function returns, the argument primitive and node lists will be empty as their contents will have been swapped to the calling object newly added child. Swapping occurs to prevent copying large amounts of data.

bool OSCAR::Node::deallocate   [protected]
 

NodeList& OSCAR::Node::GetChildren  
 

Get all the child nodes. CAUTION: This method may be removed later when a procedure of accessing specific nodes using maps is implemented.

Returns:
A reference of the children list.

const NodeList& OSCAR::Node::GetChildren   const
 

Get const reference to all the children.

Returns:
A reference of the children list.

Xform OSCAR::Node::GetGlobalXform  
 

Get the global transformation matrix for this node. The global transformation matrix is a transformation of this node relative to the world frame.

Returns:
The global tranformation matrix.

const Xform& OSCAR::Node::GetGlobalXform   const
 

Get the global transformation matrix for this node. The global transformation matrix is a transformation of this node relative to the world frame.

Returns:
The global tranformation matrix.

Xform OSCAR::Node::GetLocalXform  
 

Get the local transformation matrix for this node. The local transformation matrix is a transformation of this node relative to its parent. The transformation is w.r.t. the local frame of the parent node.

Returns:
The local tranformation matrix.

const Xform& OSCAR::Node::GetLocalXform   const
 

Get the local transformation matrix for this node. The local transformation matrix is a transformation of this node relative to its parent. The transformation is w.r.t. the local frame of the parent node.

Returns:
The local tranformation matrix.

Node* OSCAR::Node::GetParent   const
 

Get the parent node.

Returns:
A pointer to the parent node.

PrimitiveList& OSCAR::Node::GetPrimitives  
 

Get all the primitives. CAUTION: This method may be removed later when a procedure of accessing specific primitives using maps is implemented.

Returns:
A reference of the primitive list.

const PrimitiveList& OSCAR::Node::GetPrimitives   const
 

Get const reference to all the primitives.

Returns:
A reference of the primitive list.

bool OSCAR::Node::IsRoot   const
 

Return whether or not this node is a root node.

Returns:
true if this node is a root node or false otherwise.

bool OSCAR::Node::Move Node &    from,
Primitive   primitive
 

Move a primitive from another node to this node. This will move the argument primitive without any copying. The moved node will point to the same address as before. However, the primitive will be updated using the global transformation of this node.

Parameters:
from The node from which a child node is moved.
primitive A pointer to Primitive to be moved.

bool OSCAR::Node::Move Node *    from,
Node *    node
 

Move a child node from another node to this node. This will move the argument node without any copying. The moved node will point to the same address as before. However, its child nodes and primitives will be updated using the global transformation of this node.

Parameters:
from The node from which a child node is moved. NULL if the node has no parent (IE it is the root node). If this is the case then nothing will be done regarding the deletion of this node from its original source, and that task is left to the user.
node A pointer to Node to be moved.

unsigned int OSCAR::Node::NumChildren bool    thisNodeOnly = false const
 

The number of child nodes under this node.

Parameters:
thisNodeOnly If true, then this method only returns the number of child nodes of this only. If false, it then returns the total number of child nodes under this node including child nodes of its children.

unsigned int OSCAR::Node::NumPrimitives bool    thisNodeOnly = false const
 

The number of primitives under this node.

Parameters:
thisNodeOnly If true, then this method only returns the number of primitives of this only. If false, it then returns the total number of primitives under this node including primitives of its children.

Node& OSCAR::Node::operator= const Node &    rhs
 

Assignement operator. This will copy all the contents (including all the child nodes and primitives) of rhs to this node. The parent of this node will be the same as the parent of rhs but this node will NOT be added the parent's children node list. The user must explicitly add this node to a parent node and may also have to change the name of this node by calling SetName() because the ModelingObjectMap requires that each node has a unique name.

Parameters:
rhs The node to be copied from.

bool OSCAR::Node::Remove Primitive   primitive
 

Remove a primitive from this node. IMPORTANT: Use with caution. Remove will destroy the primitive in the argument. Do not use Remove and Add methods to move primitive. Use Move method instead.

Parameters:
primitive A pointer to Primitive to be removed.

bool OSCAR::Node::Remove Node *    node
 

Remove a child node from this node. IMPORTANT: Use with caution. Remove will destroy the node in the argument. Do not use Remove and Add methods to move node. Use Move method instead.

Parameters:
node A pointer to Node to be removed.

bool OSCAR::Node::update   [protected]
 

Update the global transformation of this node, its child nodes, and its primitives.

bool OSCAR::Node::Update const Xform   transform [virtual]
 

Update the locations of all the child nodes and primitives.

Parameters:
transform The transformation matrix used to update the locations with respect to the parent or the world frame if this is a root node. This call will also update the transformations of this node's child nodes and primitives.
Returns:
true if updated successfully (i.e. if this node is a root node) or false otherwise.

Reimplemented from OSCAR::ModelingObject.


Member Data Documentation

NodeList OSCAR::Node::children [protected]
 

Node* OSCAR::Node::parent [protected]
 

PrimitiveList OSCAR::Node::primitives [protected]
 

Xform OSCAR::Node::toGlobal [protected]
 

Xform OSCAR::Node::toParent [protected]
 


The documentation for this class was generated from the following file:
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations