ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLevelSetNeighborhoodExtractor.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 __itkLevelSetNeighborhoodExtractor_h
00019 #define __itkLevelSetNeighborhoodExtractor_h
00020 
00021 #include "itkLightProcessObject.h"
00022 #include "itkLevelSet.h"
00023 #include "itkIndex.h"
00024 
00025 namespace itk
00026 {
00056 template< class TLevelSet >
00057 class ITK_EXPORT LevelSetNeighborhoodExtractor:
00058   public LightProcessObject
00059 {
00060 public:
00062   typedef LevelSetNeighborhoodExtractor Self;
00063   typedef LightProcessObject            Superclass;
00064   typedef SmartPointer< Self >          Pointer;
00065   typedef SmartPointer< const Self >    ConstPointer;
00066 
00068   itkNewMacro(Self);
00069 
00071   itkTypeMacro(LevelSetNeighborhoodExtractor, Object);
00072 
00074   typedef LevelSetTypeDefault< TLevelSet >            LevelSetType;
00075   typedef typename LevelSetType::LevelSetImageType    LevelSetImageType;
00076   typedef typename LevelSetType::LevelSetPointer      LevelSetPointer;
00077   typedef typename LevelSetType::LevelSetConstPointer LevelSetConstPointer;
00078   typedef typename LevelSetType::PixelType            PixelType;
00079   typedef typename LevelSetType::NodeType             NodeType;
00080   typedef typename LevelSetType::NodeContainer        NodeContainer;
00081   typedef typename LevelSetType::NodeContainerPointer NodeContainerPointer;
00082 
00084   itkStaticConstMacro(SetDimension, unsigned int,
00085                       LevelSetType::SetDimension);
00086 
00088   typedef Index< itkGetStaticConstMacro(SetDimension) > IndexType;
00089 
00091   itkSetConstObjectMacro(InputLevelSet, LevelSetImageType);
00092 
00094   itkGetConstObjectMacro(InputLevelSet, LevelSetImageType);
00095 
00097   itkSetMacro(LevelSetValue, double);
00098 
00100   itkGetConstMacro(LevelSetValue, double);
00101 
00103   itkSetClampMacro( NarrowBandwidth, double, 0.0,
00104                     NumericTraits< double >::max() );
00105 
00107   itkGetConstMacro(NarrowBandwidth, double);
00108 
00110   itkSetMacro(NarrowBanding, bool);
00111 
00113   itkGetConstMacro(NarrowBanding, bool);
00114   itkBooleanMacro(NarrowBanding);
00116 
00119   void SetInputNarrowBand(NodeContainer *ptr);
00120 
00121   itkGetObjectMacro(InputNarrowBand, NodeContainer);
00122 
00125   NodeContainerPointer GetInsidePoints()
00126   { return m_InsidePoints; }
00127 
00130   NodeContainerPointer GetOutsidePoints(void)
00131   { return m_OutsidePoints; }
00132 
00135   void Locate();
00136 
00137 protected:
00138   LevelSetNeighborhoodExtractor();
00139   ~LevelSetNeighborhoodExtractor(){}
00140   void PrintSelf(std::ostream & os, Indent indent) const;
00141 
00142   typename LevelSetImageType::PixelType GetLargeValue() const
00143   { return m_LargeValue; }
00144 
00145   const NodeType & GetNodeUsedInCalculation(unsigned int idx) const
00146   { return m_NodesUsed[idx]; }
00147 
00148   virtual void Initialize();
00149 
00150   virtual double CalculateDistance(IndexType & index);
00151 
00152   void GenerateData();
00153 
00154   bool GetLastPointIsInside() const
00155   { return m_LastPointIsInside; }
00156 private:
00157   LevelSetNeighborhoodExtractor(const Self &); //purposely not implemented
00158   void operator=(const Self &);                //purposely not implemented
00159 
00160   void      GenerateDataFull();
00161 
00162   void      GenerateDataNarrowBand();
00163 
00164   double m_LevelSetValue;
00165 
00166   NodeContainerPointer m_InsidePoints;
00167   NodeContainerPointer m_OutsidePoints;
00168 
00169   LevelSetConstPointer m_InputLevelSet;
00170 
00171   bool                 m_NarrowBanding;
00172   double               m_NarrowBandwidth;
00173   NodeContainerPointer m_InputNarrowBand;
00174 
00175   SizeValueType m_ImageSize[SetDimension];
00176   typename LevelSetImageType::PixelType m_LargeValue;
00177 
00178   std::vector< NodeType > m_NodesUsed;
00179 
00180   bool m_LastPointIsInside;
00181 };
00182 } // namespace itk
00183 
00184 #ifndef ITK_MANUAL_INSTANTIATION
00185 #include "itkLevelSetNeighborhoodExtractor.hxx"
00186 #endif
00187 
00188 #endif
00189