ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLevelSetEvolutionComputeIterationThreader.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 __itkLevelSetEvolutionComputeIterationThreader_h
00019 #define __itkLevelSetEvolutionComputeIterationThreader_h
00020 
00021 #include "itkDomainThreader.h"
00022 #include "itkThreadedImageRegionPartitioner.h"
00023 #include "itkThreadedIteratorRangePartitioner.h"
00024 
00025 #include "itkLevelSetDenseImageBase.h"
00026 #include "itkWhitakerSparseLevelSetImage.h"
00027 
00028 namespace itk
00029 {
00030 
00038 template< class TLevelSet, class TDomainPartitioner, class TLevelSetEvolution >
00039 class LevelSetEvolutionComputeIterationThreader
00040 {};
00041 
00042 // For dense image level set split by putting part of the level set region in
00043 // each thread.
00044 template< class TImage, class TLevelSetEvolution >
00045 class LevelSetEvolutionComputeIterationThreader< LevelSetDenseImageBase< TImage >, ThreadedImageRegionPartitioner< TImage::ImageDimension >, TLevelSetEvolution >
00046   : public DomainThreader< ThreadedImageRegionPartitioner< TImage::ImageDimension >, TLevelSetEvolution >
00047 {
00048 public:
00050   typedef LevelSetEvolutionComputeIterationThreader                                                      Self;
00051   typedef DomainThreader< ThreadedImageRegionPartitioner< TImage::ImageDimension >, TLevelSetEvolution > Superclass;
00052   typedef SmartPointer< Self >                                                                           Pointer;
00053   typedef SmartPointer< const Self >                                                                     ConstPointer;
00054 
00056   itkTypeMacro( LevelSetEvolutionComputeIterationThreader, DomainThreader );
00057 
00059   itkNewMacro( Self );
00060 
00062   typedef typename Superclass::DomainType    DomainType;
00063   typedef typename Superclass::AssociateType AssociateType;
00064 
00066   typedef TLevelSetEvolution                                     LevelSetEvolutionType;
00067   typedef typename LevelSetEvolutionType::IdListType             IdListType;
00068   typedef typename LevelSetEvolutionType::IdListConstIterator    IdListConstIterator;
00069   typedef typename LevelSetEvolutionType::InputImageType         InputImageType;
00070   typedef typename LevelSetEvolutionType::LevelSetType           LevelSetType;
00071   typedef typename LevelSetEvolutionType::LevelSetImageType      LevelSetImageType;
00072   typedef typename LevelSetEvolutionType::LevelSetDataType       LevelSetDataType;
00073   typedef typename LevelSetEvolutionType::LevelSetOutputRealType LevelSetOutputRealType;
00074   typedef typename LevelSetEvolutionType::LevelSetContainerType  LevelSetContainerType;
00075   typedef typename LevelSetEvolutionType::EquationContainerType  EquationContainerType;
00076   typedef typename LevelSetEvolutionType::TermContainerType      TermContainerType;
00077 
00078 protected:
00079   LevelSetEvolutionComputeIterationThreader();
00080 
00081   virtual void ThreadedExecution( const DomainType & imageSubRegion, const ThreadIdType threadId );
00082 
00083 private:
00084   LevelSetEvolutionComputeIterationThreader( const Self & ); // purposely not implemented
00085   void operator=( const Self & ); // purposely not implemented
00086 };
00087 
00088 // For dense image level set split by putting a level set domain in each thread.
00089 template< class TImage, class TLevelSetEvolution >
00090 class LevelSetEvolutionComputeIterationThreader< LevelSetDenseImageBase< TImage >,
00091       ThreadedIteratorRangePartitioner< typename TLevelSetEvolution::DomainMapImageFilterType::DomainMapType::const_iterator >, TLevelSetEvolution >
00092   : public DomainThreader< ThreadedIteratorRangePartitioner< typename TLevelSetEvolution::DomainMapImageFilterType::DomainMapType::const_iterator >, TLevelSetEvolution >
00093 {
00094 public:
00095   typedef typename TLevelSetEvolution::DomainMapImageFilterType::DomainMapType::const_iterator DomainMapConstIteratorType;
00096   typedef ThreadedIteratorRangePartitioner< DomainMapConstIteratorType >                       ThreadedDomainMapPartitionerType;
00097 
00099   typedef LevelSetEvolutionComputeIterationThreader                              Self;
00100   typedef DomainThreader< ThreadedDomainMapPartitionerType, TLevelSetEvolution > Superclass;
00101   typedef SmartPointer< Self >                                                   Pointer;
00102   typedef SmartPointer< const Self >                                             ConstPointer;
00103 
00105   itkTypeMacro( LevelSetEvolutionComputeIterationThreader, DomainThreader );
00106 
00108   itkNewMacro( Self );
00109 
00111   typedef typename Superclass::DomainType    DomainType;
00112   typedef typename Superclass::AssociateType AssociateType;
00113 
00115   typedef TLevelSetEvolution                                     LevelSetEvolutionType;
00116   typedef typename LevelSetEvolutionType::IdListType             IdListType;
00117   typedef typename LevelSetEvolutionType::IdListConstIterator    IdListConstIterator;
00118   typedef typename LevelSetEvolutionType::InputImageType         InputImageType;
00119   typedef typename LevelSetEvolutionType::LevelSetType           LevelSetType;
00120   typedef typename LevelSetEvolutionType::LevelSetImageType      LevelSetImageType;
00121   typedef typename LevelSetEvolutionType::LevelSetDataType       LevelSetDataType;
00122   typedef typename LevelSetEvolutionType::LevelSetOutputRealType LevelSetOutputRealType;
00123   typedef typename LevelSetEvolutionType::LevelSetContainerType  LevelSetContainerType;
00124   typedef typename LevelSetEvolutionType::EquationContainerType  EquationContainerType;
00125   typedef typename LevelSetEvolutionType::TermContainerType      TermContainerType;
00126 
00127 protected:
00128   LevelSetEvolutionComputeIterationThreader();
00129 
00130   virtual void ThreadedExecution( const DomainType & imageSubRegion, const ThreadIdType threadId );
00131 
00132 private:
00133   LevelSetEvolutionComputeIterationThreader( const Self & ); // purposely not implemented
00134   void operator=( const Self & ); // purposely not implemented
00135 };
00136 
00137 // For Whitaker sparse level set split by putting part of the level set in each
00138 // thread.
00139 template< class TOutput, unsigned int VDimension, class TLevelSetEvolution >
00140 class LevelSetEvolutionComputeIterationThreader<
00141       WhitakerSparseLevelSetImage< TOutput, VDimension >,
00142       ThreadedIteratorRangePartitioner< typename WhitakerSparseLevelSetImage< TOutput, VDimension >::LayerConstIterator >,
00143       TLevelSetEvolution
00144       >
00145   : public DomainThreader< ThreadedIteratorRangePartitioner< typename WhitakerSparseLevelSetImage< TOutput, VDimension >::LayerConstIterator >, TLevelSetEvolution >
00146 {
00147 public:
00149   typedef LevelSetEvolutionComputeIterationThreader                                                                                                                 Self;
00150   typedef DomainThreader< ThreadedIteratorRangePartitioner< typename WhitakerSparseLevelSetImage< TOutput, VDimension >::LayerConstIterator >, TLevelSetEvolution > Superclass;
00151   typedef SmartPointer< Self >                                                                                                                                      Pointer;
00152   typedef SmartPointer< const Self >                                                                                                                                ConstPointer;
00153 
00155   itkTypeMacro( LevelSetEvolutionComputeIterationThreader, DomainThreader );
00156 
00158   itkNewMacro( Self );
00159 
00161   typedef typename Superclass::DomainType    DomainType;
00162   typedef typename Superclass::AssociateType AssociateType;
00163 
00165   typedef TLevelSetEvolution                                     LevelSetEvolutionType;
00166   typedef typename LevelSetEvolutionType::LevelSetType           LevelSetType;
00167   typedef typename LevelSetEvolutionType::LevelSetContainerType  LevelSetContainerType;
00168   typedef typename LevelSetEvolutionType::LevelSetIdentifierType LevelSetIdentifierType;
00169   typedef typename LevelSetEvolutionType::LevelSetInputType      LevelSetInputType;
00170   typedef typename LevelSetEvolutionType::LevelSetOutputType     LevelSetOutputType;
00171   typedef typename LevelSetEvolutionType::LevelSetDataType       LevelSetDataType;
00172   typedef typename LevelSetEvolutionType::TermContainerType      TermContainerType;
00173   typedef typename LevelSetEvolutionType::NodePairType           NodePairType;
00174 
00175 protected:
00176   LevelSetEvolutionComputeIterationThreader();
00177 
00178   virtual void BeforeThreadedExecution();
00179 
00180   virtual void ThreadedExecution( const DomainType & iteratorSubRange, const ThreadIdType threadId );
00181 
00182   virtual void AfterThreadedExecution();
00183 
00184   typedef std::vector< std::vector< NodePairType > > NodePairsPerThreadType;
00185   NodePairsPerThreadType m_NodePairsPerThread;
00186 
00187 private:
00188   LevelSetEvolutionComputeIterationThreader( const Self & ); // purposely not implemented
00189   void operator=( const Self & ); // purposely not implemented
00190 };
00191 
00192 } // namespace itk
00193 
00194 #ifndef ITK_MANUAL_INSTANTIATION
00195 #include "itkLevelSetEvolutionComputeIterationThreader.hxx"
00196 #endif
00197 
00198 #endif
00199