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