ITK  4.13.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"
26 namespace itk
27 {
28 enum {
32  };
33 
38 
46  };
47 
54 class ITKCommon_EXPORT OctreeBase:public Object
55 {
56 public:
57 
59  typedef OctreeBase Self;
61 
66  virtual OctreeNode * GetTree() = 0;
67 
72  virtual unsigned int GetDepth() = 0;
73 
79  virtual unsigned int GetWidth() = 0;
80 
82  virtual void SetDepth(unsigned int depth) = 0;
83 
85  virtual void SetWidth(unsigned int width) = 0;
86 
92  virtual void BuildFromBuffer(const void *buffer,
93  const unsigned int xsize, const unsigned int ysize, const unsigned int zsize) = 0;
94 
105  virtual const OctreeNodeBranch * GetColorTable() const = 0;
106 
108  virtual int GetColorTableSize() const = 0;
109 };
110 
119 template< typename TPixel, unsigned int ColorTableSize, typename MappingFunctionType >
120 class ITK_TEMPLATE_EXPORT Octree:public OctreeBase
121 {
122 public:
123 
125  typedef Octree Self;
130 
132  itkNewMacro(Self);
133 
135  itkTypeMacro(Octree, Superclass);
136 
137  ImageTypePointer GetImage();
138 
139  virtual void BuildFromBuffer(const void *buffer, const unsigned int xsize, const unsigned int ysize, const unsigned int zsize) ITK_OVERRIDE;
140 
141  void BuildFromImage(Image< TPixel, 3 > *fromImage);
142 
143  Octree();
144  ~Octree() ITK_OVERRIDE;
145  void SetColor(unsigned int color) { m_Tree.SetColor(color); }
146  void SetTree(OctreeNodeBranch *branch) { m_Tree.SetBranch(branch); }
147  void SetTrueDims(const unsigned int Dim0, const unsigned int Dim1,
148  const unsigned int Dim2);
149 
150  int GetValue(const unsigned int Dim0, const unsigned int Dim1,
151  const unsigned int Dim2);
152 
153  virtual void SetWidth(unsigned int width) ITK_OVERRIDE;
154 
155  virtual void SetDepth(unsigned int depth) ITK_OVERRIDE;
156 
157  virtual unsigned int GetWidth() ITK_OVERRIDE;
158 
159  virtual unsigned int GetDepth() ITK_OVERRIDE;
160 
161  virtual OctreeNode * GetTree() ITK_OVERRIDE;
162 
163  virtual const OctreeNodeBranch * GetColorTable() const ITK_OVERRIDE;
164 
165  virtual int GetColorTableSize() const ITK_OVERRIDE;
166 
167 private:
168  ITK_DISALLOW_COPY_AND_ASSIGN(Octree);
169 
170  OctreeNodeBranch * maskToOctree(const TPixel *Mask, unsigned width, unsigned x,
171  unsigned y, unsigned z, unsigned xsize,
172  unsigned ysize, unsigned zsize);
173 
174  enum OctreePlaneType m_Plane; // The orientation of the plane for this octree
175  unsigned int m_Width; // The width of the Octree
176  // ( This is always a power of 2, and large
177  // enough to contain MAX(DIMS[1,2,3]))
178  unsigned int m_Depth; // < The depth of the Octree
179  unsigned int m_TrueDims[3]; // The true dimensions of the image
180  OctreeNodeBranch m_ColorTable[ColorTableSize];
181  OctreeNode m_Tree;
182  // OctreeColorMapFunction m_ColorMapFunction;
183  MappingFunctionType m_MappingFunction;
184 };
185 }
186 
187 #ifndef ITK_MANUAL_INSTANTIATION
188 #include "itkOctree.hxx"
189 #endif
190 
191 #endif /* itkOctree_h */
Light weight base class for most itk classes.
Octree Self
Definition: itkOctree.h:125
Provides non-templated access to templated instances of Octree.
Definition: itkOctree.h:54
void SetColor(unsigned int color)
Definition: itkOctree.h:145
void SetTree(OctreeNodeBranch *branch)
Definition: itkOctree.h:146
Image< TPixel, 3 > ImageType
Definition: itkOctree.h:128
OctreeBase Self
Definition: itkOctree.h:59
OctreeBase Superclass
Definition: itkOctree.h:126
A data structure representing a node in an Octree.
Definition: itkOctreeNode.h:45
SmartPointer< Self > Pointer
Definition: itkOctree.h:127
Represent a 3D Image with an Octree data structure.
Definition: itkOctree.h:120
OctreePlaneType
Definition: itkOctree.h:37
ImageType::Pointer ImageTypePointer
Definition: itkOctree.h:129
Base class for most ITK classes.
Definition: itkObject.h:59
SmartPointer< Self > Pointer
Definition: itkOctree.h:60
Templated n-dimensional image class.
Definition: itkImage.h:75