ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLevelSetSparseImageBase.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 
00019 #ifndef __itkLevelSetSparseImageBase_h
00020 #define __itkLevelSetSparseImageBase_h
00021 
00022 #include "itkDiscreteLevelSetImageBase.h"
00023 #include "itkObjectFactory.h"
00024 
00025 #include "itkLabelObject.h"
00026 #include "itkLabelMap.h"
00027 
00028 namespace itk
00029 {
00039 template< typename TOutput, unsigned int VDimension >
00040 class LevelSetSparseImageBase :
00041   public DiscreteLevelSetImageBase< TOutput, VDimension >
00042 {
00043 public:
00044   typedef LevelSetSparseImageBase                           Self;
00045   typedef SmartPointer< Self >                              Pointer;
00046   typedef SmartPointer< const Self >                        ConstPointer;
00047   typedef DiscreteLevelSetImageBase< TOutput, VDimension >  Superclass;
00048 
00050   itkTypeMacro ( LevelSetSparseImageBase, DiscreteLevelSetImageBase );
00051 
00052   itkStaticConstMacro ( Dimension, unsigned int, Superclass::Dimension );
00053 
00054   typedef typename Superclass::InputType        InputType;
00055   typedef typename Superclass::OutputType       OutputType;
00056   typedef typename Superclass::OutputRealType   OutputRealType;
00057   typedef typename Superclass::GradientType     GradientType;
00058   typedef typename Superclass::HessianType      HessianType;
00059   typedef typename Superclass::LevelSetDataType LevelSetDataType;
00060 
00061   typedef int8_t                                  LayerIdType;
00062   typedef std::list< LayerIdType >                LayerIdListType;
00063 
00064   typedef LabelObject< LayerIdType, VDimension >  LabelObjectType;
00065   typedef typename LabelObjectType::Pointer       LabelObjectPointer;
00066   typedef typename LabelObjectType::LengthType    LabelObjectLengthType;
00067   typedef typename LabelObjectType::LineType      LabelObjectLineType;
00068 
00069   typedef LabelMap< LabelObjectType >         LabelMapType;
00070   typedef typename LabelMapType::Pointer      LabelMapPointer;
00071   typedef typename LabelMapType::RegionType   RegionType;
00072 
00073   typedef std::map< InputType, OutputType,
00074                     Functor::IndexLexicographicCompare< VDimension > >
00075                                                   LayerType;
00076   typedef typename LayerType::iterator            LayerIterator;
00077   typedef typename LayerType::const_iterator      LayerConstIterator;
00078 
00079   typedef std::map< LayerIdType, LayerType >      LayerMapType;
00080   typedef typename LayerMapType::iterator         LayerMapIterator;
00081   typedef typename LayerMapType::const_iterator   LayerMapConstIterator;
00082 
00084   virtual LayerIdType Status( const InputType& iP ) const;
00085 
00087   const LayerType& GetLayer( LayerIdType iVal ) const;
00088 
00090   LayerType& GetLayer( LayerIdType iVal );
00091 
00093   void SetLayer( LayerIdType iVal, const LayerType& iLayer );
00094 
00096   virtual void SetLabelMap( LabelMapType* iLabelMap );
00097   itkGetObjectMacro( LabelMap, LabelMapType );
00099 
00101   virtual void Graft( const DataObject* data );
00102 
00104   template< class TLabel >
00105   typename LabelObject< TLabel, VDimension >::Pointer GetAsLabelObject();
00106 
00107 protected:
00108   LevelSetSparseImageBase();
00109 
00110   virtual ~LevelSetSparseImageBase();
00111 
00112   LayerMapType      m_Layers;
00113   LabelMapPointer   m_LabelMap;
00114   LayerIdListType   m_InternalLabelList;
00115 
00117   virtual void InitializeLayers() = 0;
00118 
00119   virtual void InitializeInternalLabelList() = 0;
00120 
00121   virtual bool IsInside( const InputType& iP ) const;
00122 
00124   virtual void Initialize();
00125 
00127   virtual void CopyInformation( const DataObject* data );
00128 
00129 private:
00130 
00131   LevelSetSparseImageBase( const Self& ); // purposely not implemented
00132   void operator = ( const Self& ); // purposely not implemented
00133   };
00134 }
00135 
00136 #ifndef ITK_MANUAL_INSTANTIATION
00137 #include "itkLevelSetSparseImageBase.hxx"
00138 #endif
00139 
00140 #endif // __itkLevelSetSparseImageBase_h
00141