00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __ITKOCTREE_H__
00019 #define __ITKOCTREE_H__
00020
00021 #include "itkOctreeNode.h"
00022 #include "itkImage.h"
00023
00024
00025
00026 namespace itk {
00027
00028 enum
00029 {
00030 B2_MASKFILE_BLACK = 0,
00031 B2_MASKFILE_WHITE = 1,
00032 B2_MASKFILE_GRAY = 2
00033 };
00037 enum OctreePlaneType
00038 {
00039 UNKNOWN_PLANE,
00040 SAGITAL_PLANE,
00041 CORONAL_PLANE,
00042 TRANSVERSE_PLANE
00043 };
00044
00050 class OctreeBase : public Object
00051 {
00052 public:
00054 typedef OctreeBase Self;
00055 typedef SmartPointer<Self> Pointer;
00056
00061 virtual OctreeNode *GetTree() = 0;
00066 virtual unsigned int GetDepth() = 0;
00072 virtual unsigned int GetWidth() = 0;
00073
00075 virtual void SetDepth(unsigned int depth) = 0;
00076
00078 virtual void SetWidth(unsigned int width) = 0;
00084 virtual void BuildFromBuffer(const void *buffer,
00085 const int xsize,const int ysize,const int zsize) = 0;
00096 virtual const char *GetColorTable() const = 0;
00097
00099 virtual int GetColorTableSize() const = 0;
00100 };
00101
00109 template <class TPixel,unsigned int ColorTableSize,class MappingFunctionType>
00110 class Octree: public OctreeBase
00111 {
00112 public:
00114 typedef Octree Self;
00115 typedef OctreeBase Superclass;
00116 typedef SmartPointer<Self> Pointer;
00117 typedef Image<TPixel,3> ImageType;
00118 typedef typename ImageType::Pointer ImageTypePointer;
00120 itkNewMacro(Self);
00121
00123 itkTypeMacro(AnalyzeImageIO, Superclass);
00124
00125 ImageTypePointer GetImage();
00126 virtual void BuildFromBuffer(const void *buffer,const int xsize,const int ysize,const int zsize);
00127 void BuildFromImage(Image<TPixel,3> *fromImage);
00128
00129 Octree(void);
00130 ~Octree(void);
00131 void SetColor(unsigned int color) { m_Tree.SetColor(color); }
00132 void SetTree(OctreeNodeBranch *branch) { m_Tree.SetBranch(branch); }
00133 void SetTrueDims(const unsigned int Dim0, const unsigned int Dim1,
00134 const unsigned int Dim2);
00135
00136 unsigned int GetValue(const unsigned int Dim0, const unsigned int Dim1,
00137 const unsigned int Dim2);
00138
00139 virtual void SetWidth(unsigned int width);
00140 virtual void SetDepth(unsigned int depth);
00141 virtual unsigned int GetWidth();
00142 virtual unsigned int GetDepth();
00143
00144 virtual OctreeNode *GetTree();
00145 virtual const char *GetColorTable() const;
00146 virtual int GetColorTableSize() const;
00147 private:
00148 Octree(const Self&);
00149 void operator=(const Self&);
00150
00151 OctreeNodeBranch *maskToOctree (const TPixel* Mask, unsigned width, unsigned x,
00152 unsigned y, unsigned z, unsigned xsize,
00153 unsigned ysize, unsigned zsize);
00154 enum OctreePlaneType m_Plane;
00155 unsigned int m_Width;
00156
00157
00158 unsigned int m_Depth;
00159 unsigned int m_TrueDims[3];
00160 char m_ColorTable[ColorTableSize];
00161 OctreeNode m_Tree;
00162
00163 MappingFunctionType m_MappingFunction;
00164 };
00165
00166 }
00167
00168 #ifndef ITK_MANUAL_INSTANTIATION
00169 #include "itkOctree.txx"
00170 #endif
00171
00172 #endif