ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkOctree.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 itkOctree_h
19 #define itkOctree_h
20 
21 #include "itkOctreeNode.h"
22 #include "itkImage.h"
23 
24 namespace itk
25 {
26 enum {
30  };
31 
40  };
41 
48 class ITKCommon_EXPORT OctreeBase:public Object
49 {
50 public:
51 
53  using Self = OctreeBase;
55 
60  virtual OctreeNode * GetTree() = 0;
61 
66  virtual unsigned int GetDepth() = 0;
67 
73  virtual unsigned int GetWidth() = 0;
74 
76  virtual void SetDepth(unsigned int depth) = 0;
77 
79  virtual void SetWidth(unsigned int width) = 0;
80 
86  virtual void BuildFromBuffer(const void *buffer,
87  const unsigned int xsize, const unsigned int ysize, const unsigned int zsize) = 0;
88 
99  virtual const OctreeNodeBranch * GetColorTable() const = 0;
100 
102  virtual int GetColorTableSize() const = 0;
103 };
104 
113 template< typename TPixel, unsigned int ColorTableSize, typename MappingFunctionType >
114 class ITK_TEMPLATE_EXPORT Octree:public OctreeBase
115 {
116 public:
117  ITK_DISALLOW_COPY_AND_ASSIGN(Octree);
118 
120  using Self = Octree;
125 
127  itkNewMacro(Self);
128 
130  itkTypeMacro(Octree, Superclass);
131 
132  ImageTypePointer GetImage();
133 
134  void BuildFromBuffer(const void *buffer, const unsigned int xsize, const unsigned int ysize, const unsigned int zsize) override;
135 
136  void BuildFromImage(Image< TPixel, 3 > *fromImage);
137 
138  Octree();
139  ~Octree() override;
140  void SetColor(unsigned int color) { m_Tree.SetColor(color); }
141  void SetTree(OctreeNodeBranch *branch) { m_Tree.SetBranch(branch); }
142  void SetTrueDims(const unsigned int Dim0, const unsigned int Dim1,
143  const unsigned int Dim2);
144 
145  int GetValue(const unsigned int Dim0, const unsigned int Dim1,
146  const unsigned int Dim2);
147 
148  void SetWidth(unsigned int width) override;
149 
150  void SetDepth(unsigned int depth) override;
151 
152  unsigned int GetWidth() override;
153 
154  unsigned int GetDepth() override;
155 
156  OctreeNode * GetTree() override;
157 
158  const OctreeNodeBranch * GetColorTable() const override;
159 
160  int GetColorTableSize() const override;
161 
162 private:
163  OctreeNodeBranch * maskToOctree(const TPixel *Mask, unsigned width, unsigned x,
164  unsigned y, unsigned z, unsigned xsize,
165  unsigned ysize, unsigned zsize);
166 
167  OctreePlaneType m_Plane{UNKNOWN_PLANE}; // The orientation of the plane for this octree
168 
169  // The width of the Octree. This is always a power of 2,
170  // and large enough to contain MAX(DIMS[1,2,3])
171  unsigned int m_Width{0};
172 
173  unsigned int m_Depth{0}; // The depth of the Octree
174  unsigned int m_TrueDims[3]; // The true dimensions of the image
175  OctreeNodeBranch m_ColorTable[ColorTableSize];
177  MappingFunctionType m_MappingFunction;
178 };
179 }
180 
181 #ifndef ITK_MANUAL_INSTANTIATION
182 #include "itkOctree.hxx"
183 #endif
184 
185 #endif // itkOctree_h
The plane is Transverse.
Definition: itkOctree.h:39
Light weight base class for most itk classes.
The plane is Coronal.
Definition: itkOctree.h:38
Provides non-templated access to templated instances of Octree.
Definition: itkOctree.h:48
void SetColor(unsigned int color)
Definition: itkOctree.h:140
void SetTree(OctreeNodeBranch *branch)
Definition: itkOctree.h:141
OctreeNode m_Tree
Definition: itkOctree.h:176
A data structure representing a node in an Octree.
Definition: itkOctreeNode.h:45
MappingFunctionType m_MappingFunction
Definition: itkOctree.h:177
class ITK_FORWARD_EXPORT OctreeBase
Definition: itkOctreeNode.h:27
The plane is Unknown.
Definition: itkOctree.h:36
Represent a 3D Image with an Octree data structure.
Definition: itkOctree.h:114
OctreePlaneType
Definition: itkOctree.h:35
typename ImageType::Pointer ImageTypePointer
Definition: itkOctree.h:124
The plane is Sagital.
Definition: itkOctree.h:37
Base class for most ITK classes.
Definition: itkObject.h:60
Templated n-dimensional image class.
Definition: itkImage.h:75