21 #ifndef otbWrapperApplication_h
22 #define otbWrapperApplication_h
38 #include "itkMersenneTwisterRandomVariateGenerator.h"
39 #include "OTBApplicationEngineExport.h"
58 ApplicationException(
const char* file,
unsigned int line,
const char* message =
"Application error.",
const char* loc =
"Unknown");
61 ApplicationException(
const std::string& file,
unsigned int line,
const char* message =
"Application error.",
const char* loc =
"Unknown");
63 ApplicationException(
const std::string& file,
unsigned int line,
const std::string& message =
"Application error.",
const std::string& loc =
"Unknown");
76 class OTBApplicationEngine_EXPORT
Application :
public itk::Object
88 virtual void SetName(
const std::string&);
89 virtual const char* GetName()
const;
91 void SetDescription(
const std::string&);
92 virtual const char* GetDescription()
const;
98 bool IsInitialized()
const;
100 void LoadParametersFromXML(
const std::string& filename);
101 void SaveParametersToXML(
const std::string& filename);
104 void UpdateParameters();
131 int ExecuteAndWriteOutput();
134 bool ConnectImage(std::string in,
Application* app, std::string out);
137 void PropagateConnectMode(
bool isMem);
150 Parameter* GetParameterByKey(std::string
const& parameter,
bool follow =
true);
155 const Parameter* GetParameterByKey(std::string
const& parameter,
bool follow =
true)
const;
158 std::string GetParameterName(std::string
const& paramKey);
161 std::string GetParameterDescription(std::string
const& paramKey);
164 void SetParameterDescription(std::string
const& paramKey, std::string dec);
167 void EnableParameter(std::string
const& paramKey);
170 void DisableParameter(std::string
const& paramKey);
173 bool IsParameterEnabled(std::string
const& paramKey,
bool recurseParents =
false)
const;
176 bool IsMandatory(std::string
const& paramKey)
const;
181 bool HasAutomaticValue(std::string
const& paramKey)
const;
185 bool HasUserValue(std::string
const& paramKey)
const;
188 void ClearValue(std::string
const& paramKey);
193 bool HasValue(std::string
const& paramKey)
const;
200 void SetParameterUserValue(std::string
const& paramKey,
bool value);
203 UserLevel GetParameterUserLevel(std::string
const& paramKey)
const;
206 Role GetParameterRole(std::string
const& paramKey)
const;
209 ParameterType GetParameterType(std::string
const& paramKey)
const;
212 std::vector<std::string> GetChoiceKeys(std::string
const& paramKey);
215 std::vector<std::string> GetChoiceNames(std::string
const& paramKey);
227 void SetParameterInt(std::string
const& parameter,
int value,
bool hasUserValueFlag =
true);
235 void SetParameterFloat(std::string
const& parameter,
float value,
bool hasUserValueFlag =
true);
243 void SetParameterDouble(std::string
const& parameter,
double value,
bool hasUserValueFlag =
true);
256 void SetParameterString(std::string
const& parameter, std::string value,
bool hasUserValueFlag =
true);
279 void SetParameterStringList(std::string
const& parameter, std::vector<std::string> values,
bool hasUserValueFlag =
true);
284 bool IsApplicationReady();
295 bool IsParameterMissing(
const std::string& key)
const;
308 void SetDefaultParameterInt(std::string
const& parameter,
int value);
319 int GetDefaultParameterInt(std::string
const& parameter);
329 void SetDefaultParameterFloat(std::string
const& parameter,
float value);
337 float GetDefaultParameterFloat(std::string
const& parameter);
347 void SetDefaultParameterDouble(std::string
const& parameter,
double value);
355 double GetDefaultParameterDouble(std::string
const& parameter);
362 void SetDefaultOutputPixelType(std::string
const& parameter,
ImagePixelType type);
378 void SetMinimumParameterIntValue(std::string
const& parameter,
int value);
387 void SetMaximumParameterIntValue(std::string
const& parameter,
int value);
396 void SetMinimumParameterFloatValue(std::string
const& parameter,
float value);
405 void SetMaximumParameterFloatValue(std::string
const& parameter,
float value);
415 void SetMinimumParameterDoubleValue(std::string
const& parameter,
double value);
425 void SetMaximumParameterDoubleValue(std::string
const& parameter,
double value);
437 void SetListViewSingleSelectionMode(std::string
const& parameter,
bool status);
447 bool GetListViewSingleSelectionMode(
const std::string& parameter);
461 void SetParameterOutputImagePixelType(std::string
const& parameter,
ImagePixelType pixelType);
468 void SetParameterOutputVectorData(std::string
const& parameter,
VectorDataType* value);
480 int GetParameterInt(std::string
const& parameter)
const;
488 float GetParameterFloat(std::string
const& parameter)
const;
496 double GetParameterDouble(std::string
const& parameter)
const;
510 std::string GetParameterString(std::string
const& parameter)
const;
526 std::vector<std::string> GetParameterStringList(
const std::string& parameter);
538 void SetParameterInputImage(std::string
const& parameter,
ImageBaseType* inputImage);
549 ImageBaseType* GetParameterOutputImage(std::string
const& parameter);
560 void AddImageToParameterInputImageList(std::string
const& parameter,
ImageBaseType* img);
572 void SetNthParameterInputImageList(std::string
const& parameter,
const unsigned int&
id,
ImageBaseType* img);
579 void SetVectorData(std::string
const& key, std::string
const& vectorData );
600 void SetRasterData(std::string
const& key, std::string
const& rasterData );
613 void AddParameterStringList(std::string
const& parameter,
const std::string& str);
627 void SetNthParameterStringList(std::string
const& parameter,
const unsigned int&
id,
const std::string& str);
637 void ClearParameterInputImageList(std::string
const& parameter);
646 unsigned int GetNumberOfElementsInParameterInputImageList(std::string
const& parameter);
698 VectorDataType* GetParameterVectorData(std::string
const& parameter);
725 std::string GetParameterAsString(std::string
const& paramKey);
729 std::vector<std::string> GetParametersKeys(
bool recursive =
true);
736 ImagePixelType GetParameterOutputImagePixelType(std::string
const& parameter);
740 m_ParameterList = paramGroup;
748 itk::ProcessObject* GetProgressSource()
const;
750 std::string GetProgressDescription()
const;
752 virtual void SetDocLongDescription(
const std::string&);
753 virtual const char* GetDocLongDescription()
const;
755 virtual void SetDocAuthors(
const std::string&);
756 virtual const char* GetDocAuthors()
const;
758 virtual void SetDocLimitations(
const std::string&);
759 virtual const char* GetDocLimitations()
const;
761 virtual void SetDocSeeAlso(
const std::string&);
762 virtual const char* GetDocSeeAlso()
const;
764 virtual void SetDocTags(std::vector<std::string>);
765 virtual std::vector<std::string> GetDocTags()
const;
767 void AddDocTag(
const std::string&);
773 unsigned int GetNumberOfExamples();
774 std::string GetExampleComment(
unsigned int id);
775 unsigned int GetExampleNumberOfParameters(
unsigned int id);
776 std::string GetExampleParameterKey(
unsigned int exId,
unsigned int paramId);
777 std::string GetExampleParameterValue(
unsigned int exId,
unsigned int paramId);
778 void SetDocExampleParameterValue(
const std::string key,
const std::string value,
unsigned int exId = 0);
779 void SetExampleComment(
const std::string& comm,
unsigned int i);
780 unsigned int AddExample(
const std::string& comm =
"");
781 std::string GetCLExample();
782 std::string GetHtmlExample();
787 std::vector<std::pair<std::string, std::string>> GetOutputParametersSumUp();
789 double GetLastExecutionTiming()
const;
791 virtual void SetDocLink(
const std::string& link);
792 virtual const std::string& GetDocLink()
const;
794 void SetOfficialDocLink();
798 ImageBaseType::PointType GetImageOrigin(
const std::string& key,
unsigned int idx = 0);
802 ImageBaseType::SpacingType GetImageSpacing(
const std::string& key,
unsigned int idx = 0);
806 ImageBaseType::SizeType GetImageSize(
const std::string& key,
unsigned int idx = 0);
810 unsigned int GetImageNbBands(
const std::string& key,
unsigned int idx = 0);
814 std::string GetImageProjection(
const std::string& key,
unsigned int idx = 0);
821 unsigned long PropagateRequestedRegion(
const std::string& key, ImageBaseType::RegionType region,
unsigned int idx = 0);
826 ImageBaseType::RegionType GetImageRequestedRegion(
const std::string& key,
unsigned int idx = 0);
830 ImageMetadata &GetImageMetadata(
const std::string& key,
unsigned int idx = 0);
831 void SetImageMetadata(
const ImageMetadata & imd,
const std::string& key,
unsigned int idx = 0);
835 itk::MetaDataDictionary GetMetadataDictionary(
const std::string& key,
unsigned int idx = 0);
841 ImagePixelType GetImageBasePixelType(
const std::string& key,
unsigned int idx = 0);
851 ImageBaseType* GetParameterImageBase(
const std::string& key,
unsigned int idx = 0);
860 void SetParameterImageBase(
const std::string& key,
ImageBaseType* img,
unsigned int idx = 0);
872 void RegisterPipeline();
881 void FreeRessources();
883 bool IsExecuteDone();
886 bool IsMultiWritingEnabled();
896 void AddProcess(itk::ProcessObject*
object, std::string description);
899 void AddChoice(std::string
const& paramKey, std::string
const& paramName);
904 void AddParameter(
ParameterType type, std::string
const& paramKey, std::string
const& paramName);
907 void AddRAMParameter(std::string
const& paramKey =
"ram");
910 void AddRAMParameter(std::string
const& paramKey, std::string
const& paramName,
unsigned int defaultValue);
913 void AddRANDParameter(std::string
const& paramKey =
"rand");
916 void AddRANDParameter(std::string
const& paramKey, std::string
const& paramName,
unsigned int defaultValue);
919 void ClearChoices(std::string
const& key);
922 std::vector<int> GetSelectedItems(std::string
const& paramKey);
925 void MandatoryOn(std::string
const& paramKey);
928 void MandatoryOff(std::string
const& paramKey);
931 void SetParameterUserLevel(std::string
const& paramKey,
UserLevel level);
934 void SetParameterRole(std::string
const& paramKey,
Role role);
941 template <
class TImageType>
942 TImageType* GetParameterImage(std::string
const& parameter);
945 void AutomaticValueOn(std::string
const& paramKey);
948 void AutomaticValueOff(std::string
const& paramKey);
955 template <
class TImageType>
956 void SetParameterOutputImage(std::string
const& parameter, TImageType* value);
959 itkSetMacro(MultiWriting,
bool);
962 void EnableInPrivateDo();
965 void DisableInPrivateDo();
969 virtual void DoInit() = 0;
972 virtual void DoUpdateParameters() = 0;
975 virtual void DoExecute() = 0;
980 virtual void AfterExecuteAndWriteOutputs();
1046 #ifndef OTB_MANUAL_INSTANTIATION
1056 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt8VectorImageType* Application::GetParameterImage<UInt8VectorImageType>(std::string
const&);
1057 extern template OTBApplicationEngine_EXPORT_TEMPLATE
Int16VectorImageType* Application::GetParameterImage<Int16VectorImageType>(std::string
const&);
1058 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt16VectorImageType* Application::GetParameterImage<UInt16VectorImageType>(std::string
const&);
1059 extern template OTBApplicationEngine_EXPORT_TEMPLATE
Int32VectorImageType* Application::GetParameterImage<Int32VectorImageType>(std::string
const&);
1060 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt32VectorImageType* Application::GetParameterImage<UInt32VectorImageType>(std::string
const&);
1062 extern template OTBApplicationEngine_EXPORT_TEMPLATE
FloatVectorImageType* Application::GetParameterImage<FloatVectorImageType>(std::string
const&);
1063 extern template OTBApplicationEngine_EXPORT_TEMPLATE
DoubleVectorImageType* Application::GetParameterImage<DoubleVectorImageType>(std::string
const&);
1066 Application::GetParameterImage<ComplexInt16VectorImageType>(std::string
const&);
1068 Application::GetParameterImage<ComplexInt32VectorImageType>(std::string
const&);
1071 Application::GetParameterImage<ComplexFloatVectorImageType>(std::string
const&);
1073 Application::GetParameterImage<ComplexDoubleVectorImageType>(std::string
const&);
1075 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt8RGBImageType* Application::GetParameterImage<UInt8RGBImageType>(std::string
const&);
1076 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt8RGBAImageType* Application::GetParameterImage<UInt8RGBAImageType>(std::string
const&);
1078 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt8ImageType* Application::GetParameterImage<UInt8ImageType>(std::string
const&);
1079 extern template OTBApplicationEngine_EXPORT_TEMPLATE
Int16ImageType* Application::GetParameterImage<Int16ImageType>(std::string
const&);
1080 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt16ImageType* Application::GetParameterImage<UInt16ImageType>(std::string
const&);
1081 extern template OTBApplicationEngine_EXPORT_TEMPLATE
Int32ImageType* Application::GetParameterImage<Int32ImageType>(std::string
const&);
1082 extern template OTBApplicationEngine_EXPORT_TEMPLATE
UInt32ImageType* Application::GetParameterImage<UInt32ImageType>(std::string
const&);
1084 extern template OTBApplicationEngine_EXPORT_TEMPLATE
FloatImageType* Application::GetParameterImage<FloatImageType>(std::string
const&);
1085 extern template OTBApplicationEngine_EXPORT_TEMPLATE
DoubleImageType* Application::GetParameterImage<DoubleImageType>(std::string
const&);
1087 extern template OTBApplicationEngine_EXPORT_TEMPLATE
ComplexInt16ImageType* Application::GetParameterImage<ComplexInt16ImageType>(std::string
const&);
1088 extern template OTBApplicationEngine_EXPORT_TEMPLATE
ComplexInt32ImageType* Application::GetParameterImage<ComplexInt32ImageType>(std::string
const&);
1090 extern template OTBApplicationEngine_EXPORT_TEMPLATE
ComplexFloatImageType* Application::GetParameterImage<ComplexFloatImageType>(std::string
const&);
1091 extern template OTBApplicationEngine_EXPORT_TEMPLATE
ComplexDoubleImageType* Application::GetParameterImage<ComplexDoubleImageType>(std::string
const&);
1095 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt8VectorImageType>(std::string
const&,
UInt8VectorImageType*);
1096 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<Int16VectorImageType>(std::string
const&,
Int16VectorImageType*);
1097 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt16VectorImageType>(std::string
const&,
1099 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<Int32VectorImageType>(std::string
const&,
Int32VectorImageType*);
1100 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt32VectorImageType>(std::string
const&,
1103 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<FloatVectorImageType>(std::string
const&,
FloatVectorImageType*);
1104 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<DoubleVectorImageType>(std::string
const&,
1107 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexInt16VectorImageType>(std::string
const&,
1109 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexInt32VectorImageType>(std::string
const&,
1112 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexFloatVectorImageType>(std::string
const&,
1114 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexDoubleVectorImageType>(std::string
const&,
1117 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt8RGBImageType>(std::string
const&,
UInt8RGBImageType*);
1118 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt8RGBAImageType>(std::string
const&,
UInt8RGBAImageType*);
1120 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt8ImageType>(std::string
const&,
UInt8ImageType*);
1121 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<Int16ImageType>(std::string
const&,
Int16ImageType*);
1122 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt16ImageType>(std::string
const&,
UInt16ImageType*);
1123 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<Int32ImageType>(std::string
const&,
Int32ImageType*);
1124 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<UInt32ImageType>(std::string
const&,
UInt32ImageType*);
1126 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<FloatImageType>(std::string
const&,
FloatImageType*);
1127 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<DoubleImageType>(std::string
const&,
DoubleImageType*);
1129 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexInt16ImageType>(std::string
const&,
1131 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexInt32ImageType>(std::string
const&,
1134 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexFloatImageType>(std::string
const&,
1136 extern template OTBApplicationEngine_EXPORT_TEMPLATE
void Application::SetParameterOutputImage<ComplexDoubleImageType>(std::string
const&,
1143 #endif // otbWrapperApplication_h_