cmtkAffineMultiChannelRegistrationFunctional.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2010 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2011 SRI International
00006 //
00007 //  This file is part of the Computational Morphometry Toolkit.
00008 //
00009 //  http://www.nitrc.org/projects/cmtk/
00010 //
00011 //  The Computational Morphometry Toolkit is free software: you can
00012 //  redistribute it and/or modify it under the terms of the GNU General Public
00013 //  License as published by the Free Software Foundation, either version 3 of
00014 //  the License, or (at your option) any later version.
00015 //
00016 //  The Computational Morphometry Toolkit is distributed in the hope that it
00017 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //  GNU General Public License for more details.
00020 //
00021 //  You should have received a copy of the GNU General Public License along
00022 //  with the Computational Morphometry Toolkit.  If not, see
00023 //  <http://www.gnu.org/licenses/>.
00024 //
00025 //  $Revision: 2752 $
00026 //
00027 //  $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #ifndef __cmtkAffineMultiChannelRegistrationFunctional_h_included_
00034 #define __cmtkAffineMultiChannelRegistrationFunctional_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Registration/cmtkTemplateMultiChannelRegistrationFunctional.h>
00039 
00040 #include <Base/cmtkAffineXform.h>
00041 #include <Base/cmtkVolumeClipping.h>
00042 #include <Base/cmtkTransformedVolumeAxes.h>
00043 
00044 #include <System/cmtkThreads.h>
00045 #include <System/cmtkMutexLock.h>
00046 
00047 namespace
00048 cmtk
00049 {
00050 
00053 
00055 template<class MetricFunctionalClass> 
00056 class SplineWarpMultiChannelRegistrationFunctional;
00057 
00059 template<class TMultiChannelMetricFunctional>
00060 class AffineMultiChannelRegistrationFunctional :
00062   public TemplateMultiChannelRegistrationFunctional<AffineXform,TMultiChannelMetricFunctional>
00063 {
00064 public:
00066   typedef AffineMultiChannelRegistrationFunctional<TMultiChannelMetricFunctional> Self;
00067 
00069   typedef SmartPointer<Self> SmartPtr;
00070 
00072   typedef TemplateMultiChannelRegistrationFunctional<AffineXform,TMultiChannelMetricFunctional> Superclass;
00073   
00075   AffineMultiChannelRegistrationFunctional()
00076     : m_NumberOfThreads( Threads::GetNumberOfThreads() )
00077   {
00078   }
00079 
00081   void InitTransformation( const bool alignCenters );
00082 
00095   virtual typename Self::ReturnType Evaluate();
00096 
00097 private:
00099   VolumeClipping m_VolumeClipper;
00100 
00117   bool ClipZ ( const VolumeClipping& clipper, const Vector3D& origin, int& start, int& end ) const;
00118     
00145   bool ClipX( const VolumeClipping& clipper, const Vector3D& origin, int& start, int &end ) const;
00146 
00163   bool ClipY( const VolumeClipping& clipper, const Vector3D& origin, int& start, int& end ) const;
00164 
00166   const size_t m_NumberOfThreads;
00167 
00169   class EvaluateThreadParameters : 
00171     public ThreadParameters<Self>
00172   {
00173   public:
00175     const TransformedVolumeAxes* m_TransformedAxes;
00176 
00178     int m_StartZ;
00179 
00181     int m_EndZ;
00182   };
00183 
00185   static void EvaluateThreadFunction( void* args, const size_t taskIdx, const size_t taskCnt, const size_t threadIdx, const size_t );
00186 
00187 #ifdef CMTK_BUILD_SMP
00188 
00189   MutexLock m_MetricDataMutex;
00190 #endif
00191 
00193   template<class MetricFunctionalClass> friend class SplineWarpMultiChannelRegistrationFunctional;
00194 };
00195 
00197 
00198 } // namespace cmtk
00199 
00200 #include "cmtkAffineMultiChannelRegistrationFunctional.txx"
00201 
00202 #endif // #ifndef __cmtkAffineMultiChannelRegistrationFunctional_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines