freParameterLayer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freParameterLayer.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #ifndef __freParameterLayer_h
00023 #define __freParameterLayer_h
00024 
00025 #include "freElementals.h"
00026 #include "freXMLValueSet.h"
00027 #include "freExceptions.h"
00028 #include "freConvert.h"
00029 
00030 #include "itkLightObject.h"
00031 
00032 namespace FREE
00033 {
00034 
00045   class ParameterLayer: public XMLValueSet, public itk::LightObject
00046 {
00047 public:
00048   typedef ParameterLayer  Self;
00049   typedef itk::LightObject Superclass;
00050   typedef itk::SmartPointer<Self>        Pointer;
00051   typedef itk::SmartPointer<const Self>  ConstPointer;
00052   
00054   itkTypeMacro( ParameterLayer, XMLValueSet );
00055 
00056   itkNewMacro(ParameterLayer);
00057 
00060   static Pointer New(const ValueCountType iValueCount, const std::string& sNewValue = "");
00061 
00063   virtual ParameterLayer& operator = (const ParameterLayer& parameterLayer);
00064 
00065 protected:
00067   ParameterLayer(const ValueCountType iValueCount, const std::string& sNewValue = "");
00068 
00070   ParameterLayer();
00071 };
00072 
00073 namespace Convert
00074 {
00075 
00081   template< class TFixedArray> static TFixedArray ParameterLayerToFixedArray(const ::FREE::ParameterLayer& rLayer)
00082   {
00083     TFixedArray newArray;
00084                 if (newArray.Size()!=rLayer.Size()) throwStaticExceptionMacro("Dimension of fixed array and size of parameter layer differ. Fixed array dim: " << Convert::ToStr(newArray.Size()) << "; layer dim: " << Convert::ToStr(rLayer.Size()));
00085 
00086     typename TFixedArray::ValueType value;
00087                 for (int i=0; i<newArray.Size(); i++)
00088     {
00089       rLayer.GetValue(value,i);
00090       newArray[i]=value;
00091     }
00092 
00093                 return newArray;
00094   };
00095 
00102   template< class TFixedArray> static void FixedArrayToParameterLayer(const TFixedArray& rArray, ::FREE::ParameterLayer& rLayer)
00103   {
00104                 if (rArray.Size()!=rLayer.Size()) throwStaticExceptionMacro("Dimension of fixed array and size of parameter layer differ. Fixed array dim: " << Convert::ToStr(rArray.Size()) << "; layer dim: " << Convert::ToStr(rLayer.Size()));
00105 
00106                 for (int i=0; i<rArray.Size(); i++)
00107     {
00108       rLayer.SetValue(rArray[i],i);
00109     }
00110   };
00111 
00115   template< class TArray> static TArray ParameterLayerToArray(const ::FREE::ParameterLayer& rLayer)
00116   {
00117     TArray newArray(rLayer.Size());
00118 
00119     typename TArray::ValueType value;
00120                 for (int i=0; i<newArray.Size(); i++)
00121     {
00122       rLayer.GetValue(value,i);
00123       newArray[i]=value;
00124     }
00125 
00126                 return newArray;
00127   };
00128 
00133   template< class TArray> static void ArrayToParameterLayer(const TArray& rArray, ::FREE::ParameterLayer& rLayer)
00134   {
00135                 rLayer.Resize(rArray.Size());
00136 
00137                 for (int i=0; i<rArray.Size(); i++)
00138     {
00139       rLayer.SetValue(rArray[i],i);
00140     }
00141   };
00142 
00143 }
00144 
00145 }//end of namespace FREE
00146 
00147 #endif

Generated at Sat Oct 13 16:56:02 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000