cmtkSplineWarpGroupwiseRegistrationRMIFunctional.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2010 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: 2398 $
00026 //
00027 //  $LastChangedDate: 2010-10-05 14:54:37 -0700 (Tue, 05 Oct 2010) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #ifndef __cmtkSplineWarpGroupwiseRegistrationRMIFunctional_h_included_
00034 #define __cmtkSplineWarpGroupwiseRegistrationRMIFunctional_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Registration/cmtkGroupwiseRegistrationRMIFunctional.h>
00039 
00040 #include <System/cmtkSmartPtr.h>
00041 #include <System/cmtkThreads.h>
00042 
00043 #include <Base/cmtkUniformVolume.h>
00044 #include <Base/cmtkSplineWarpXform.h>
00045 #include <Base/cmtkHistogram.h>
00046 
00047 #include <IO/cmtkClassStream.h>
00048 
00049 #include <vector>
00050 
00051 namespace
00052 cmtk
00053 {
00054 
00057 
00060 class SplineWarpGroupwiseRegistrationRMIFunctional : 
00061   public GroupwiseRegistrationRMIFunctional<SplineWarpXform>
00062 {
00063 public:
00065   typedef GroupwiseRegistrationRMIFunctional<SplineWarpXform> Superclass;
00066 
00068   typedef SplineWarpGroupwiseRegistrationRMIFunctional Self;
00069 
00071   typedef SmartPointer<Self> SmartPtr;
00072 
00074   SplineWarpGroupwiseRegistrationRMIFunctional() : 
00075     m_NeedsUpdateInformationByControlPoint( false ),  
00076     m_ControlPointScheduleOverlapFreeMaxLength( 0 ) 
00077   {}
00078 
00080   virtual Self::ReturnType Evaluate();
00081 
00083   virtual Self::ReturnType EvaluateAt( CoordinateVector& v )
00084   {
00085     return this->Superclass::EvaluateAt( v );
00086   }
00087 
00095   virtual Self::ReturnType EvaluateWithGradient( CoordinateVector& v, CoordinateVector& g, const Types::Coordinate step = 1 );
00096 
00097 private:
00099   virtual void UpdateActiveControlPoints();
00100   
00102   std::vector<byte> m_InformationByControlPoint;
00103 
00105   bool m_NeedsUpdateInformationByControlPoint;
00106 
00108   virtual void UpdateInformationByControlPoint();
00109 
00111   virtual void UpdateControlPointSchedule();
00112 
00114   std::vector<int> m_ControlPointSchedule;
00115 
00117   size_t m_ControlPointScheduleOverlapFreeMaxLength;
00118 
00120   class EvaluateLocalGradientThreadParameters : 
00122     public ThreadParameters<Self>
00123   {
00124   public:
00126     size_t m_ThreadStorageIndex;
00127 
00129     Types::Coordinate m_Step;
00130 
00132     Types::Coordinate* m_Gradient;
00133     
00135     Self::ReturnType m_MetricBaseValue;
00136 
00137 #ifdef CMTK_BUILD_MPI
00138 
00139     size_t m_FirstIndexToCompute;
00140 #endif
00141   };
00142 
00148   static CMTK_THREAD_RETURN_TYPE EvaluateLocalGradientThreadFunc( void* args );
00149 
00150 #ifdef CMTK_BUILD_MPI
00151   void ReorderGradientComponents( Types::Coordinate *const dst, const Types::Coordinate* src, const size_t fromCpIdx, const size_t toCpIdx );
00152 #endif
00153 };
00154 
00156 
00157 } // namespace cmtk
00158 
00159 #endif // #ifndef __cmtkSplineWarpGroupwiseRegistrationRMIFunctional_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines