diff --git a/Code/Core/otbWrapperApplication.cxx b/Code/Core/otbWrapperApplication.cxx index d3b5985a2cafd1edca215cad2f03f620b0a16c8c..62b47c8ce3862f23140be91c71d65ed1ff5aa498 100644 --- a/Code/Core/otbWrapperApplication.cxx +++ b/Code/Core/otbWrapperApplication.cxx @@ -275,9 +275,9 @@ std::string Application::GetParameterString(std::string parameter) return ret; } -InputImageParameter::VectorImageType* Application::GetParameterImage(std::string parameter) +VectorImageType* Application::GetParameterImage(std::string parameter) { - InputImageParameter::VectorImageType::Pointer ret; + VectorImageType::Pointer ret; Parameter* param = GetParameterByKey(parameter); if (dynamic_cast<InputImageParameter*>(param)) @@ -290,9 +290,9 @@ InputImageParameter::VectorImageType* Application::GetParameterImage(std::string return ret; } -InputComplexImageParameter::VectorImageType* Application::GetParameterComplexImage(std::string parameter) +VectorImageType* Application::GetParameterComplexImage(std::string parameter) { - InputComplexImageParameter::VectorImageType::Pointer ret; + VectorImageType::Pointer ret; Parameter* param = GetParameterByKey(parameter); if (dynamic_cast<InputComplexImageParameter*>(param)) @@ -306,9 +306,9 @@ InputComplexImageParameter::VectorImageType* Application::GetParameterComplexIma } -InputVectorDataParameter::VectorDataType* Application::GetParameterVectorData(std::string parameter) +VectorDataType* Application::GetParameterVectorData(std::string parameter) { - InputVectorDataParameter::VectorDataType::Pointer ret; + VectorDataType::Pointer ret; Parameter* param = GetParameterByKey(parameter); if (dynamic_cast<InputVectorDataParameter*>(param)) diff --git a/Code/Core/otbWrapperApplication.h b/Code/Core/otbWrapperApplication.h index 132dc68b753922106896f616fadf2164096f90a4..a61b1f3cecff9b998416ea1e9c1591465089f668 100644 --- a/Code/Core/otbWrapperApplication.h +++ b/Code/Core/otbWrapperApplication.h @@ -23,6 +23,7 @@ #include "itkObject.h" #include "itkObjectFactory.h" +#include "otbWrapperTypes.h" #include "otbWrapperParameterGroup.h" // include all parameters type for easy use when defining the application @@ -76,41 +77,103 @@ public: /** Get the parameter description */ itkGetStringMacro(Description); + /** Initialize the application, instanciating the parameter list */ void Init(); + /** Update the value of parameters for which no user value has been provided */ void UpdateParameters(); + /** Run the application. + * + * For pipeline ready application, this only wire + * and configure the pipeline, and provides + * the output image or vector data parameters as pointers. + * + * In other cases, the application must handle + * the I/O (intermediary results for example) */ void Execute(); + /* Get the internal application parameters + * + * WARNING: this method may disappear from the API */ ParameterGroup* GetParameterList(); + /* Get the internal application parameter specified + * + * WARNING: this method may disappear from the API */ Parameter* GetParameterByKey(std::string parameter); - //void SetParameterBool(std::string parameter, bool value); + /* Enable the use of an optional parameter. Returns the previous state */ + bool EnableParameter(std::string paramKey); + + /* Disable the use of an optional parameter. Returns the previous state */ + bool DisableParameter(std::string paramKey); + + /* Return the enable state of an optional parameter */ + bool IsParameterEnabled(std::string paramKey) const; + + /* Return true if the specified parameter is mandatory */ + bool IsMandatory(std::string paramKey) const; + + /* Returns true if the parameter has an associated value provided externally + * (not automatically computed by the application) */ + bool HasUserValue(std::string paramKey) const; + + /* Returns true if the parameter has an associated value. + * This value can be an automatically computed value or default value, + * or a value set externally by user */ + bool HasValue(std::string paramKey) const; + + /* Return the user level of access to a parameter */ + UserLevel GetParameterUserLevel(std::string paramKey) const; + + /* Get the parameter type from its name */ + ParameterType GetParameterType(std::string paramKey) const; + void SetParameterInt(std::string parameter, int value); void SetParameterFloat(std::string parameter, float value); void SetParameterString(std::string parameter, std::string value); - void SetParameterOutputImage(std::string parameter, OutputImageParameter::VectorImageType* value); - void SetParameterOutputVectorData(std::string parameter, OutputVectorDataParameter::VectorDataType* value); + void SetParameterOutputImage(std::string parameter, VectorImageType* value); + void SetParameterOutputVectorData(std::string parameter, VectorDataType* value); int GetParameterInt(std::string parameter); float GetParameterFloat(std::string parameter); std::string GetParameterString(std::string parameter); - InputImageParameter::VectorImageType* GetParameterImage(std::string parameter); - InputComplexImageParameter::VectorImageType* GetParameterComplexImage(std::string parameter); - InputVectorDataParameter::VectorDataType* GetParameterVectorData(std::string parameter); + VectorImageType* GetParameterImage(std::string parameter); + ComplexVectorImageType* GetParameterComplexImage(std::string parameter); + VectorDataType* GetParameterVectorData(std::string parameter); + protected: /** Constructor */ Application(); + /** Destructor */ virtual ~Application(); + /** Add a new parameter to the parameter group */ + void AddParameter(ParameterType type, std::string paramKey, std::string paramName); + + /** Add a new subgroup to an existing group */ + void AddParameterGroup(std::string paramKey, std::string paramName); + + /** Declare a parameter as mandatory */ + void MandatoryOn(std::string paramKey); + + /** Declare a parameter as NOT mandatory (default state) */ + void MandatoryOff(std::string paramKey); + + /* Set the user level of access to a parameter */ + void SetParameterUserLevel(std::string paramKey, UserLevel level); + private: + /* Implement this method to add parameters */ virtual void DoCreateParameters() = 0; + /* Implement this method to update non valued parameters */ virtual void DoUpdateParameters() = 0; + /* Implement this method to build the output */ virtual void DoExecute() = 0; Application(const Application &); //purposely not implemented diff --git a/Code/Core/otbWrapperInputComplexImageParameter.h b/Code/Core/otbWrapperInputComplexImageParameter.h index 791b08aee80cac2d8bb7ab791627e96affe44d85..cf4c4d6aa77ebb8eee1d4aaaf669979f7dc1a882 100644 --- a/Code/Core/otbWrapperInputComplexImageParameter.h +++ b/Code/Core/otbWrapperInputComplexImageParameter.h @@ -18,10 +18,7 @@ #ifndef __otbWrapperInputComplexImageParameter_h #define __otbWrapperInputComplexImageParameter_h -#include <complex> -#include "otbVectorImage.h" #include "otbImageFileReader.h" - #include "otbWrapperParameter.h" namespace otb @@ -47,9 +44,6 @@ public: /** RTTI support */ itkTypeMacro(InputComplexImageParameter,Parameter); - typedef std::complex<float> PixelType; - typedef otb::VectorImage<PixelType, 2> VectorImageType; - /** Set the value */ itkSetObjectMacro(Image, VectorImageType); diff --git a/Code/Core/otbWrapperInputImageParameter.h b/Code/Core/otbWrapperInputImageParameter.h index 01aab565e7aa661c8d56d3a21b5623c61154a9e7..1c1e9d12991bf3dd4d3717a0160b0185d15adaf5 100644 --- a/Code/Core/otbWrapperInputImageParameter.h +++ b/Code/Core/otbWrapperInputImageParameter.h @@ -18,7 +18,6 @@ #ifndef __otbWrapperInputImageParameter_h #define __otbWrapperInputImageParameter_h -#include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbWrapperParameter.h" @@ -46,9 +45,6 @@ public: /** RTTI support */ itkTypeMacro(InputImageParameter,Parameter); - typedef float PixelType; - typedef otb::VectorImage<PixelType, 2> VectorImageType; - /** Set the value */ itkSetObjectMacro(Image, VectorImageType); diff --git a/Code/Core/otbWrapperInputVectorDataParameter.h b/Code/Core/otbWrapperInputVectorDataParameter.h index f0cbe1481e4f716f58df7df4c813af16c88ce984..337e4d632e9ad7a777704eb74f162de86ea7ab67 100644 --- a/Code/Core/otbWrapperInputVectorDataParameter.h +++ b/Code/Core/otbWrapperInputVectorDataParameter.h @@ -18,9 +18,7 @@ #ifndef __otbWrapperInputVectorDataParameter_h #define __otbWrapperInputVectorDataParameter_h -#include "otbVectorData.h" #include "otbVectorDataFileReader.h" - #include "otbWrapperParameter.h" namespace otb diff --git a/Code/Core/otbWrapperParameter.h b/Code/Core/otbWrapperParameter.h index f66619c93ad1255b4e1fc642c470271dcb7e792a..14371d4e02a78b2bf319f03974690407192afd51 100644 --- a/Code/Core/otbWrapperParameter.h +++ b/Code/Core/otbWrapperParameter.h @@ -23,6 +23,8 @@ #include "boost/any.hpp" #include "itkObjectFactory.h" +#include "otbWrapperTypes.h" + namespace otb { namespace Wrapper @@ -88,11 +90,17 @@ public: /** Get the parameter key */ itkGetStringMacro(Key); + /** Set the parameter mandatory flag */ + itkSetMacro(Active,bool); + + /** Get the parameter mandatory flag */ + itkGetConstMacro(Active,bool); + /** Set the parameter mandatory flag */ itkSetMacro(Mandatory,bool); /** Get the parameter mandatory flag */ - itkGetMacro(Mandatory,bool); + itkGetConstMacro(Mandatory,bool); /** Toogle the parameter mandatory flag */ itkBooleanMacro(Mandatory); @@ -151,9 +159,14 @@ protected: /** True if the parameter is mandatory */ bool m_Mandatory; + /** True if activated (a mandatory parameter is always active) */ + bool m_Active; + /** Default value behaviour */ DefaultValueMode m_DefaultValueMode; + UserLevel m_Level; + private: Parameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented diff --git a/Example/Smoothing/otbSmoothing.cxx b/Example/Smoothing/otbSmoothing.cxx index 413d6b0cfae90be1aa41b604f8441d9c1200880f..d956f944c7de0d6dd9b37d681405e703eb7eb3a9 100644 --- a/Example/Smoothing/otbSmoothing.cxx +++ b/Example/Smoothing/otbSmoothing.cxx @@ -38,21 +38,8 @@ enum Smoothing_Anisotropic }; -typedef otb::Wrapper::InputImageParameter::VectorImageType VectorImageType; typedef otb::Image<VectorImageType::InternalPixelType, 2> ImageType; -typedef itk::MeanImageFilter<ImageType, ImageType> MeanFilterType; -typedef otb::PerBandVectorImageFilter<VectorImageType, VectorImageType, MeanFilterType> - PerBandMeanFilterType; - -typedef itk::DiscreteGaussianImageFilter<ImageType, ImageType> DiscreteGaussianFilterType; -typedef otb::PerBandVectorImageFilter<VectorImageType, VectorImageType, DiscreteGaussianFilterType> - PerBandDiscreteGaussianFilterType; - -typedef itk::GradientAnisotropicDiffusionImageFilter<ImageType, ImageType> GradientAnisotropicDiffusionFilterType; -typedef otb::PerBandVectorImageFilter<VectorImageType, VectorImageType, GradientAnisotropicDiffusionFilterType> - PerBandGradientAnisotropicDiffusionFilterType; - Smoothing::Smoothing() { @@ -115,9 +102,12 @@ void Smoothing::DoExecute() { case Smoothing_Mean: { + typedef itk::MeanImageFilter<ImageType, ImageType> MeanFilterType; + typedef otb::PerBandVectorImageFilter<VectorImageType, VectorImageType, MeanFilterType> + PerBandMeanFilterType; + PerBandMeanFilterType::Pointer perBand = PerBandMeanFilterType::New(); - perBand->SetInput(inImage); MeanFilterType::InputSizeType radius; @@ -129,6 +119,10 @@ void Smoothing::DoExecute() break; case Smoothing_Gaussian: { + typedef itk::DiscreteGaussianImageFilter<ImageType, ImageType> DiscreteGaussianFilterType; + typedef otb::PerBandVectorImageFilter<VectorImageType, VectorImageType, DiscreteGaussianFilterType> + PerBandDiscreteGaussianFilterType; + PerBandDiscreteGaussianFilterType::Pointer perBand = PerBandDiscreteGaussianFilterType::New(); perBand->SetInput(inImage); @@ -142,6 +136,10 @@ void Smoothing::DoExecute() break; case Smoothing_Anisotropic: { + typedef itk::GradientAnisotropicDiffusionImageFilter<ImageType, ImageType> GradientAnisotropicDiffusionFilterType; + typedef otb::PerBandVectorImageFilter<VectorImageType, VectorImageType, GradientAnisotropicDiffusionFilterType> + PerBandGradientAnisotropicDiffusionFilterType; + PerBandGradientAnisotropicDiffusionFilterType::Pointer perBand = PerBandGradientAnisotropicDiffusionFilterType::New(); perBand->SetInput(inImage);