ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLevelSetContainer.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 __itkLevelSetContainer_h
00020 #define __itkLevelSetContainer_h
00021 
00022 #include "itkLevelSetContainerBase.h"
00023 
00024 #include "itkLevelSetDenseImageBase.h"
00025 
00026 namespace itk
00027 {
00037 template< class TIdentifier, class TLevelSet >
00038 class LevelSetContainer :
00039 public LevelSetContainerBase< TIdentifier, TLevelSet >
00040 {
00041 public:
00042 
00043   typedef LevelSetContainer                               Self;
00044   typedef LevelSetContainerBase< TIdentifier, TLevelSet > Superclass;
00045   typedef SmartPointer< Self >                            Pointer;
00046   typedef SmartPointer< const Self >                      ConstPointer;
00047 
00049   itkNewMacro ( Self );
00050 
00051   itkTypeMacro ( LevelSetContainer, LevelSetContainerBase );
00052 
00053   typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
00054 
00055   typedef typename Superclass::LevelSetType       LevelSetType;
00056   typedef typename Superclass::LevelSetPointer    LevelSetPointer;
00057   typedef typename Superclass::InputIndexType     InputIndexType;
00058   typedef typename Superclass::OutputType         OutputPixelType;
00059   typedef typename Superclass::OutputRealType     OutputRealType;
00060   typedef typename Superclass::GradientType       GradientType;
00061   typedef typename Superclass::HessianType        HessianType;
00062 
00063   typedef typename Superclass::LevelSetContainerType              LevelSetContainerType;
00064   typedef typename Superclass::LevelSetContainerConstIteratorType LevelSetContainerConstIteratorType;
00065   typedef typename Superclass::LevelSetContainerIteratorType      LevelSetContainerIteratorType;
00066 
00067   typedef typename Superclass::HeavisideType          HeavisideType;
00068   typedef typename Superclass::HeavisideConstPointer  HeavisideConstPointer;
00069 
00070   itkStaticConstMacro ( Dimension, unsigned int, LevelSetType::Dimension );
00071 
00072   typedef typename Superclass::IdListType               IdListType;
00073   typedef typename Superclass::IdListIterator           IdListIterator;
00074   typedef typename Superclass::IdListImageType          IdListImageType;
00075   typedef typename Superclass::CacheImageType           CacheImageType;
00076   typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
00077 
00078   typedef typename Superclass::DomainMapImageFilterPointer  DomainMapImageFilterPointer;
00079   typedef typename Superclass::LevelSetDomainType           LevelSetDomainType;
00080   typedef typename Superclass::DomainIteratorType           DomainIteratorType;
00081 
00082 protected:
00083   LevelSetContainer() {}
00084   ~LevelSetContainer() {}
00085 
00086 private:
00087   LevelSetContainer( const Self& ); // purposely not implemented
00088   void operator = ( const Self& );  // purposely not implemented
00089 };
00090 
00095 template< class TIdentifier, class TImage >
00096 class LevelSetContainer< TIdentifier, LevelSetDenseImageBase< TImage > > :
00097 public LevelSetContainerBase< TIdentifier, LevelSetDenseImageBase< TImage > >
00098 {
00099 public:
00100   typedef LevelSetDenseImageBase< TImage >  LevelSetType;
00101 
00102   typedef LevelSetContainer                                   Self;
00103   typedef LevelSetContainerBase< TIdentifier, LevelSetType >  Superclass;
00104   typedef SmartPointer< Self >                                Pointer;
00105   typedef SmartPointer< const Self >                          ConstPointer;
00106 
00108   itkNewMacro ( Self );
00109 
00110   itkTypeMacro ( LevelSetContainer, LevelSetContainerBase );
00111 
00112   typedef typename Superclass::LevelSetIdentifierType LevelSetIdentifierType;
00113 
00114   typedef typename Superclass::LevelSetPointer    LevelSetPointer;
00115   typedef typename Superclass::InputIndexType     InputIndexType;
00116   typedef typename Superclass::OutputType         OutputPixelType;
00117   typedef typename Superclass::OutputRealType     OutputRealType;
00118   typedef typename Superclass::GradientType       GradientType;
00119   typedef typename Superclass::HessianType        HessianType;
00120 
00121   typedef typename Superclass::LevelSetContainerType              LevelSetContainerType;
00122   typedef typename Superclass::LevelSetContainerConstIteratorType LevelSetContainerConstIteratorType;
00123   typedef typename Superclass::LevelSetContainerIteratorType      LevelSetContainerIteratorType;
00124 
00125   typedef typename Superclass::HeavisideType          HeavisideType;
00126   typedef typename Superclass::HeavisideConstPointer  HeavisideConstPointer;
00127 
00128   itkStaticConstMacro ( Dimension, unsigned int, LevelSetType::Dimension );
00129 
00130   typedef typename Superclass::IdListType               IdListType;
00131   typedef typename Superclass::IdListIterator           IdListIterator;
00132   typedef typename Superclass::IdListImageType          IdListImageType;
00133   typedef typename Superclass::CacheImageType           CacheImageType;
00134   typedef typename Superclass::DomainMapImageFilterType DomainMapImageFilterType;
00135 
00136   typedef typename Superclass::DomainMapImageFilterPointer  DomainMapImageFilterPointer;
00137   typedef typename Superclass::LevelSetDomainType           LevelSetDomainType;
00138   typedef typename Superclass::DomainIteratorType           DomainIteratorType;
00139 
00140   typedef typename LevelSetType::ImageType    LevelSetImageType;
00141   typedef typename LevelSetImageType::Pointer LevelSetImagePointer;
00142 
00144   void CopyInformationAndAllocate( const Self * iOther, const bool & iAllocate )
00145     {
00146     LevelSetContainerType internalContainer = iOther->GetContainer();
00147     LevelSetContainerConstIteratorType it = internalContainer.begin();
00149 
00150     LevelSetContainerType newContainer;
00151 
00152     while( it != internalContainer.end() )
00153       {
00154       if( iAllocate )
00155         {
00156         LevelSetPointer temp_ls = LevelSetType::New();
00157 
00158         LevelSetImagePointer image = LevelSetImageType::New();
00159         const LevelSetImageType * otherImage = (it->second)->GetImage();
00160 
00161         image->CopyInformation( otherImage );
00162         image->SetBufferedRegion( otherImage->GetBufferedRegion() );
00163         image->SetRequestedRegion( otherImage->GetRequestedRegion() );
00164         image->SetLargestPossibleRegion( otherImage->GetLargestPossibleRegion() );
00165         image->Allocate();
00166         image->FillBuffer( NumericTraits< OutputPixelType >::Zero );
00167 
00168         temp_ls->SetImage( image );
00169         newContainer[ it->first ] = temp_ls;
00170         }
00171       else
00172         {
00173         LevelSetPointer temp_ls;
00174         newContainer[ it->first ] = temp_ls;
00175         }
00176       ++it;
00177       }
00178 
00179     this->SetContainer( newContainer );
00180     }
00181 
00182 protected:
00183   LevelSetContainer() {}
00184   ~LevelSetContainer() {}
00185 
00186 private:
00187   LevelSetContainer( const Self& ); // purposely not implemented
00188   void operator = ( const Self& );  // purposely not implemented
00189 };
00190 
00191 }
00192 
00193 #endif // __itkLevelSetContainer_h
00194