ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkFastMarchingBase.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 __itkFastMarchingBase_h
00020 #define __itkFastMarchingBase_h
00021 
00022 #include "itkIntTypes.h"
00023 #include "itkFastMarchingStoppingCriterionBase.h"
00024 #include "itkFastMarchingTraits.h"
00025 
00026 #include <queue>
00027 
00028 namespace itk
00029 {
00100 template< class TInput, class TOutput >
00101 class FastMarchingBase : public FastMarchingTraits<TInput, TOutput>::SuperclassType
00102   {
00103 public:
00104   typedef FastMarchingTraits<TInput, TOutput>   Traits;
00105   typedef typename Traits::SuperclassType       SuperclassType;
00107 
00108   typedef FastMarchingBase            Self;
00109   typedef SuperclassType              Superclass;
00110   typedef SmartPointer< Self >        Pointer;
00111   typedef SmartPointer< const Self >  ConstPointer;
00112 
00114   typedef typename Traits::InputDomainType        InputDomainType;
00115   typedef typename Traits::InputDomainPointer     InputDomainPointer;
00116   typedef typename Traits::InputPixelType         InputPixelType;
00117 
00119   typedef typename Traits::OutputDomainType       OutputDomainType;
00120   typedef typename Traits::OutputDomainPointer    OutputDomainPointer;
00121   typedef typename Traits::OutputPixelType        OutputPixelType;
00122 
00124   typedef typename Traits::NodeType                 NodeType;
00125 
00127   typedef typename Traits::NodePairType             NodePairType;
00128   typedef typename Traits::NodePairContainerType    NodePairContainerType;
00129   typedef typename Traits::NodePairContainerPointer NodePairContainerPointer;
00130   typedef typename Traits::NodePairContainerConstIterator
00131     NodePairContainerConstIterator;
00132 
00133   typedef typename Traits::LabelType                LabelType;
00134 
00136   typedef FastMarchingStoppingCriterionBase< TInput, TOutput > StoppingCriterionType;
00137   typedef typename StoppingCriterionType::Pointer              StoppingCriterionPointer;
00138 
00139   /*
00140   typedef long ElementIdentifier;
00141 
00142   typedef MinPriorityQueueElementWrapper< NodeType,
00143     OutputPixelType,
00144     ElementIdentifier > PriorityQueueElementType;
00145 
00146   typedef PriorityQueueContainer< PriorityQueueElementType,
00147     PriorityQueueElementType,
00148     OutputPixelType,
00149     ElementIdentifier > PriorityQueueType;
00150   typedef typename PriorityQueueType::Pointer PriorityQueuePointer;
00151   */
00152 
00154   enum TopologyCheckType {
00155 
00157     Nothing = 0,
00158 
00160     NoHandles,
00161 
00163     Strict };
00164 
00167   itkSetMacro( TopologyCheck, TopologyCheckType );
00168   itkGetConstReferenceMacro( TopologyCheck, TopologyCheckType );
00170 
00172   itkSetObjectMacro( TrialPoints, NodePairContainerType );
00173   itkGetObjectMacro( TrialPoints, NodePairContainerType );
00175 
00177   itkSetObjectMacro( AlivePoints, NodePairContainerType );
00178   itkGetObjectMacro( AlivePoints, NodePairContainerType );
00180 
00182   itkSetObjectMacro( ProcessedPoints, NodePairContainerType );
00183   itkGetObjectMacro( ProcessedPoints, NodePairContainerType );
00185 
00187   itkSetObjectMacro( ForbiddenPoints, NodePairContainerType );
00188   itkGetObjectMacro( ForbiddenPoints, NodePairContainerType );
00190 
00192   itkGetObjectMacro( StoppingCriterion, StoppingCriterionType );
00193   itkSetObjectMacro( StoppingCriterion, StoppingCriterionType );
00194 
00196   itkGetMacro( SpeedConstant, double );
00197   itkSetMacro( SpeedConstant, double );
00198 
00200   itkGetMacro( NormalizationFactor, double );
00201   itkSetMacro( NormalizationFactor, double );
00202 
00204   itkGetMacro( TargetReachedValue, OutputPixelType );
00205 
00210   itkSetMacro(CollectPoints, bool);
00211 
00213   itkGetConstReferenceMacro(CollectPoints, bool);
00214   itkBooleanMacro(CollectPoints);
00216 
00217 
00218 protected:
00219 
00221   FastMarchingBase();
00222 
00224   virtual ~FastMarchingBase();
00225 
00226   StoppingCriterionPointer m_StoppingCriterion;
00227 
00228   double m_SpeedConstant;
00229   double m_InverseSpeed;
00230   double m_NormalizationFactor;
00231 
00232   OutputPixelType m_TargetReachedValue;
00233   OutputPixelType m_LargeValue;
00234   OutputPixelType m_TopologyValue;
00235 
00236   NodePairContainerPointer  m_TrialPoints;
00237   NodePairContainerPointer  m_AlivePoints;
00238   NodePairContainerPointer  m_ProcessedPoints;
00239   NodePairContainerPointer  m_ForbiddenPoints;
00240 
00241   bool m_CollectPoints;
00242 
00243   //PriorityQueuePointer m_Heap;
00244   typedef std::vector< NodePairType >   HeapContainerType;
00245   typedef std::greater< NodePairType >  NodeComparerType;
00246 
00247   typedef std::priority_queue<
00248     NodeType,
00249     HeapContainerType,
00250     NodeComparerType >
00251     PriorityQueueType;
00252 
00253   PriorityQueueType m_Heap;
00254 
00255   TopologyCheckType m_TopologyCheck;
00256 
00258   virtual IdentifierType GetTotalNumberOfNodes() const = 0;
00259 
00261   virtual const OutputPixelType GetOutputValue( OutputDomainType* oDomain,
00262                                          const NodeType& iNode ) const = 0;
00263 
00265   virtual void SetOutputValue( OutputDomainType* oDomain,
00266                               const NodeType& iNode,
00267                               const OutputPixelType& iValue ) = 0;
00268 
00272   virtual unsigned char
00273   GetLabelValueForGivenNode( const NodeType& iNode ) const = 0;
00274 
00278   virtual void SetLabelValueForGivenNode( const NodeType& iNode,
00279                                          const LabelType& iLabel ) = 0;
00280 
00285   virtual void UpdateNeighbors( OutputDomainType* oDomain,
00286                                const NodeType& iNode ) = 0;
00287 
00292   virtual void UpdateValue( OutputDomainType* oDomain,
00293                            const NodeType& iNode ) = 0;
00294 
00299   virtual bool CheckTopology( OutputDomainType* oDomain,
00300                              const NodeType& iNode ) = 0;
00301 
00303   void Initialize( OutputDomainType* oDomain );
00304 
00306   virtual void InitializeOutput( OutputDomainType* oDomain ) = 0;
00307 
00309   void GenerateData();
00310 
00312   void PrintSelf(std::ostream & os, Indent indent) const;
00313 
00314 private:
00315   FastMarchingBase( const Self& );
00316   void operator = ( const Self& );
00317   };
00318 }
00319 
00320 #include "itkFastMarchingBase.hxx"
00321 #endif
00322