Blender V4.3
NodeGroup.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12#include "NodeGroup.h"
13
14namespace Freestyle {
15
17{
18 if (nullptr == iChild) {
19 return;
20 }
21
22 _Children.push_back(iChild);
23 iChild->addRef();
24}
25
27{
33 int refThis = Node::destroy();
34
35 // if refThis != 0, we can't destroy the tree
36 if (0 != refThis) {
37 return refThis;
38 }
39
40 // If we are here, that means that nobody else needs our NodeGroup and we can destroy it.
41 int refCount = 0;
42 vector<Node *>::iterator node;
43
44 for (node = _Children.begin(); node != _Children.end(); ++node) {
45 refCount = (*node)->destroy();
46 if (0 == refCount) {
47 delete (*node);
48 }
49 }
50
51 _Children.clear();
52
53 return refThis;
54}
55
57{
58 v.visitNodeGroup(*this);
59
60 v.visitNodeGroupBefore(*this);
61 for (vector<Node *>::iterator node = _Children.begin(), end = _Children.end(); node != end;
62 ++node)
63 {
64 (*node)->accept(v);
65 }
66 v.visitNodeGroupAfter(*this);
67}
68
70{
71 vector<Node *>::iterator node;
72
73 for (node = _Children.begin(); node != _Children.end(); ++node) {
74 (*node)->release();
75 }
76
77 _Children.clear();
78}
79
81{
82 // int found = 0; /* UNUSED. */
83 vector<Node *>::iterator node;
84
85 for (node = _Children.begin(); node != _Children.end(); ++node) {
86 if ((*node) == iChild) {
87 (*node)->release();
88 _Children.erase(node);
89 // found = 1; /* UNUSED. */
90 break;
91 }
92 }
93}
94
95void NodeGroup::RetrieveChildren(vector<Node *> &oNodes)
96{
97 oNodes = _Children;
98}
99
101{
102 vector<Node *>::iterator node;
103 clearBBox();
104 for (node = _Children.begin(); node != _Children.end(); ++node) {
105 AddBBox((*node)->UpdateBBox());
106 }
107
108 return Node::UpdateBBox();
109}
110
111} /* namespace Freestyle */
Class to represent a group node. This node can contains several children.
ATTR_WARN_UNUSED_RESULT const BMVert * v
virtual int destroy()
Definition BaseObject.h:33
virtual void RetrieveChildren(vector< Node * > &oNodes)
Definition NodeGroup.cpp:95
virtual void DetachChildren()
Definition NodeGroup.cpp:69
virtual void AddChild(Node *iChild)
Definition NodeGroup.cpp:16
virtual const BBox< Vec3r > & UpdateBBox()
vector< Node * > _Children
Definition NodeGroup.h:62
virtual int destroy()
Definition NodeGroup.cpp:26
virtual void DetachChild(Node *iChild)
Definition NodeGroup.cpp:80
virtual void accept(SceneVisitor &v)
Definition NodeGroup.cpp:56
virtual void clearBBox()
Definition Node.h:84
virtual void AddBBox(const BBox< Vec3r > &iBox)
Definition Node.h:63
virtual const BBox< Vec3r > & UpdateBBox()
Definition Node.h:78
OperationNode * node
inherits from class Rep
Definition AppCanvas.cpp:20