Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkOctree.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkOctree.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006/02/05 20:57:46 $
00007   Version:   $Revision: 1.5 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkOctree_h
00018 #define __itkOctree_h
00019 
00020 #include "itkOctreeNode.h"
00021 #include "itkImage.h"
00022 /*
00023  * Octree data structure
00024  */
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(AnalyzeImageIO, 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&);         // purposely not implemented
00159     void operator=(const Self&); // purposely not implemented
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; // The orientation of the plane for this octree
00165     unsigned int m_Width;         // The width of the Octree 
00166                                   // ( This is always a power of 2, and large 
00167                                   // enough to contain MAX(DIMS[1,2,3]))
00168     unsigned int m_Depth;         // < The depth of the Octree
00169     unsigned int m_TrueDims[3];   // The true dimensions of the image
00170     char m_ColorTable[ColorTableSize];
00171     OctreeNode m_Tree;
00172     // OctreeColorMapFunction m_ColorMapFunction;
00173     MappingFunctionType m_MappingFunction;
00174   };
00175 
00176 }
00177 
00178 #ifndef ITK_MANUAL_INSTANTIATION
00179 #include "itkOctree.txx"
00180 #endif
00181 
00182 #endif                          /* __itkOctree_h */
00183 

Generated at Mon Mar 12 01:58:57 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000