# osg::Group Class Reference

General group node which maintains a list of children. More...

Inheritance diagram for osg::Group:

[legend]
List of all members.

## Public Member Functions

| Group ()
| Group (const Group &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
| Copy constructor using CopyOp to manage deep vs shallow copy.
| META_Node (osg, Group)
virtual Group * | asGroup ()
| convert 'this' into a Group pointer if Node is a Group, otherwise return 0.
virtual const Group * | asGroup () const
| convert 'const this' into a const Group pointer if Node is a Group, otherwise return 0.
virtual void | traverse (NodeVisitor &nv)
| Traverse downwards : calls children's accept method with NodeVisitor.
virtual bool | addChild (Node *child)
| Add Node to Group.
virtual bool | insertChild (unsigned int index, Node *child)
| Insert Node to Group at specific location.
virtual bool | removeChild (Node *child)
| Remove Node from Group.
virtual bool | removeChild (unsigned int pos, unsigned int numChildrenToRemove=1)
virtual bool | replaceChild (Node *origChild, Node *newChild)
| Replace specified Node with another Node.
unsigned int | getNumChildren () const
| Return the number of chilren nodes.
virtual bool | setChild (unsigned int i, Node *node)
| Set child node at position i.
Node * | getChild (unsigned int i)
| Return child node at position i.
const Node * | getChild (unsigned int i) const
| Return child node at position i.
bool | containsNode (const Node *node) const
| Return true if node is contained within Group.
unsigned int | getChildIndex (const Node *node) const
| Get the index number of child, return a value between 0 and _children.size()-1 if found, if not found then return _children.size().

## Protected Member Functions

virtual | ~Group ()
virtual bool | computeBound () const
| Compute the bounding sphere around Node's geometry or children.
virtual void | childRemoved (unsigned int, unsigned int)
virtual void | childInserted (unsigned int)

## Protected Attributes

NodeList | _children

## Detailed Description

General group node which maintains a list of children.

Children are reference counted. This allows children to be shared with memory management handled automatically via osg::Referenced.

## Constructor & Destructor Documentation

Group::Group | ( |  | ) |

Group::Group | ( | const Group & | ,
|  | const CopyOp & | copyop = `CopyOp::SHALLOW_COPY`
| ) |

| Copy constructor using CopyOp to manage deep vs shallow copy.

Group::~Group | ( |  | ) | `[protected, virtual]`

## Member Function Documentation

bool Group::addChild | ( | Node * | child | ) | `[virtual]`

| Add Node to Group. If node is not NULL and is not contained in Group then increment its reference count, add it to the child list and dirty the bounding sphere to force it to recompute on next getBound() and return true for success. Otherwise return false. Scene nodes can't be added as child nodes. Reimplemented in osg::LOD, osg::PagedLOD, and osg::Switch.

virtual const Group* osg::Group::asGroup | ( |  | ) | const`[inline, virtual]`

| convert 'const this' into a const Group pointer if Node is a Group, otherwise return 0. Equivalent to dynamic_cast<const Group*>(this). Reimplemented from osg::Node.

virtual Group* osg::Group::asGroup | ( |  | ) | `[inline, virtual]`

| convert 'this' into a Group pointer if Node is a Group, otherwise return 0. Equivalent to dynamic_cast<Group*>(this). Reimplemented from osg::Node.

virtual void osg::Group::childInserted | ( | unsigned | int | ) | `[inline, protected, virtual]`

| Reimplemented in osg::LOD, and osg::PagedLOD.

virtual void osg::Group::childRemoved | ( | unsigned | int,
|  | unsigned | int
| ) | `[inline, protected, virtual]`

| Reimplemented in osg::LOD, and osg::PagedLOD.

bool Group::computeBound | ( |  | ) | const`[protected, virtual]`

| Compute the bounding sphere around Node's geometry or children. This method is automatically called by getBound() when the bounding sphere has been marked dirty via dirtyBound(). Reimplemented from osg::Node. Reimplemented in osg::ClipNode, osg::Impostor, osg::LightSource, osg::LOD, osg::OccluderNode, and osg::Transform.

bool osg::Group::containsNode | ( | const Node * | node | ) | const`[inline]`

| Return true if node is contained within Group.

const Node* osg::Group::getChild | ( | unsigned int | i | ) | const`[inline]`

| Return child node at position i.

Node* osg::Group::getChild | ( | unsigned int | i | ) | `[inline]`

| Return child node at position i.

unsigned int osg::Group::getChildIndex | ( | const Node * | node | ) | const`[inline]`

| Get the index number of child, return a value between 0 and _children.size()-1 if found, if not found then return _children.size().

unsigned int osg::Group::getNumChildren | ( |  | ) | const`[inline]`

| Return the number of chilren nodes.

bool Group::insertChild | ( | unsigned int | index,
|  | Node * | child
| ) | `[virtual]`

| Insert Node to Group at specific location. The new child node is inserted into the child list before the node at the specified index. No nodes are removed from the group with this operation. Reimplemented in osg::Switch.

osg::Group::META_Node | ( | osg | ,
|  | Group |
| ) |

bool Group::removeChild | ( | unsigned int | pos,
|  | unsigned int | numChildrenToRemove = `1`
| ) | `[virtual]`

bool Group::removeChild | ( | Node * | child | ) | `[virtual]`

| Remove Node from Group. If Node is contained in Group then remove it from the child list, decrement its reference count, and dirty the bounding sphere to force it to recompute on next getBound() and return true for success. If Node is not found then return false and do not change the reference count of the Node. Reimplemented in osg::LOD, osg::PagedLOD, and osg::Switch.

bool Group::replaceChild | ( | Node * | origChild,
|  | Node * | newChild
| ) | `[virtual]`

| Replace specified Node with another Node. Equivalent to setChild(getChildIndex(orignChild),node) See docs for setChild for futher details on implementation.

bool Group::setChild | ( | unsigned int | i,
|  | Node * | node
| ) | `[virtual]`

Set child node at position i.

Return true if set correctly, false on failure (if node==NULL || i is out of range). When Set can be successful applied, the algorithm is : decrement the reference count origNode and increment the reference count of newNode, and dirty the bounding sphere to force it to recompute on next getBound() and return true. If origNode is not found then return false and do not add newNode. If newNode is NULL then return false and do not remove origNode. Also returns false if newChild is a Scene node.

void Group::traverse | ( | NodeVisitor & | nv | ) | `[virtual]`

| Traverse downwards : calls children's accept method with NodeVisitor. Reimplemented from osg::Node. Reimplemented in osg::LOD, osg::PagedLOD, osg::Sequence, and osg::Switch.

## Member Data Documentation

NodeList osg::Group::_children `[protected]`

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

- Group
- Group.cpp