~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/freestyle/intern/scene_graph/NodeGroup.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 *
 
18
 * ***** END GPL LICENSE BLOCK *****
 
19
 */
 
20
 
 
21
/** \file blender/freestyle/intern/scene_graph/NodeGroup.cpp
 
22
 *  \ingroup freestyle
 
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
 
26
 *  \date 24/01/2002
 
27
 */
 
28
 
 
29
#include "NodeGroup.h"
 
30
 
 
31
namespace Freestyle {
 
32
 
 
33
void NodeGroup::AddChild(Node *iChild)
 
34
{
 
35
        if (NULL == iChild)
 
36
                return;
 
37
 
 
38
        _Children.push_back(iChild);
 
39
        iChild->addRef();
 
40
}
 
41
 
 
42
int NodeGroup::destroy()
 
43
{
 
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();
 
49
         */
 
50
        int refThis = Node::destroy();
 
51
 
 
52
        // if refThis != 0, we can't destroy the tree
 
53
        if (0 != refThis)
 
54
                return refThis;
 
55
 
 
56
        // If we are here, that means that nobody else needs our NodeGroup and we can destroy it.
 
57
        int refCount = 0;
 
58
        vector<Node *>::iterator node;
 
59
 
 
60
        for (node = _Children.begin(); node != _Children.end(); ++node) {
 
61
                refCount = (*node)->destroy();
 
62
                if (0 == refCount)
 
63
                        delete (*node);
 
64
        }
 
65
 
 
66
        _Children.clear();
 
67
 
 
68
        return refThis;
 
69
}
 
70
 
 
71
void NodeGroup::accept(SceneVisitor& v)
 
72
{
 
73
        v.visitNodeGroup(*this);
 
74
 
 
75
        v.visitNodeGroupBefore(*this);
 
76
        for (vector<Node *>::iterator node = _Children.begin(), end = _Children.end(); node != end; ++node)
 
77
                (*node)->accept(v);
 
78
        v.visitNodeGroupAfter(*this);
 
79
}
 
80
 
 
81
void NodeGroup::DetachChildren()
 
82
{
 
83
        vector<Node *>::iterator node;
 
84
 
 
85
        for (node = _Children.begin(); node != _Children.end(); ++node) {
 
86
                (*node)->release();
 
87
        }
 
88
 
 
89
        _Children.clear();
 
90
}
 
91
 
 
92
void NodeGroup::DetachChild(Node *iChild)
 
93
{
 
94
        /* int found = 0; */ /* UNUSED */
 
95
        vector<Node*>::iterator node;
 
96
 
 
97
        for (node = _Children.begin(); node != _Children.end(); ++node) {
 
98
                if ((*node) == iChild) {
 
99
                        (*node)->release();
 
100
                        _Children.erase(node);
 
101
                        /* found = 1; */ /* UNUSED */
 
102
                        break;
 
103
                }
 
104
        }
 
105
}
 
106
 
 
107
void NodeGroup::RetrieveChildren(vector<Node*>& oNodes)
 
108
{
 
109
        oNodes = _Children;
 
110
}
 
111
 
 
112
const BBox<Vec3r>& NodeGroup::UpdateBBox()
 
113
{
 
114
        vector<Node *>::iterator node;
 
115
        clearBBox();
 
116
        for (node = _Children.begin(); node != _Children.end(); ++node) {
 
117
                AddBBox((*node)->UpdateBBox());
 
118
        }
 
119
 
 
120
        return Node::UpdateBBox();
 
121
}
 
122
 
 
123
} /* namespace Freestyle */