00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "freTransformSetupAdaptor.h"
00023
00024 #include "freConvert.h"
00025
00026 namespace FREE
00027 {
00028
00032
00033
00034 void
00035 TransformSetupAdaptor::
00036 SetInitialTransformParameters(ParameterArrayType initialParameters)
00037 {
00038 if (!(m_pComponent->Parameters().ParameterExists(cParam_InitialTransformValues))) throwExceptionMacro("No initial transform parameter found, ensure that the transform setup is build properly.");
00039
00040 for (int iIndex=0; iIndex<m_pComponent->Parameters().ParameterSize(cParam_InitialTransformValues); iIndex++)
00041 {
00042 m_pComponent->Parameters().SetParameterValue(cParam_InitialTransformValues,initialParameters.GetElement(iIndex),iIndex);
00043 };
00044 };
00045
00046 ParameterArrayType
00047 TransformSetupAdaptor::
00048 GetInitialTransformParameters() const
00049 {
00050 if (!(m_pComponent->Parameters().ParameterExists(cParam_InitialTransformValues))) throwExceptionMacro("No initial transform parameter found, ensure that the transform setup is build properly.");
00051
00052 ParameterArrayType values(m_pComponent->Parameters().ParameterSize(cParam_InitialTransformValues));
00053
00054 for (int iIndex=0; iIndex<m_pComponent->Parameters().ParameterSize(cParam_InitialTransformValues); iIndex++)
00055 {
00056 ScalarType newValue = 0.0;
00057 m_pComponent->Parameters().GetParameterValue(cParam_InitialTransformValues,newValue,iIndex);
00058 values.SetElement(iIndex,newValue);
00059 };
00060
00061 return values;
00062 };
00063
00064 void
00065 TransformSetupAdaptor::
00066 SetCurrentTransformParameters(const ParameterArrayType& currentParameters)
00067 {
00068 if (!(m_pComponent->Parameters().ParameterExists(cParam_CurrentTransformValues))) throwExceptionMacro("No initial transform parameter found, ensure that the transform setup is build properly.");
00069
00070 for (int iIndex=0; iIndex<m_pComponent->Parameters().ParameterSize(cParam_CurrentTransformValues); iIndex++)
00071 {
00072 m_pComponent->Parameters().SetParameterValue(cParam_CurrentTransformValues,currentParameters.GetElement(iIndex),iIndex);
00073 };
00074 };
00075
00076 ParameterArrayType
00077 TransformSetupAdaptor::
00078 GetCurrentTransformParameters() const
00079 {
00080 if (!(m_pComponent->Parameters().ParameterExists(cParam_CurrentTransformValues))) throwExceptionMacro("No initial transform parameter found, ensure that the transform setup is build properly.");
00081
00082 ParameterArrayType values(m_pComponent->Parameters().ParameterSize(cParam_CurrentTransformValues));
00083
00084 for (int iIndex=0; iIndex<m_pComponent->Parameters().ParameterSize(cParam_CurrentTransformValues); iIndex++)
00085 {
00086 ScalarType newValue = 0.0;
00087 m_pComponent->Parameters().GetParameterValue(cParam_CurrentTransformValues,newValue,iIndex);
00088 values.SetElement(iIndex,newValue);
00089 };
00090
00091 return values;
00092 };
00093
00094 void
00095 TransformSetupAdaptor::
00096 SetScales(ParameterArrayType newScales)
00097 {
00098 if (!(m_pComponent->Parameters().ParameterExists(cParam_TransformScale))) throwExceptionMacro("No transform scale parameter found, ensure that the transform setup is build properly.");
00099
00100 for (int iIndex=0; iIndex<m_pComponent->Parameters().ParameterSize(cParam_TransformScale); iIndex++)
00101 {
00102 m_pComponent->Parameters().SetParameterValue(cParam_TransformScale,newScales.GetElement(iIndex),iIndex);
00103 };
00104 };
00105
00106 ParameterArrayType
00107 TransformSetupAdaptor::
00108 GetScales(const int iLevel) const
00109 {
00110 if (!(m_pComponent->Parameters().ParameterExists(cParam_TransformScale))) throwExceptionMacro("No transform scale parameter found, ensure that the transform setup is build properly.");
00111
00112 Parameter* pParameter = m_pComponent->Parameters().GetParameter(cParam_TransformScale);
00113
00114 ParameterArrayType values(pParameter->ParameterSize());
00115
00116 int iSelectedLevel = iLevel;
00117 if (iLevel > pParameter->LayerCount() -1)
00118 {
00119 iSelectedLevel = pParameter->LayerCount() - 1;
00120 std::cout<<"Warning: Scale level "<< iLevel << "does not exist. Used level" << iSelectedLevel << "instead.";
00121 }
00122
00123 for (int iIndex=0; iIndex<m_pComponent->Parameters().ParameterSize(cParam_TransformScale); iIndex++)
00124 {
00125 ScalarType newScale = 0.0;
00126 m_pComponent->Parameters().GetParameterValue(cParam_TransformScale,newScale,iIndex,iSelectedLevel);
00127 values.SetElement(iIndex,newScale);
00128 };
00129
00130 return values;
00131 };
00132
00133 ComponentSetup*
00134 TransformSetupAdaptor::
00135 Adapt(ComponentSetup* pComponent)
00136 {
00137 ComponentAdaptorBase::Adapt(pComponent);
00138
00139 m_pComponent->Parameters().AddParameter(cParam_InitialTransformValues);
00140 m_pComponent->Parameters().AddParameter(cParam_TransformScale);
00141 m_pComponent->Parameters().AddParameter(cParam_InitialisationMethod);
00142
00143 return m_pComponent;
00144 };
00145
00146 TransformSetupAdaptor::
00147 TransformSetupAdaptor(ComponentSetup* pComponent) : ComponentAdaptorBase(pComponent)
00148 {
00149 };
00150
00151 TransformSetupAdaptor::
00152 ~TransformSetupAdaptor()
00153 {};
00154
00155 }