Commit b267e309 authored by Jonathan Guinet's avatar Jonathan Guinet
Browse files

ENH: prosail parameters class refactoring.

parent 10b685ae
......@@ -78,8 +78,8 @@ public:
itkTypeMacro(LabelToProSailParameters, LabelToSimulationParametersBase);
itkNewMacro(Self);
virtual const ParametersType & GetStep1Parameters();
virtual const ParametersType & GetStep2Parameters();
// virtual const ParametersType & GetStep1Parameters();
//virtual const ParametersType & GetStep2Parameters();
virtual void GenerateData();
......
......@@ -29,23 +29,48 @@ template <class TLabel>
LabelToProSailParameters<TLabel>
::LabelToProSailParameters()
{
//default parameters
ParametersType Step1Parameters;
ParametersType Step2Parameters;
Step1Parameters.SetSize(6);
Step2Parameters.SetSize(8);
Step1Parameters[0] = 30.0;
Step1Parameters[1] = 10.0;
Step1Parameters[2] = 0.0;
Step1Parameters[3] = 0.015;
Step1Parameters[4] = 0.009;
Step1Parameters[5] = 1.2;
Step2Parameters[0] = 2;
Step2Parameters[1] = 50;
Step2Parameters[2] = 1;
Step2Parameters[3] = 70;
Step2Parameters[4] = 0.2;
Step2Parameters[5] = 30;
Step2Parameters[6] = 0;
Step2Parameters[7] = 0;
this->SetStep1Parameters(Step1Parameters);
this->SetStep2Parameters(Step2Parameters);
}
template <class TLabel>
const typename LabelToProSailParameters<TLabel>::ParametersType &
LabelToProSailParameters<TLabel>
::GetStep1Parameters()
{
return this->m_Step1Parameters;
}
//template <class TLabel>
//const typename LabelToProSailParameters<TLabel>::ParametersType &
//LabelToProSailParameters<TLabel>
//::GetStep1Parameters()
//{
// return this->m_Step1Parameters;
//}
template <class TLabel>
const typename LabelToProSailParameters<TLabel>::ParametersType &
LabelToProSailParameters<TLabel>
::GetStep2Parameters()
{
return this->m_Step2Parameters;
}
//template <class TLabel>
//const typename LabelToProSailParameters<TLabel>::ParametersType &
//LabelToProSailParameters<TLabel>
//::GetStep2Parameters()
//{
// return this->m_Step2Parameters;
//}
template <class TLabel>
......@@ -55,26 +80,9 @@ LabelToProSailParameters<TLabel>
{
//int value = 0;
// this->m_Label;
this->m_Step1Parameters.SetSize(6);
this->m_Step2Parameters.SetSize(8);
//TODO accessor must be implemented in otbLabelToSimulationParametersBase
// and default values need to migrate to class constructor.
this->m_Step1Parameters[0] = 30.0;
this->m_Step1Parameters[1] = 10.0;
this->m_Step1Parameters[2] = 0.0;
this->m_Step1Parameters[3] = 0.015;
this->m_Step1Parameters[4] = 0.009;
this->m_Step1Parameters[5] = 1.2;
this->m_Step2Parameters[0] = 2;
this->m_Step2Parameters[1] = 50;
this->m_Step2Parameters[2] = 1;
this->m_Step2Parameters[3] = 70;
this->m_Step2Parameters[4] = 0.2;
this->m_Step2Parameters[5] = 30;
this->m_Step2Parameters[6] = 0;
this->m_Step2Parameters[7] = 0;
ParametersType Step1Parameters=this->GetStep1Parameters();
ParametersType Step2Parameters=this->GetStep2Parameters();
std::cout<<" Step1Parameters"<<Step1Parameters<<"Step2Parameters"<<Step2Parameters<<""<<std::endl;
}
......
......@@ -75,22 +75,30 @@ public:
itkTypeMacro(LabelToSimulationParametersBase, ProcessObject);
itkSetMacro(Label, LabelType);
virtual const ParametersType & GetStep1Parameters() = 0;
virtual const ParametersType & GetStep2Parameters() = 0;
itkGetMacro(Label, LabelType);
itkSetMacro(Step1Parameters, ParametersType);
itkGetMacro(Step1Parameters, ParametersType);
itkSetMacro(Step2Parameters, ParametersType);
itkGetMacro(Step2Parameters, ParametersType);
//virtual const ParametersType & GetStep1Parameters() = 0;
//virtual const ParametersType & GetStep2Parameters() = 0;
protected:
LabelToSimulationParametersBase(){};
virtual ~LabelToSimulationParametersBase() {}
ParametersType m_Step1Parameters;
ParametersType m_Step2Parameters;
LabelType m_Label;
private:
LabelToSimulationParametersBase(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
ParametersType m_Step1Parameters;
ParametersType m_Step2Parameters;
LabelType m_Label;
};
......
......@@ -135,11 +135,11 @@ SailModel
/** Set Parameters */
void
SailModel
::SetParameters(const ParametersType & params)
::SetInput(const ParametersType & params)
{
if(params.Size()!=8) itkExceptionMacro( << "Must have 8 parameters in that order : LAI, Angl, PSoil, Skyl, HSpot, TTS, TTO, PSI" );
m_Parameters = params;
this->SetParameters(params);
m_LAI=params[0];
m_Angl=params[1];
m_PSoil=params[2];
......@@ -151,22 +151,24 @@ SailModel
}
/** Get Parameters */
const SailModel::ParametersType &
const SailModel::ParametersType
SailModel
::GetParameters()
::GetInput()
{
if(m_Parameters.Size()!=8)
ParametersType parameters=this->GetParameters();
if(parameters.Size()!=8)
{
m_Parameters[0]=m_LAI;
m_Parameters[1]=m_Angl;
m_Parameters[2]=m_PSoil;
m_Parameters[3]=m_Skyl;
m_Parameters[4]=m_HSpot;
m_Parameters[5]=m_TTS;
m_Parameters[6]=m_TTO;
m_Parameters[7]=m_PSI;
parameters[0]=m_LAI;
parameters[1]=m_Angl;
parameters[2]=m_PSoil;
parameters[3]=m_Skyl;
parameters[4]=m_HSpot;
parameters[5]=m_TTS;
parameters[6]=m_TTO;
parameters[7]=m_PSI;
this->SetParameters(parameters);
}
return m_Parameters;
return this->GetParameters();
}
......
......@@ -102,8 +102,8 @@ class ITK_EXPORT SailModel : public SimulationStep2Base
virtual SpectralResponseType * GetViewingReflectance();
virtual SpectralResponseType * GetHemisphericalReflectance();
virtual const ParametersType & GetParameters();
virtual void SetParameters(const ParametersType &);
const ParametersType GetInput();
void SetInput(const ParametersType &);
protected:
......
......@@ -54,7 +54,9 @@ public:
/** Standard Macro*/
itkTypeMacro(SimulationStep1Base, ProcessObject);
virtual void SetInput(const ParametersType &) = 0;
itkSetMacro(Parameters, ParametersType)
itkGetMacro(Parameters, ParametersType)
//virtual void SetInput(const ParametersType &) = 0;
virtual SpectralResponseType * GetReflectance() = 0;
virtual SpectralResponseType * GetTransmittance() = 0;
......@@ -64,13 +66,13 @@ protected:
SimulationStep1Base(){};
virtual ~SimulationStep1Base() {}
ParametersType m_Parameters;
private:
SimulationStep1Base(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
ParametersType m_Parameters;
};
......
......@@ -39,38 +39,42 @@ class ITK_EXPORT SimulationStep2Base : public itk::ProcessObject
{
public:
/**Standard "Self" & Superclass typedef*/
typedef SimulationStep2Base Self;
typedef itk::ProcessObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Some convenient typedefs. */
typedef SpectralResponse<double, double> SpectralResponseType;
typedef double ParametersValueType;
typedef itk::Array<ParametersValueType> ParametersType;
/** Standard Macro*/
itkTypeMacro(SimulationStep2Base, ProcessObject);
virtual const ParametersType & GetParameters() = 0;
virtual void SetParameters(const ParametersType &) = 0;
virtual void SetReflectance(const SpectralResponseType *) = 0;
virtual void SetTransmittance(const SpectralResponseType *) = 0;
/**Standard "Self" & Superclass typedef*/
typedef SimulationStep2Base Self;
typedef itk::ProcessObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Some convenient typedefs. */
typedef SpectralResponse<double, double> SpectralResponseType;
typedef double ParametersValueType;
typedef itk::Array<ParametersValueType> ParametersType;
/** Standard Macro*/
itkTypeMacro(SimulationStep2Base, ProcessObject)
;
itkSetMacro(Parameters, ParametersType)
itkGetMacro(Parameters, ParametersType)
// ;
virtual void SetReflectance(const SpectralResponseType *) = 0;
virtual void SetTransmittance(const SpectralResponseType *) = 0;
protected:
SimulationStep2Base(){};
virtual ~SimulationStep2Base() {}
ParametersType m_Parameters;
SimulationStep2Base()
{
}
;
virtual ~SimulationStep2Base()
{
}
private:
SimulationStep2Base(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
SimulationStep2Base(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
ParametersType m_Parameters;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment