Commit 7c845027 authored by Guillaume Pasero's avatar Guillaume Pasero

ENH: OutputImageParameter refactored with fewer dynamic_cast

parent 31232585
...@@ -117,14 +117,8 @@ protected: ...@@ -117,14 +117,8 @@ protected:
/** Destructor */ /** Destructor */
~OutputImageParameter() override; ~OutputImageParameter() override;
template <class TInputVectorImageType> template <class TInput>
void SwitchVectorImageWrite(); int SwitchInput(TInput *img);
template <class TInputVectorImageType>
void SwitchRGBImageWrite();
template <class TInputVectorImageType>
void SwitchRGBAImageWrite();
//FloatVectorImageType::Pointer m_Image; //FloatVectorImageType::Pointer m_Image;
ImageBaseType::Pointer m_Image; ImageBaseType::Pointer m_Image;
...@@ -132,46 +126,28 @@ protected: ...@@ -132,46 +126,28 @@ protected:
ImagePixelType m_PixelType; ImagePixelType m_PixelType;
ImagePixelType m_DefaultPixelType; ImagePixelType m_DefaultPixelType;
typedef otb::ImageFileWriter<UInt8VectorImageType> VectorUInt8WriterType;
typedef otb::ImageFileWriter<Int16VectorImageType> VectorInt16WriterType;
typedef otb::ImageFileWriter<UInt16VectorImageType> VectorUInt16WriterType;
typedef otb::ImageFileWriter<Int32VectorImageType> VectorInt32WriterType;
typedef otb::ImageFileWriter<UInt32VectorImageType> VectorUInt32WriterType;
typedef otb::ImageFileWriter<FloatVectorImageType> VectorFloatWriterType;
typedef otb::ImageFileWriter<DoubleVectorImageType> VectorDoubleWriterType;
typedef otb::ImageFileWriter<UInt8RGBAImageType> RGBAUInt8WriterType;
typedef otb::ImageFileWriter<UInt8RGBImageType> RGBUInt8WriterType;
typedef otb::ImageFileWriter<ComplexInt16VectorImageType> ComplexVectorInt16WriterType;
typedef otb::ImageFileWriter<ComplexInt32VectorImageType> ComplexVectorInt32WriterType;
typedef otb::ImageFileWriter<ComplexFloatVectorImageType> ComplexVectorFloatWriterType;
typedef otb::ImageFileWriter<ComplexDoubleVectorImageType> ComplexVectorDoubleWriterType;
VectorUInt8WriterType::Pointer m_VectorUInt8Writer;
VectorInt16WriterType::Pointer m_VectorInt16Writer;
VectorUInt16WriterType::Pointer m_VectorUInt16Writer;
VectorInt32WriterType::Pointer m_VectorInt32Writer;
VectorUInt32WriterType::Pointer m_VectorUInt32Writer;
VectorFloatWriterType::Pointer m_VectorFloatWriter;
VectorDoubleWriterType::Pointer m_VectorDoubleWriter;
RGBUInt8WriterType::Pointer m_RGBUInt8Writer;
RGBAUInt8WriterType::Pointer m_RGBAUInt8Writer;
ComplexVectorInt16WriterType::Pointer m_ComplexVectorInt16Writer;
ComplexVectorInt32WriterType::Pointer m_ComplexVectorInt32Writer;
ComplexVectorFloatWriterType::Pointer m_ComplexVectorFloatWriter;
ComplexVectorDoubleWriterType::Pointer m_ComplexVectorDoubleWriter;
private: private:
OutputImageParameter(const Parameter &); //purposely not implemented OutputImageParameter(const Parameter &); //purposely not implemented
void operator =(const Parameter&); //purposely not implemented void operator =(const Parameter&); //purposely not implemented
unsigned int m_RAMValue; unsigned int m_RAMValue;
itk::ProcessObject::Pointer m_Caster;
itk::ProcessObject::Pointer m_Writer;
}; // End class OutputImage Parameter }; // End class OutputImage Parameter
// Declare specialisation for UInt8RGBAImageType
template <>
int
OutputImageParameter::SwitchInput(UInt8RGBAImageType *img);
// Declare specialisation for UInt8RGBImageType
template <>
int
OutputImageParameter::SwitchInput(UInt8RGBImageType *img);
} // End namespace Wrapper } // End namespace Wrapper
} // End namespace otb } // End namespace otb
......
...@@ -477,7 +477,6 @@ int Application::ExecuteAndWriteOutput() ...@@ -477,7 +477,6 @@ int Application::ExecuteAndWriteOutput()
if(outputParam!=ITK_NULLPTR) if(outputParam!=ITK_NULLPTR)
{ {
outputParam->InitializeWriters();
std::string checkReturn = outputParam->CheckFileName(true); std::string checkReturn = outputParam->CheckFileName(true);
if (!checkReturn.empty()) if (!checkReturn.empty())
{ {
...@@ -487,6 +486,7 @@ int Application::ExecuteAndWriteOutput() ...@@ -487,6 +486,7 @@ int Application::ExecuteAndWriteOutput()
{ {
outputParam->SetRAMValue(ram); outputParam->SetRAMValue(ram);
} }
outputParam->InitializeWriters();
std::ostringstream progressId; std::ostringstream progressId;
progressId << "Writing " << outputParam->GetFileName() << "..."; progressId << "Writing " << outputParam->GetFileName() << "...";
AddProcess(outputParam->GetWriter(), progressId.str()); AddProcess(outputParam->GetWriter(), progressId.str());
......
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