ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkPointSetToPointSetMetricv4.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 __itkPointSetToPointSetMetricv4_h
00019 #define __itkPointSetToPointSetMetricv4_h
00020 
00021 #include "itkObjectToObjectMetric.h"
00022 
00023 #include "itkFixedArray.h"
00024 #include "itkPointsLocator.h"
00025 #include "itkPointSet.h"
00026 
00027 namespace itk
00028 {
00044 template<class TFixedPointSet,  class TMovingPointSet>
00045 class ITK_EXPORT PointSetToPointSetMetricv4
00046 : public ObjectToObjectMetric<TFixedPointSet::PointDimension, TMovingPointSet::PointDimension>
00047 {
00048 public:
00049 
00051   typedef PointSetToPointSetMetricv4                                                            Self;
00052   typedef ObjectToObjectMetric<TFixedPointSet::PointDimension, TMovingPointSet::PointDimension> Superclass;
00053   typedef SmartPointer<Self>                                                                    Pointer;
00054   typedef SmartPointer<const Self>                                                              ConstPointer;
00055 
00057   itkTypeMacro( PointSetToPointSetMetricv4, ObjectToObjectMetric );
00058 
00060   typedef typename Superclass::MeasureType            MeasureType;
00061 
00063   typedef typename Superclass::ParametersType         ParametersType;
00064   typedef typename Superclass::ParametersValueType    ParametersValueType;
00065   typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
00066 
00068   typedef typename Superclass::DerivativeType         DerivativeType;
00069 
00071   typedef typename Superclass::FixedTransformType            FixedTransformType;
00072   typedef typename Superclass::FixedTransformPointer         FixedTransformPointer;
00073   typedef typename Superclass::FixedInputPointType           FixedInputPointType;
00074   typedef typename Superclass::FixedOutputPointType          FixedOutputPointType;
00075   typedef typename Superclass::FixedTransformParametersType  FixedTransformParametersType;
00076 
00077   typedef typename Superclass::MovingTransformType            MovingTransformType;
00078   typedef typename Superclass::MovingTransformPointer         MovingTransformPointer;
00079   typedef typename Superclass::MovingInputPointType           MovingInputPointType;
00080   typedef typename Superclass::MovingOutputPointType          MovingOutputPointType;
00081   typedef typename Superclass::MovingTransformParametersType  MovingTransformParametersType;
00082 
00083   typedef typename Superclass::JacobianType                   JacobianType;
00084   typedef typename Superclass::FixedTransformJacobianType     FixedTransformJacobianType;
00085   typedef typename Superclass::MovingTransformJacobianType    MovingTransformJacobianType;
00086 
00088   typedef typename Superclass::DimensionType                  DimensionType;
00089 
00091   typedef TFixedPointSet                               FixedPointSetType;
00092   typedef typename TFixedPointSet::PointType           FixedPointType;
00093   typedef typename TFixedPointSet::PixelType           FixedPixelType;
00094   typedef typename TFixedPointSet::PointsContainer     FixedPointsContainer;
00095 
00096   itkStaticConstMacro( FixedPointDimension, DimensionType, Superclass::FixedDimension );
00097 
00099   typedef TMovingPointSet                              MovingPointSetType;
00100   typedef typename TMovingPointSet::PointType          MovingPointType;
00101   typedef typename TMovingPointSet::PixelType          MovingPixelType;
00102   typedef typename TMovingPointSet::PointsContainer    MovingPointsContainer;
00103 
00104   itkStaticConstMacro( MovingPointDimension, DimensionType, Superclass::MovingDimension );
00105 
00112   itkStaticConstMacro( PointDimension, DimensionType, Superclass::FixedDimension );
00113 
00114   typedef FixedPointType                               PointType;
00115   typedef typename PointType::CoordRepType             CoordRepType;
00116   typedef FixedPointsContainer                         PointsContainer;
00117   typedef typename PointsContainer::ConstIterator      PointsConstIterator;
00118   typedef typename PointsContainer::ElementIdentifier  PointIdentifier;
00119 
00121   typedef PointsLocator<PointIdentifier, itkGetStaticConstMacro( PointDimension ), CoordRepType, PointsContainer> PointsLocatorType;
00122   typedef typename PointsLocatorType::NeighborsIdentifierType    NeighborsIdentifierType;
00123 
00124   typedef PointSet<FixedPixelType, itkGetStaticConstMacro( PointDimension )>    FixedTransformedPointSetType;
00125   typedef PointSet<MovingPixelType, itkGetStaticConstMacro( PointDimension )>   MovingTransformedPointSetType;
00126 
00127   typedef typename DerivativeType::ValueType                                          DerivativeValueType;
00128   typedef FixedArray<DerivativeValueType, itkGetStaticConstMacro( PointDimension )>   LocalDerivativeType;
00129 
00131   itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
00132 
00134   itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
00135 
00137   itkGetConstObjectMacro( FixedTransformedPointSet, FixedTransformedPointSetType );
00138 
00140   itkSetObjectMacro( MovingPointSet, MovingPointSetType );
00141 
00143   itkGetConstObjectMacro( MovingPointSet, MovingPointSetType );
00144 
00146   itkGetConstObjectMacro( MovingTransformedPointSet, MovingTransformedPointSetType );
00147 
00151   SizeValueType GetNumberOfComponents() const;
00152 
00163   virtual MeasureType GetValue() const;
00164 
00175   virtual void GetDerivative( DerivativeType & ) const;
00176 
00187   virtual void GetValueAndDerivative( MeasureType &, DerivativeType & ) const;
00188 
00193   virtual MeasureType GetLocalNeighborhoodValue( const PointType & ) const = 0;
00194 
00198   virtual LocalDerivativeType GetLocalNeighborhoodDerivative( const PointType & ) const;
00199 
00203   virtual void GetLocalNeighborhoodValueAndDerivative( const PointType &,
00204     MeasureType &, LocalDerivativeType & ) const = 0;
00205 
00210   virtual void Initialize( void ) throw ( ExceptionObject );
00211 
00212 protected:
00213   PointSetToPointSetMetricv4();
00214   virtual ~PointSetToPointSetMetricv4();
00215   void PrintSelf( std::ostream & os, Indent indent ) const;
00216 
00217   typename FixedPointSetType::ConstPointer                m_FixedPointSet;
00218   mutable typename FixedTransformedPointSetType::Pointer  m_FixedTransformedPointSet;
00219 
00220   mutable typename PointsLocatorType::Pointer             m_FixedTransformedPointsLocator;
00221 
00222   typename MovingPointSetType::ConstPointer               m_MovingPointSet;
00223   mutable typename MovingTransformedPointSetType::Pointer m_MovingTransformedPointSet;
00224 
00225   mutable typename PointsLocatorType::Pointer             m_MovingTransformedPointsLocator;
00226 
00231   virtual void InitializeForIteration( void ) const;
00232 
00235   void CalculateValueAndDerivative( MeasureType & value, DerivativeType & derivative, bool calculateValue ) const;
00236 
00242   void TransformFixedPointSet() const;
00243 
00249   void TransformMovingPointSet() const;
00250 
00255   void InitializePointsLocators() const;
00256 
00257 private:
00258   PointSetToPointSetMetricv4( const Self & ); //purposely not implemented
00259   void operator=( const Self & );           //purposely not implemented
00260 
00261   mutable bool m_MovingTransformPointLocatorsNeedInitialization;
00262   mutable bool m_FixedTransformPointLocatorsNeedInitialization;
00263 };
00264 } // end namespace itk
00265 
00266 #ifndef ITK_MANUAL_INSTANTIATION
00267 #include "itkPointSetToPointSetMetricv4.hxx"
00268 #endif
00269 
00270 #endif
00271