ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkOctreeNode_h 00019 #define __itkOctreeNode_h 00020 #include "itkMacro.h" 00021 namespace itk 00022 { 00023 enum LeafIdentifier { ZERO = 0, ONE = 1, TWO = 2, THREE = 3, FOUR = 4, FIVE = 5, SIX = 6, SEVEN = 7 }; 00024 00025 //A forward-declaration 00026 class OctreeNodeBranch; 00027 class OctreeBase; 00028 00043 class ITKCommon_EXPORT OctreeNode 00044 { 00045 public: 00046 00052 OctreeNode(void); 00053 00057 virtual ~OctreeNode(void); 00058 00066 OctreeNode & GetChild(const enum LeafIdentifier ChildID) const; 00067 00068 OctreeNode & GetChild(const enum LeafIdentifier ChildID); 00069 00078 int GetColor(void) const; 00079 00086 void SetColor(int NodeColor); 00087 00093 void SetBranch(OctreeNodeBranch *NewBranch); 00094 00099 bool IsNodeColored(void) const; 00100 00101 inline void SetParentOctree(OctreeBase *parent) 00102 { 00103 m_Parent = parent; 00104 } 00105 00106 protected: 00107 private: 00112 void RemoveChildren(void); 00113 00117 OctreeNodeBranch *m_Branch; 00118 OctreeBase * m_Parent; 00119 }; 00120 00121 class OctreeNodeBranch 00122 { 00123 public: 00124 OctreeNodeBranch(OctreeBase *parent) 00125 { 00126 for ( int i = 0; i < 8; i++ ) 00127 { 00128 m_Leaves[i].SetParentOctree(parent); 00129 } 00130 } 00131 00132 inline OctreeNode * GetLeaf(enum LeafIdentifier LeafID) 00133 { 00134 return &m_Leaves[LeafID]; 00135 } 00136 00137 private: 00138 OctreeNode m_Leaves[8]; 00139 }; 00140 } //End of itk Namespace 00141 #endif /* __itkOctreeNode_h */ 00142