ITK  6.0.0
Insight Toolkit
itkOctreeNode.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkOctreeNode_h
19#define itkOctreeNode_h
20#include "itkMacro.h"
21#include "itkCommonEnums.h"
22
23namespace itk
24{
25
26// Forward reference because of circular dependencies
27class ITK_FORWARD_EXPORT OctreeNodeBranch;
28class ITK_FORWARD_EXPORT OctreeBase;
29
46class ITKCommon_EXPORT OctreeNode
47{
48public:
49
56
60 virtual ~OctreeNode();
61
63#if !defined(ITK_LEGACY_REMOVE)
64 // We need to expose the enum values at the class level
65 // for backwards compatibility
66 static constexpr LeafIdentifierEnum ZERO = LeafIdentifierEnum::ZERO;
67 static constexpr LeafIdentifierEnum ONE = LeafIdentifierEnum::ONE;
68 static constexpr LeafIdentifierEnum TWO = LeafIdentifierEnum::TWO;
69 static constexpr LeafIdentifierEnum THREE = LeafIdentifierEnum::THREE;
70 static constexpr LeafIdentifierEnum FOUR = LeafIdentifierEnum::FOUR;
71 static constexpr LeafIdentifierEnum FIVE = LeafIdentifierEnum::FIVE;
72 static constexpr LeafIdentifierEnum SIX = LeafIdentifierEnum::SIX;
73 static constexpr LeafIdentifierEnum SEVEN = LeafIdentifierEnum::SEVEN;
74#endif
75
84 GetChild(const LeafIdentifierEnum ChildID) const;
85
97 long
98 GetColor() const;
99
106 void
107 SetColor(int color);
108
114 void
116
121 bool
123
124 inline void
126 {
127 m_Parent = parent;
128 }
129
130protected:
131private:
136 void
138
142 OctreeNodeBranch * m_Branch{};
143 OctreeBase * m_Parent{};
144};
145
146class ITKCommon_EXPORT OctreeNodeBranch
147{
148public:
149 OctreeNodeBranch() = default;
151 {
152 for (auto & leaf : m_Leaves)
153 {
154 leaf.SetParentOctree(parent);
155 }
156 }
157
158 inline OctreeNode *
160 {
161 return &m_Leaves[static_cast<uint8_t>(LeafID)];
162 }
163
164private:
165 OctreeNode m_Leaves[8];
166};
167
168} // namespace itk
169#endif /* itkOctreeNode_h */
Provides non-templated access to templated instances of Octree.
Definition: itkOctree.h:41
OctreeNode * GetLeaf(OctreeNode::LeafIdentifierEnum LeafID)
OctreeNodeBranch(OctreeBase *parent)
OctreeNodeBranch()=default
A data structure representing a node in an Octree.
Definition: itkOctreeNode.h:47
void SetColor(int color)
virtual ~OctreeNode()
void SetParentOctree(OctreeBase *parent)
void SetBranch(OctreeNodeBranch *NewBranch)
void RemoveChildren()
bool IsNodeColored() const
OctreeNode & GetChild(const LeafIdentifierEnum ChildID) const
long GetColor() const
OctreeNode & GetChild(const LeafIdentifierEnum ChildID)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....