| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkOctree.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:43 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
|
| 18 |
DEF |
#ifndef __ITKOCTREE_H__ |
| 19 |
DEF |
#define __ITKOCTREE_H__ |
| 20 |
|
|
| 21 |
|
#include "itkOctreeNode.h" |
| 22 |
|
#include "itkImage.h" |
| 23 |
|
/* |
| 24 |
IND |
** Octree data structure |
| 25 |
IND |
**/ |
| 26 |
|
namespace itk { |
| 27 |
|
|
| 28 |
IND |
**enum |
| 29 |
IND |
****{ |
| 30 |
IND |
******B2_MASKFILE_BLACK = 0, |
| 31 |
IND |
******B2_MASKFILE_WHITE = 1, |
| 32 |
IND |
******B2_MASKFILE_GRAY = 2 |
| 33 |
IND |
****}; |
| 34 |
IND |
**/** |
| 35 |
IND |
**** The enumeration to define the planar orientation of the octree |
| 36 |
IND |
****/ |
| 37 |
IND |
**enum OctreePlaneType |
| 38 |
IND |
****{ |
| 39 |
IND |
******UNKNOWN_PLANE, /** < The plane is Unknown */ |
| 40 |
|
SAGITAL_PLANE, /** < The plane is Sagital */ |
| 41 |
|
CORONAL_PLANE, /** < The plane is Coronal */ |
| 42 |
|
TRANSVERSE_PLANE /** < The plane is Transverse */ |
| 43 |
IND |
****}; |
| 44 |
|
|
| 45 |
|
/** |
| 46 |
|
* \class OctreeBase |
| 47 |
|
* \brief Provides non-templated access to templated instances of Octree |
| 48 |
|
* |
| 49 |
|
*/ |
| 50 |
|
class OctreeBase : public Object |
| 51 |
IND |
**{ |
| 52 |
IND |
**public: |
| 53 |
|
/** Standard class typedefs. */ |
| 54 |
|
typedef OctreeBase Self; |
| 55 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 56 |
|
|
| 57 |
IND |
****/** Get the actual tree base |
| 58 |
IND |
****** |
| 59 |
IND |
****** Returns the tree, or 0 if the Octree isn't built yet |
| 60 |
IND |
******/ |
| 61 |
IND |
****virtual OctreeNode *GetTree() = 0; |
| 62 |
IND |
****/** Get tree depth. |
| 63 |
IND |
****** |
| 64 |
IND |
****** Depth represents x, for the smallest 2^x >= largest image dimension |
| 65 |
IND |
******/ |
| 66 |
IND |
****virtual unsigned int GetDepth() = 0; |
| 67 |
IND |
****/** Get tree width. |
| 68 |
IND |
****** |
| 69 |
IND |
****** Width == smallest 2^x >= largest image dimension |
| 70 |
IND |
****** i.e. 2^Depth == Width |
| 71 |
IND |
******/ |
| 72 |
IND |
****virtual unsigned int GetWidth() = 0; |
| 73 |
|
|
| 74 |
IND |
****/** Set the depth, e.g. when reading tree from a file. */ |
| 75 |
IND |
****virtual void SetDepth(unsigned int depth) = 0; |
| 76 |
|
|
| 77 |
IND |
****/** Set width, e.g. when reading from a file. */ |
| 78 |
IND |
****virtual void SetWidth(unsigned int width) = 0; |
| 79 |
IND |
****/** Build an Octree from an Image's pixel buffer. |
| 80 |
IND |
****** |
| 81 |
IND |
****** Method needed for ImageIO class, which has no handle on image, just |
| 82 |
IND |
****** the pixel buffer. |
| 83 |
IND |
******/ |
| 84 |
IND |
****virtual void BuildFromBuffer(const void *buffer, |
| 85 |
LEN |
const int xsize,const int ysize,const int zsize) = 0; |
| 86 |
IND |
****/** Get the ColorTable Pointer |
| 87 |
IND |
****** |
| 88 |
IND |
****** Returns color table pointer for this tree. |
| 89 |
IND |
****** |
| 90 |
IND |
****** Each Octree has an array of char whose size = the # of color table |
| 91 |
IND |
****** entries. Each Node in the Octree points either to 8 sub-nodes, or |
| 92 |
IND |
****** into the ColorTable; The color table isn't actually used to hold |
| 93 |
IND |
****** data; it simply provides a range of unique addresses that are distinct |
| 94 |
IND |
****** from the address of any valid subtree. |
| 95 |
IND |
******/ |
| 96 |
IND |
****virtual const char *GetColorTable() const = 0; |
| 97 |
|
|
| 98 |
IND |
****/** Get the size of the Color Table */ |
| 99 |
IND |
****virtual int GetColorTableSize() const = 0; |
| 100 |
IND |
**}; |
| 101 |
|
|
| 102 |
IND |
**/** |
| 103 |
IND |
**** \class Octree |
| 104 |
IND |
**** \brief represent a 3D Image with an Octree data structure. |
| 105 |
IND |
**** |
| 106 |
IND |
**** Parameterized on Pixel type of the image, # of colors in color table, |
| 107 |
IND |
**** and a Mapping function, derived from itk::FunctionBase |
| 108 |
IND |
****/ |
| 109 |
IND |
**template <class TPixel,unsigned int ColorTableSize,class MappingFunctionType> |
| 110 |
IND |
**class Octree: public OctreeBase |
| 111 |
IND |
**{ |
| 112 |
IND |
**public: |
| 113 |
IND |
****/** Standard class typedefs. */ |
| 114 |
IND |
****typedef Octree Self; |
| 115 |
TDA,IND |
****typedef OctreeBase Superclass; |
| 116 |
TDA,IND |
****typedef SmartPointer<Self> Pointer; |
| 117 |
TDA,IND |
****typedef Image<TPixel,3> ImageType; |
| 118 |
TDA,IND |
****typedef typename ImageType::Pointer ImageTypePointer; |
| 119 |
IND |
****/** Method for creation through the object factory. */ |
| 120 |
IND |
****itkNewMacro(Self); |
| 121 |
|
|
| 122 |
IND |
****/** Run-time type information (and related methods). */ |
| 123 |
IND |
****itkTypeMacro(AnalyzeImageIO, Superclass); |
| 124 |
|
|
| 125 |
IND |
****ImageTypePointer GetImage(); |
| 126 |
LEN,IND |
****virtual void BuildFromBuffer(const void *buffer,const int xsize,const int ysize,const int zsize); |
| 127 |
IND |
****void BuildFromImage(Image<TPixel,3> *fromImage); |
| 128 |
|
|
| 129 |
IND |
****Octree(void); |
| 130 |
IND |
****~Octree(void); |
| 131 |
IND |
****void SetColor(unsigned int color) { m_Tree.SetColor(color); } |
| 132 |
IND |
****void SetTree(OctreeNodeBranch *branch) { m_Tree.SetBranch(branch); } |
| 133 |
IND |
****void SetTrueDims(const unsigned int Dim0, const unsigned int Dim1, |
| 134 |
|
const unsigned int Dim2); |
| 135 |
|
|
| 136 |
IND |
****unsigned int GetValue(const unsigned int Dim0, const unsigned int Dim1, |
| 137 |
|
const unsigned int Dim2); |
| 138 |
|
|
| 139 |
IND |
****virtual void SetWidth(unsigned int width); |
| 140 |
IND |
****virtual void SetDepth(unsigned int depth); |
| 141 |
IND |
****virtual unsigned int GetWidth(); |
| 142 |
IND |
****virtual unsigned int GetDepth(); |
| 143 |
|
|
| 144 |
IND |
****virtual OctreeNode *GetTree(); |
| 145 |
IND |
****virtual const char *GetColorTable() const; |
| 146 |
IND |
****virtual int GetColorTableSize() const; |
| 147 |
IND |
**private: |
| 148 |
IND |
****Octree(const Self&); // purposely not implemented |
| 149 |
IND |
****void operator=(const Self&); // purposely not implemented |
| 150 |
|
|
| 151 |
LEN,IND |
****OctreeNodeBranch *maskToOctree (const TPixel* Mask, unsigned width, unsigned x, |
| 152 |
|
unsigned y, unsigned z, unsigned xsize, |
| 153 |
|
unsigned ysize, unsigned zsize); |
| 154 |
LEN,IND |
****enum OctreePlaneType m_Plane; // The orientation of the plane for this octree |
| 155 |
IND |
****unsigned int m_Width; // The width of the Octree |
| 156 |
IND |
**********************************// ( This is always a power of 2, and large |
| 157 |
|
// enough to contain MAX(DIMS[1,2,3])) |
| 158 |
IND |
****unsigned int m_Depth; // < The depth of the Octree |
| 159 |
IND |
****unsigned int m_TrueDims[3]; // The true dimensions of the image |
| 160 |
IND |
****char m_ColorTable[ColorTableSize]; |
| 161 |
IND |
****OctreeNode m_Tree; |
| 162 |
IND |
****// OctreeColorMapFunction m_ColorMapFunction; |
| 163 |
IND |
****MappingFunctionType m_MappingFunction; |
| 164 |
IND |
**}; |
| 165 |
|
|
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 169 |
|
#include "itkOctree.txx" |
| 170 |
|
#endif |
| 171 |
|
|
| 172 |
|
#endif /* __ITKOCTREE_H__ */ |
| 173 |
|
|