ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLevelSetEquationTermBase.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 __itkLevelSetEquationTermBase_h
00020 #define __itkLevelSetEquationTermBase_h
00021 
00022 #include "itkObject.h"
00023 #include "itkHeavisideStepFunctionBase.h"
00024 #include "itksys/hash_set.hxx"
00025 
00026 namespace itk
00027 {
00047 template< class TInputImage, // Input image
00048           class TLevelSetContainer >
00049 class LevelSetEquationTermBase : public Object
00050 {
00051 public:
00052   typedef LevelSetEquationTermBase   Self;
00053   typedef SmartPointer< Self >       Pointer;
00054   typedef SmartPointer< const Self > ConstPointer;
00055   typedef Object                     Superclass;
00056 
00058   itkTypeMacro( LevelSetEquationTermBase, Object );
00059 
00060   typedef TInputImage                                     InputImageType;
00061   typedef typename InputImageType::Pointer                InputImagePointer;
00062   typedef typename InputImageType::PixelType              InputPixelType;
00063   typedef typename NumericTraits< InputPixelType >::RealType
00064                                                           InputPixelRealType;
00065 
00067   typedef TLevelSetContainer                              LevelSetContainerType;
00068   typedef typename LevelSetContainerType::LevelSetIdentifierType
00069                                                           LevelSetIdentifierType;
00070   typedef typename LevelSetContainerType::Pointer         LevelSetContainerPointer;
00071   typedef typename LevelSetContainerType::LevelSetType    LevelSetType;
00072   typedef typename LevelSetContainerType::LevelSetPointer LevelSetPointer;
00073   typedef typename LevelSetContainerType::OutputType      LevelSetOutputPixelType;
00074   typedef typename LevelSetContainerType::OutputRealType  LevelSetOutputRealType;
00075   typedef typename LevelSetContainerType::InputIndexType  LevelSetInputIndexType;
00076   typedef typename LevelSetContainerType::GradientType    LevelSetGradientType;
00077   typedef typename LevelSetContainerType::HessianType     LevelSetHessianType;
00078   typedef typename LevelSetContainerType::LevelSetDataType
00079                                                           LevelSetDataType;
00080 
00081   typedef typename LevelSetContainerType::DomainMapImageFilterType  DomainMapImageFilterType;
00082   typedef typename LevelSetContainerType::CacheImageType            CacheImageType;
00083 
00084   typedef HeavisideStepFunctionBase< LevelSetOutputRealType,
00085                                      LevelSetOutputRealType >
00086                                           HeavisideType;
00087 //  typedef typename HeavisideType::Pointer HeavisidePointer;
00088   typedef typename HeavisideType::ConstPointer HeavisideConstPointer;
00089 
00091   itkSetObjectMacro( Input, InputImageType );
00092   itkGetObjectMacro( Input, InputImageType );
00094 
00095   itkSetMacro( Coefficient, LevelSetOutputRealType );
00096   itkGetMacro( Coefficient, LevelSetOutputRealType );
00097 
00098   itkSetMacro( CurrentLevelSetId, LevelSetIdentifierType );
00099   itkGetMacro( CurrentLevelSetId, LevelSetIdentifierType );
00100 
00101   itkGetObjectMacro( CurrentLevelSetPointer, LevelSetType );
00102 
00103   virtual void SetLevelSetContainer( LevelSetContainerType*ptr );
00104   itkGetObjectMacro( LevelSetContainer, LevelSetContainerType );
00105 
00109   virtual LevelSetOutputRealType Evaluate( const LevelSetInputIndexType& iP );
00110 
00111   virtual LevelSetOutputRealType Evaluate( const LevelSetInputIndexType& iP,
00112                                            const LevelSetDataType& iData );
00113 
00115   virtual void Initialize( const LevelSetInputIndexType& iP ) = 0;
00116 
00118   virtual void InitializeParameters() = 0;
00119 
00121   virtual void UpdatePixel( const LevelSetInputIndexType& iP,
00122                            const LevelSetOutputRealType & oldValue,
00123                            const LevelSetOutputRealType & newValue ) = 0;
00124 
00126   itkGetConstMacro( CFLContribution, LevelSetOutputRealType );
00127 
00129   itkSetStringMacro( TermName );
00130   itkGetStringMacro( TermName );
00132 
00134   virtual void Update() = 0;
00135 
00136   typedef itksys::hash_set< std::string > RequiredDataType;
00137 
00138   const RequiredDataType & GetRequiredData() const;
00139 
00140 protected:
00142   LevelSetEquationTermBase();
00143 
00145   virtual ~LevelSetEquationTermBase();
00146 
00147   void SetUp();
00148 
00153   virtual LevelSetOutputRealType Value( const LevelSetInputIndexType& iP ) = 0;
00154 
00155   virtual LevelSetOutputRealType Value( const LevelSetInputIndexType& iP,
00156                                         const LevelSetDataType& iData ) = 0;
00157 
00159   InputImagePointer        m_Input;
00160 
00162   LevelSetContainerPointer m_LevelSetContainer;
00163 
00165   LevelSetIdentifierType   m_CurrentLevelSetId;
00166 
00167   LevelSetPointer          m_CurrentLevelSetPointer;
00168 
00170   LevelSetOutputRealType   m_Coefficient;
00171 
00175   LevelSetOutputRealType   m_CFLContribution;
00176 
00180   HeavisideConstPointer         m_Heaviside;
00181 
00185   std::string               m_TermName;
00186 
00187   RequiredDataType          m_RequiredData;
00188 
00189 private:
00190   LevelSetEquationTermBase( const Self& ); // purposely not implemented
00191   void operator = ( const Self& ); // purposely not implemented
00192 };
00193 }
00194 
00195 #ifndef ITK_MANUAL_INSTANTIATION
00196 #include "itkLevelSetEquationTermBase.hxx"
00197 #endif
00198 
00199 #endif
00200