ITK  5.2.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  * http://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 
23 namespace itk
24 {
25 
26 // Forward reference because of circular dependencies
27 class ITK_FORWARD_EXPORT OctreeNodeBranch;
28 class ITK_FORWARD_EXPORT OctreeBase;
29 
46 class ITKCommon_EXPORT OctreeNode
47 {
48 public:
49 
55  OctreeNode();
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 
83  OctreeNode &
84  GetChild(const LeafIdentifierEnum ChildID) const;
85 
86  OctreeNode &
87  GetChild(const LeafIdentifierEnum ChildID);
97  long int
98  GetColor() const;
99 
106  void
107  SetColor(int NodeColor);
108 
114  void
115  SetBranch(OctreeNodeBranch * NewBranch);
116 
121  bool
122  IsNodeColored() const;
123 
124  inline void
125  SetParentOctree(OctreeBase * parent)
126  {
127  m_Parent = parent;
128  }
129 
130 protected:
131 private:
136  void
137  RemoveChildren();
138 
142  OctreeNodeBranch * m_Branch;
143  OctreeBase * m_Parent;
144 };
145 
146 class ITKCommon_EXPORT OctreeNodeBranch
147 {
148 public:
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 
164 private:
165  OctreeNode m_Leaves[8];
166 };
167 
168 } // namespace itk
169 #endif /* itkOctreeNode_h */
itk::OctreeNodeBranch::OctreeNodeBranch
OctreeNodeBranch(OctreeBase *parent)
Definition: itkOctreeNode.h:150
itk::OctreeNodeBranch::GetLeaf
OctreeNode * GetLeaf(OctreeNode::LeafIdentifierEnum LeafID)
Definition: itkOctreeNode.h:159
itk::OctreeEnums::LeafIdentifier
LeafIdentifier
Definition: itkCommonEnums.h:230
itk::OctreeNodeBranch
class ITK_FORWARD_EXPORT OctreeNodeBranch
Definition: itkOctreeNode.h:27
itk::OctreeBase
Provides non-templated access to templated instances of Octree.
Definition: itkOctree.h:40
itk::OctreeNodeBranch
Definition: itkOctreeNode.h:146
itkMacro.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkCommonEnums.h
itk::OctreeNode
A data structure representing a node in an Octree.
Definition: itkOctreeNode.h:46