2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* ***** END GPL LICENSE BLOCK *****
21
/** \file blender/freestyle/intern/scene_graph/NodeGroup.cpp
23
* \brief Class to represent a group node. This node can contains several children.
24
* \brief It also contains a transform matrix indicating the transform state of the underlying children.
25
* \author Stephane Grabli
29
#include "NodeGroup.h"
33
void NodeGroup::AddChild(Node *iChild)
38
_Children.push_back(iChild);
42
int NodeGroup::destroy()
44
/*! Node::destroy makes a release on the object and then returns the reference counter.
45
* If the reference counter is equal to 0, that means that nobody else is linking this node group and
46
* that we can destroy the whole underlying tree.
47
* Else, one or several Node link this node group, and we only returns the reference counter
48
* decremented by Node::destroy();
50
int refThis = Node::destroy();
52
// if refThis != 0, we can't destroy the tree
56
// If we are here, that means that nobody else needs our NodeGroup and we can destroy it.
58
vector<Node *>::iterator node;
60
for (node = _Children.begin(); node != _Children.end(); ++node) {
61
refCount = (*node)->destroy();
71
void NodeGroup::accept(SceneVisitor& v)
73
v.visitNodeGroup(*this);
75
v.visitNodeGroupBefore(*this);
76
for (vector<Node *>::iterator node = _Children.begin(), end = _Children.end(); node != end; ++node)
78
v.visitNodeGroupAfter(*this);
81
void NodeGroup::DetachChildren()
83
vector<Node *>::iterator node;
85
for (node = _Children.begin(); node != _Children.end(); ++node) {
92
void NodeGroup::DetachChild(Node *iChild)
94
/* int found = 0; */ /* UNUSED */
95
vector<Node*>::iterator node;
97
for (node = _Children.begin(); node != _Children.end(); ++node) {
98
if ((*node) == iChild) {
100
_Children.erase(node);
101
/* found = 1; */ /* UNUSED */
107
void NodeGroup::RetrieveChildren(vector<Node*>& oNodes)
112
const BBox<Vec3r>& NodeGroup::UpdateBBox()
114
vector<Node *>::iterator node;
116
for (node = _Children.begin(); node != _Children.end(); ++node) {
117
AddBBox((*node)->UpdateBBox());
120
return Node::UpdateBBox();
123
} /* namespace Freestyle */