ITK  4.2.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 int xsize, const int ysize, const int zsize) = 0;
94 
105  virtual const char * GetColorTable() const = 0;
106 
108  virtual int GetColorTableSize() const = 0;
109 };
110 
119 template< class TPixel, unsigned int ColorTableSize, class 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 int xsize, const int ysize, const int zsize);
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  unsigned int GetValue(const unsigned int Dim0, const unsigned int Dim1,
151  const unsigned int Dim2);
152 
153  virtual void SetWidth(unsigned int width);
154 
155  virtual void SetDepth(unsigned int depth);
156 
157  virtual unsigned int GetWidth();
158 
159  virtual unsigned int GetDepth();
160 
161  virtual OctreeNode * GetTree();
162 
163  virtual const char * GetColorTable() const;
164 
165  virtual int GetColorTableSize() const;
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 */
193