ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkSparseImage.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkSparseImage_h
00019 #define __itkSparseImage_h
00020 
00021 #include "itkImage.h"
00022 #include "itkSparseFieldLayer.h"
00023 #include "itkObjectStore.h"
00024 
00025 namespace itk
00026 {
00066 template< class TNode, unsigned int VImageDimension = 2 >
00067 class ITK_EXPORT SparseImage:public Image< TNode *, VImageDimension >
00068 {
00069 public:
00071   typedef SparseImage                       Self;
00072   typedef Image< TNode *, VImageDimension > Superclass;
00073   typedef SmartPointer< Self >              Pointer;
00074   typedef SmartPointer< const Self >        ConstPointer;
00075   typedef WeakPointer< const Self >         ConstWeakPointer;
00076 
00078   itkNewMacro(Self);
00079 
00081   itkTypeMacro(SparseImage, Image);
00082 
00084   itkStaticConstMacro(ImageDimension, unsigned int,
00085                       Superclass::ImageDimension);
00086 
00088   typedef TNode NodeType;
00089 
00091   typedef typename Superclass::IndexType IndexType;
00092 
00095   typedef NeighborhoodAccessorFunctor< Self >
00096   NeighborhoodAccessorFunctorType;
00097 
00098   typedef typename Superclass::IOPixelType IOPixelType;
00099 
00101   typedef SparseFieldLayer< NodeType > NodeListType;
00102   typedef ObjectStore< NodeType >      NodeStoreType;
00103 
00106   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
00107   { return NeighborhoodAccessorFunctorType(); }
00108 
00111   const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
00112   { return NeighborhoodAccessorFunctorType(); }
00113 
00116   NodeType * AddNode(const IndexType & index)
00117   {
00118     m_NodeList->PushFront( m_NodeStore->Borrow() );
00119     NodeType *node = m_NodeList->Front();
00120     node->m_Index = index;
00121     this->SetPixel(index, node);
00122     return node;
00123   }
00125 
00128   NodeListType * GetNodeList()
00129   {
00130     return m_NodeList;
00131   }
00132 
00135   virtual void Initialize();
00136 
00137 protected:
00138   SparseImage();
00139   ~SparseImage() {}
00140 
00141   void PrintSelf(std::ostream & os, Indent indent) const;
00142 
00143 private:
00145   typename NodeListType::Pointer m_NodeList;
00146 
00147   typename NodeStoreType::Pointer m_NodeStore;
00148 
00149   SparseImage(const Self &);    //purposely not implemented
00150   void operator=(const Self &); //purposely not implemented
00151 };
00152 } // end namespace itk
00153 
00154 #ifndef ITK_MANUAL_INSTANTIATION
00155 #include "itkSparseImage.hxx"
00156 #endif
00157 
00158 #endif
00159