ITK  4.6.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 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 char * GetColorTable() const = 0;
106 
108  virtual int GetColorTableSize() const = 0;
109 };
110 
119 template< typename TPixel, unsigned int ColorTableSize, typename MappingFunctionType >
120 class Octree:public OctreeBase
121 {
122 public:
123 
125  typedef Octree Self;
130 
132  itkNewMacro(Self);
133 
135  itkTypeMacro(Octree, Superclass);
136 
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(void);
144  ~Octree(void);
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 char * GetColorTable() const ITK_OVERRIDE;
164 
165  virtual int GetColorTableSize() const ITK_OVERRIDE;
166 
167 private:
168  Octree(const Self &); // purposely not implemented
169  void operator=(const Self &); // purposely not implemented
170 
171  OctreeNodeBranch * maskToOctree(const TPixel *Mask, unsigned width, unsigned x,
172  unsigned y, unsigned z, unsigned xsize,
173  unsigned ysize, unsigned zsize);
174 
175  enum OctreePlaneType m_Plane; // The orientation of the plane for this octree
176  unsigned int m_Width; // The width of the Octree
177  // ( This is always a power of 2, and large
178  // enough to contain MAX(DIMS[1,2,3]))
179  unsigned int m_Depth; // < The depth of the Octree
180  unsigned int m_TrueDims[3]; // The true dimensions of the image
181  char m_ColorTable[ColorTableSize];
183  // OctreeColorMapFunction m_ColorMapFunction;
184  MappingFunctionType m_MappingFunction;
185 };
186 }
187 
188 #ifndef ITK_MANUAL_INSTANTIATION
189 #include "itkOctree.hxx"
190 #endif
191 
192 #endif /* __itkOctree_h */
void SetColor(int NodeColor)
virtual int GetColorTableSize() const =0
virtual void BuildFromBuffer(const void *buffer, const unsigned int xsize, const unsigned int ysize, const unsigned int zsize) ITK_OVERRIDE
Light weight base class for most itk classes.
virtual unsigned int GetDepth()=0
void SetTrueDims(const unsigned int Dim0, const unsigned int Dim1, const unsigned int Dim2)
enum OctreePlaneType m_Plane
Definition: itkOctree.h:175
Octree Self
Definition: itkOctree.h:125
OctreeNodeBranch * maskToOctree(const TPixel *Mask, unsigned width, unsigned x, unsigned y, unsigned z, unsigned xsize, unsigned ysize, unsigned zsize)
virtual OctreeNode * GetTree() ITK_OVERRIDE
Provides non-templated access to templated instances of Octree.
Definition: itkOctree.h:54
virtual void SetWidth(unsigned int width)=0
virtual void BuildFromBuffer(const void *buffer, const unsigned int xsize, const unsigned int ysize, const unsigned int zsize)=0
void SetColor(unsigned int color)
Definition: itkOctree.h:145
void SetTree(OctreeNodeBranch *branch)
Definition: itkOctree.h:146
unsigned int m_Depth
Definition: itkOctree.h:179
Image< TPixel, 3 > ImageType
Definition: itkOctree.h:128
OctreeBase Self
Definition: itkOctree.h:59
OctreeNode m_Tree
Definition: itkOctree.h:182
OctreeBase Superclass
Definition: itkOctree.h:126
virtual unsigned int GetDepth() ITK_OVERRIDE
virtual unsigned int GetWidth()=0
virtual void SetDepth(unsigned int depth)=0
virtual int GetColorTableSize() const ITK_OVERRIDE
virtual OctreeNode * GetTree()=0
A data structure representing a node in an Octree.
Definition: itkOctreeNode.h:45
SmartPointer< Self > Pointer
Definition: itkOctree.h:127
unsigned int m_TrueDims[3]
Definition: itkOctree.h:180
virtual const char * GetColorTable() const =0
virtual unsigned int GetWidth() ITK_OVERRIDE
unsigned int m_Width
Definition: itkOctree.h:176
MappingFunctionType m_MappingFunction
Definition: itkOctree.h:184
Represent a 3D Image with an Octree data structure.
Definition: itkOctree.h:120
virtual void SetWidth(unsigned int width) ITK_OVERRIDE
OctreePlaneType
Definition: itkOctree.h:37
ImageType::Pointer ImageTypePointer
Definition: itkOctree.h:129
char m_ColorTable[ColorTableSize]
Definition: itkOctree.h:181
void BuildFromImage(Image< TPixel, 3 > *fromImage)
virtual const char * GetColorTable() const ITK_OVERRIDE
ImageTypePointer GetImage()
Base class for most ITK classes.
Definition: itkObject.h:57
SmartPointer< Self > Pointer
Definition: itkOctree.h:60
int GetValue(const unsigned int Dim0, const unsigned int Dim1, const unsigned int Dim2)
virtual void SetDepth(unsigned int depth) ITK_OVERRIDE
void SetBranch(OctreeNodeBranch *NewBranch)
Templated n-dimensional image class.
Definition: itkImage.h:75