ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkFastMarchingStoppingCriterionBase.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 __itkFastMarchingStoppingCriterionBase_h
00020 #define __itkFastMarchingStoppingCriterionBase_h
00021 
00022 #include "itkStoppingCriterionBase.h"
00023 #include "itkNumericTraits.h"
00024 #include "itkFastMarchingTraits.h"
00025 
00026 namespace itk
00027 {
00028 
00034 template< class TInput, class TOutput >
00035 class FastMarchingStoppingCriterionBase : public StoppingCriterionBase
00036 {
00037 public:
00038   typedef FastMarchingStoppingCriterionBase      Self;
00039   typedef StoppingCriterionBase                  Superclass;
00040   typedef SmartPointer< Self >                   Pointer;
00041   typedef SmartPointer< const Self >             ConstPointer;
00042   typedef FastMarchingTraits< TInput, TOutput >  Traits;
00043 
00044   typedef typename Traits::NodeType            NodeType;
00045   typedef typename Traits::OutputPixelType     OutputPixelType;
00046   typedef typename Traits::NodePairType        NodePairType;
00047   typedef typename Traits::OutputDomainType    OutputDomainType;
00048   typedef typename Traits::OutputDomainPointer OutputDomainPointer;
00049 
00051   itkTypeMacro(FastMarchingStoppingCriterionBase, StoppingCriterionBase);
00052 
00054   void Reinitialize()
00055     {
00056     m_CurrentValue  = NumericTraits< OutputPixelType >::Zero;
00057     m_PreviousValue = NumericTraits< OutputPixelType >::Zero;
00058 
00059     this->Reset();
00060     }
00061 
00062   void SetCurrentNodePair( const NodePairType& iNodePair )
00063     {
00064     this->SetCurrentNode( iNodePair.GetNode() );
00065     this->SetCurrentValue( iNodePair.GetValue() );
00066     }
00067 
00068   itkSetObjectMacro( Domain, OutputDomainType );
00069   itkGetObjectMacro( Domain, OutputDomainType );
00070 
00071  protected:
00073   FastMarchingStoppingCriterionBase() : Superclass(), m_Domain( NULL )
00074   {
00075     m_CurrentValue = NumericTraits< OutputPixelType >::Zero;
00076     m_PreviousValue = NumericTraits< OutputPixelType >::Zero;
00077   }
00078 
00080   virtual ~FastMarchingStoppingCriterionBase() {}
00081 
00082   OutputDomainPointer m_Domain;
00083 
00084   OutputPixelType m_PreviousValue;
00085   OutputPixelType m_CurrentValue;
00086 
00089   virtual void Reset() = 0;
00090 
00092   virtual void SetCurrentNode( const NodeType& iNode ) = 0;
00093 
00095   virtual void SetCurrentValue( const OutputPixelType& iValue )
00096     {
00097     m_PreviousValue = m_CurrentValue;
00098     m_CurrentValue = iValue;
00099     }
00100 
00101 private:
00102   FastMarchingStoppingCriterionBase( const Self& );
00103   void operator = ( const Self& );
00104 };
00105 }
00106 #endif
00107