Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkOctree_h
00018 #define __itkOctree_h
00019
00020 #include "itkOctreeNode.h"
00021 #include "itkImage.h"
00025 namespace itk {
00026
00027 enum
00028 {
00029 B2_MASKFILE_BLACK = 0,
00030 B2_MASKFILE_WHITE = 1,
00031 B2_MASKFILE_GRAY = 2
00032 };
00036 enum OctreePlaneType
00037 {
00038
00046 };
00047
00053 class OctreeBase : public Object
00054 {
00055 public:
00056
00058 typedef OctreeBase Self;
00059 typedef SmartPointer<Self> Pointer;
00060
00065 virtual OctreeNode *GetTree() = 0;
00066
00071 virtual unsigned int GetDepth() = 0;
00072
00078 virtual unsigned int GetWidth() = 0;
00079
00081 virtual void SetDepth(unsigned int depth) = 0;
00082
00084 virtual void SetWidth(unsigned int width) = 0;
00085
00091 virtual void BuildFromBuffer(const void *buffer,
00092 const int xsize,const int ysize,const int zsize) = 0;
00093
00104 virtual const char *GetColorTable() const = 0;
00105
00107 virtual int GetColorTableSize() const = 0;
00108 };
00109
00117 template <class TPixel,unsigned int ColorTableSize,class MappingFunctionType>
00118 class Octree: public OctreeBase
00119 {
00120 public:
00121
00123 typedef Octree Self;
00124 typedef OctreeBase Superclass;
00125 typedef SmartPointer<Self> Pointer;
00126 typedef Image<TPixel,3> ImageType;
00127 typedef typename ImageType::Pointer ImageTypePointer;
00128
00130 itkNewMacro(Self);
00131
00133 itkTypeMacro(Octree, Superclass);
00134
00135 ImageTypePointer GetImage();
00136 virtual void BuildFromBuffer(const void *buffer,const int xsize,const int ysize,const int zsize);
00137 void BuildFromImage(Image<TPixel,3> *fromImage);
00138
00139 Octree(void);
00140 ~Octree(void);
00141 void SetColor(unsigned int color) { m_Tree.SetColor(color); }
00142 void SetTree(OctreeNodeBranch *branch) { m_Tree.SetBranch(branch); }
00143 void SetTrueDims(const unsigned int Dim0, const unsigned int Dim1,
00144 const unsigned int Dim2);
00145
00146 unsigned int GetValue(const unsigned int Dim0, const unsigned int Dim1,
00147 const unsigned int Dim2);
00148
00149 virtual void SetWidth(unsigned int width);
00150 virtual void SetDepth(unsigned int depth);
00151 virtual unsigned int GetWidth();
00152 virtual unsigned int GetDepth();
00153
00154 virtual OctreeNode *GetTree();
00155 virtual const char *GetColorTable() const;
00156 virtual int GetColorTableSize() const;
00157 private:
00158 Octree(const Self&);
00159 void operator=(const Self&);
00160
00161 OctreeNodeBranch *maskToOctree (const TPixel* Mask, unsigned width, unsigned x,
00162 unsigned y, unsigned z, unsigned xsize,
00163 unsigned ysize, unsigned zsize);
00164 enum OctreePlaneType m_Plane;
00165 unsigned int m_Width;
00166
00167
00168 unsigned int m_Depth;
00169 unsigned int m_TrueDims[3];
00170 char m_ColorTable[ColorTableSize];
00171 OctreeNode m_Tree;
00172
00173 MappingFunctionType m_MappingFunction;
00174 };
00175
00176 }
00177
00178 #ifndef ITK_MANUAL_INSTANTIATION
00179 #include "itkOctree.txx"
00180 #endif
00181
00182 #endif
00183