00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 }
00146
00147 #endif