diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 4402dbf028504c9187f6a47145131fec5fd99cbb..26c389002dc32713c481a6fd5fc6728f57a83d73 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -483,6 +483,34 @@ public: */ void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageListParameter::ImageBaseType * img); +/** + * Add a value to a parameter list as a string + * + * Can be called for parameter types: + * \li ParameterType_InputImageList + * + * \in parameter The parameter key + * \in str The string + * \throw itk::Exception if parameter is not found or not an + * InputImageList parameter + */ + void AddParameterStringList(std::string parameter, const std::string & str); + + /** + * Set the nth value of a parameter list as a string. + * + * Can be called for parameter types: + * \li ParameterType_InputImageList + * + * \in parameter The parameter key + * \in id Position at which to set the ImageBase pointer + * \in str The string + * \throw itk::Exception if parameter is not found or not an + * InputImageList parameter or if id is out of bounds + */ + void SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string& str); + + /** * Clear all images from an InputImageList parameter. * diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 4611450d2120cb31fdcd43d36e6fa9aae8252143..cf17ba6fc9b2d0856d0d69e5350740b0803a83dc 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1263,6 +1263,42 @@ void Application::SetNthParameterInputImageList(std::string parameter, const uns } +void Application::AddParameterStringList(std::string parameter, const std::string & str) +{ + Parameter* param = GetParameterByKey(parameter); + + InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); + + if(paramDown) + { + paramDown->AddFromFileName(str); + } + else + { + itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + } + +} + +void Application::SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string & str) +{ + Parameter* param = GetParameterByKey(parameter); + + InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); + + if(paramDown) + { + paramDown->SetNthFileName(id,str); + } + else + { + itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + } + +} + + + void Application::ClearParameterInputImageList(std::string parameter) { Parameter* param = GetParameterByKey(parameter); diff --git a/Modules/Wrappers/ApplicationEngine/test/otbApplicationMemoryConnectTest.cxx b/Modules/Wrappers/ApplicationEngine/test/otbApplicationMemoryConnectTest.cxx index e0f646d59565adb1f98323c18fd4f59d58d3231f..b9d92f8d265f873ef87b6ef0e038ab6119b513df 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbApplicationMemoryConnectTest.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbApplicationMemoryConnectTest.cxx @@ -64,6 +64,7 @@ int otbApplicationMemoryConnectTest(int argc, char * argv[]) app4->AddImageToParameterInputImageList("il",app2->GetParameterOutputImage("out")); app4->AddImageToParameterInputImageList("il",app3->GetParameterOutputImage("out")); + app4->AddParameterStringList("il",infname); app4->ExecuteAndWriteOutput(); diff --git a/Modules/Wrappers/SWIG/src/otbApplication.i b/Modules/Wrappers/SWIG/src/otbApplication.i index c617e05e7220d28d8db455a92f130c8e0ebed7f4..aa93633ba359170270f853d5b4973c7cfa54de1e 100644 --- a/Modules/Wrappers/SWIG/src/otbApplication.i +++ b/Modules/Wrappers/SWIG/src/otbApplication.i @@ -209,7 +209,9 @@ public: ComplexInputImageParameter::ImageBaseType * GetParameterComplexOutputImage(std::string parameter); void SetParameterComplexInputImage(std::string parameter, ComplexInputImageParameter::ImageBaseType * inputImage); void AddImageToParameterInputImageList(std::string parameter,InputImageParameter::ImageBaseType * img); - void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageParameter::ImageBaseType * img); + void AddParameterStringList(std::string parameter,const std::string & str); + void SetNthParameterInputImageList(std::string parameter, const unsigned int &id, InputImageParameter::ImageBaseType * img); + void SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string& str); void ClearParameterInputImageList(std::string parameter); unsigned int GetNumberOfElementsInParameterInputImageList(std::string parameter); diff --git a/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py b/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py index 0b25eb0018f1044a737b69e776df8e6acd1d4393..30a0be351910636d28e5969d050e0df2c3548bd6 100644 --- a/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py +++ b/Modules/Wrappers/SWIG/test/python/PythonConnectApplications.py @@ -21,6 +21,7 @@ def test(otb, argv): app4.AddImageToParameterInputImageList("il",app2.GetParameterOutputImage("out")); app4.AddImageToParameterInputImageList("il",app3.GetParameterOutputImage("out")); + app4.AddParameterStringList("il",argv[1]) app4.OUT = argv[2] app4.ExecuteAndWriteOutput()