Skip to content
Snippets Groups Projects
Commit 94c8c3c5 authored by Sébastien Dinot's avatar Sébastien Dinot
Browse files

LICENSE: Merge existing work in relation to the license migration

parents f8d5877c b37be480
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 896 deletions
...@@ -16,7 +16,6 @@ David Dubois, ...@@ -16,7 +16,6 @@ David Dubois,
David Youssefi (CNES Intern, then CS), David Youssefi (CNES Intern, then CS),
Edouard Barthelet (Telecom Bretagne and Thales Communications), Edouard Barthelet (Telecom Bretagne and Thales Communications),
Emmanuel Christophe (CNES, then CRISP, then Google), Emmanuel Christophe (CNES, then CRISP, then Google),
Eric Bughin (CMLA),
Etienne Bougoin (CS), Etienne Bougoin (CS),
Gr\'egoire Mercier (Telecom Bretagne), Gr\'egoire Mercier (Telecom Bretagne),
Guillaume Borrut (CS), Guillaume Borrut (CS),
......
project(OTBIOMW)
set(OTBIOMW_LIBRARIES OTBIOMW)
otb_module_impl()
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef otbMWImageIO_h
#define otbMWImageIO_h
#include "otbImageIOBase.h"
#include <fstream>
#include <string>
#include <vector>
namespace otb
{
/** \class MWImageIO
*
* \brief ImageIO object for reading (not writing) MW format images
*
* The streaming read is implemented.
*
* \ingroup IOFilters
*
*
* \ingroup OTBIOMW
*/
class ITK_EXPORT MWImageIO : public otb::ImageIOBase
{
public:
/** Standard class typedefs. */
typedef MWImageIO Self;
typedef otb::ImageIOBase Superclass;
typedef itk::SmartPointer<Self> Pointer;
/** Byte order typedef */
typedef Superclass::ByteOrder ByteOrder;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(MWImageIO, otb::ImageIOBase);
/*-------- This part of the interface deals with reading data. ------ */
/** Determine the file type. Returns true if this ImageIO can read the
* file specified. */
bool CanReadFile(const char*) ITK_OVERRIDE;
/** Determine the file type. Returns true if the ImageIO can stream read the specified file */
bool CanStreamRead() ITK_OVERRIDE
{
return true;
}
/** Set the spacing and dimension information for the set filename. */
void ReadImageInformation() ITK_OVERRIDE;
/** Reads the data from disk into the memory buffer provided. */
void Read(void* buffer) ITK_OVERRIDE;
/** Reads 3D data from multiple files assuming one slice per file. */
virtual void ReadVolume(void* buffer);
/*-------- This part of the interfaces deals with writing data. ----- */
/** Determine the file type. Returns true if this ImageIO can read the
* file specified. */
bool CanWriteFile(const char*) ITK_OVERRIDE;
/** Determine the file type. Returns true if the ImageIO can stream write the specified file */
bool CanStreamWrite() ITK_OVERRIDE
{
return true;
}
/** Writes the spacing and dimensions of the image.
* Assumes SetFileName has been called with a valid file name. */
void WriteImageInformation() ITK_OVERRIDE;
/** Writes the data to disk from the memory buffer provided. Make sure
* that the IORegion has been set properly. */
void Write(const void* buffer) ITK_OVERRIDE;
// JULIEN: NOT USED, NOT IMPLEMENTED
//void SampleImage(void* buffer, int XBegin, int YBegin, int SizeXRead, int SizeYRead, int XSample, int YSample);
/** Get the number of overviews available into the file specified
* This imageIO didn't support overviews */
unsigned int GetOverviewsCount() ITK_OVERRIDE
{
// MANTIS-1154: Source image is always considered as the best
// resolution overview.
return 1;
}
/** Get information about overviews available into the file specified
* This imageIO didn't support overviews */
std::vector<std::string> GetOverviewsInfo() ITK_OVERRIDE
{
std::vector<std::string> desc;
return desc;
}
/** Provide hist about the output container to deal with complex pixel
* type (Not used here) */
void SetOutputImagePixelType( bool itkNotUsed(isComplexInternalPixelType),
bool itkNotUsed(isVectorImage)) ITK_OVERRIDE{}
protected:
/** Constructor.*/
MWImageIO();
/** Destructor.*/
~MWImageIO() ITK_OVERRIDE;
bool OpenOneraDataFileForReading(const char* filename);
bool OpenOneraHeaderFileForReading(const char* filename);
void InternalReadImageInformation();
bool OpenOneraDataFileForWriting(const char* filename);
bool OpenOneraHeaderFileForWriting(const char* filename);
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
private:
MWImageIO(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
/** Internal method to read filename extension */
std::string GetExtension(const std::string& filename);
/** Internal method to read header information */
bool InternalReadHeaderInformation(std::fstream& file, const bool reportError);
inline void ByteSplitting(unsigned short a, unsigned short& low, unsigned short& high)
{
unsigned short b = 255;
low = a & b;
high = (a >> 8) & b;
}
#define otbSwappFileOrderToSystemOrderMacro(StrongType, buffer, buffer_size) \
{ \
typedef itk::ByteSwapper<StrongType> InternalByteSwapperType; \
if (m_ByteOrder != m_FileByteOrder) \
{ \
if (m_ByteOrder == LittleEndian) \
{ \
InternalByteSwapperType::SwapRangeFromSystemToBigEndian((StrongType *) buffer, buffer_size); \
} \
else if (m_ByteOrder == BigEndian) \
{ \
InternalByteSwapperType::SwapRangeFromSystemToLittleEndian((StrongType *) buffer, buffer_size); \
} \
} \
}
#define otbSwappFileToSystemMacro(StrongType, WeakType, buffer, buffer_size) \
else if (this->GetComponentType() == WeakType) \
{ \
otbSwappFileOrderToSystemOrderMacro(StrongType, buffer, buffer_size) \
}
bool m_FlagWriteImageInformation;
std::string m_TypeMW; //used for write
otb::ImageIOBase::ByteOrder m_FileByteOrder;
std::fstream m_File;
unsigned int m_Ncom;
};
} // end namespace otb
#endif // otbMWImageIO_h
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef otbMWImageIOFactory_h
#define otbMWImageIOFactory_h
#include "itkObjectFactoryBase.h"
namespace otb
{
/** \class MWImageIOFactory
* \brief Creation d'un instance d'un objet LUMImageIO utilisant les object factory.
*
* \ingroup OTBIOMW
*/
class ITK_EXPORT MWImageIOFactory : public itk::ObjectFactoryBase
{
public:
/** Standard class typedefs. */
typedef MWImageIOFactory Self;
typedef itk::ObjectFactoryBase Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Class methods used to interface with the registered factories. */
const char* GetITKSourceVersion(void) const ITK_OVERRIDE;
const char* GetDescription(void) const ITK_OVERRIDE;
/** Method for class instantiation. */
itkFactorylessNewMacro(Self);
static MWImageIOFactory * FactoryNew() { return new MWImageIOFactory; }
/** Run-time type information (and related methods). */
itkTypeMacro(MWImageIOFactory, itk::ObjectFactoryBase);
/** Register one factory of this type */
static void RegisterOneFactory(void)
{
MWImageIOFactory::Pointer MWFactory = MWImageIOFactory::New();
itk::ObjectFactoryBase::RegisterFactory(MWFactory);
}
protected:
MWImageIOFactory();
~MWImageIOFactory() ITK_OVERRIDE;
private:
MWImageIOFactory(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
};
} // end namespace otb
#endif
set(DOCUMENTATION "This module contains features to read MW format images.")
otb_module(OTBIOMW
DEPENDS
OTBImageBase
OTBCommon
OTBITK
TEST_DEPENDS
OTBTestKernel
DESCRIPTION
"${DOCUMENTATION}"
)
set(OTBIOMW_SRC
otbMWImageIOFactory.cxx
otbMWImageIO.cxx
)
add_library(OTBIOMW ${OTBIOMW_SRC})
target_link_libraries(OTBIOMW
${OTBImageBase_LIBRARIES}
${OTBCommon_LIBRARIES}
)
otb_module_target(OTBIOMW)
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbMWImageIO.h"
#include "itkByteSwapper.h"
#include "otbSystem.h"
#include "itksys/SystemTools.hxx"
#include "otbMacro.h"
namespace otb
{
MWImageIO::MWImageIO()
{
// By default set number of dimensions to two.
this->SetNumberOfDimensions(2);
m_PixelType = SCALAR;
m_ComponentType = UCHAR;
if (itk::ByteSwapper<char>::SystemIsLittleEndian() == true)
{
m_ByteOrder = LittleEndian;
}
else
{
m_ByteOrder = BigEndian;
}
m_FileByteOrder = BigEndian;
// Set default spacing to one
m_Spacing[0] = 1.0;
m_Spacing[1] = 1.0;
// Set default origin to [0.5 , 0.5]
// (consistency between ImageIO, see Mantis #942)
m_Origin[0] = 0.5;
m_Origin[1] = 0.5;
m_FlagWriteImageInformation = true;
m_Ncom = 0;
this->AddSupportedWriteExtension(".img");
this->AddSupportedWriteExtension(".IMG");
this->AddSupportedWriteExtension(".mw");
this->AddSupportedWriteExtension(".MW");
this->AddSupportedReadExtension(".img");
this->AddSupportedReadExtension(".IMG");
this->AddSupportedReadExtension(".mw");
this->AddSupportedReadExtension(".MW");
}
MWImageIO::~MWImageIO()
{
if (m_File.is_open())
{
m_File.close();
}
}
bool MWImageIO::CanReadFile(const char* filename)
{
std::string lFileName(filename);
// Test the extension
std::string extension = GetExtension(filename);
if ((extension != "img") && (extension != "") && (extension != "mw")) return false;
if (itksys::SystemTools::FileIsDirectory(lFileName.c_str()) == true) return false;
if (m_File.is_open()) m_File.close();
std::fstream header_file;
header_file.open(filename, std::ios::in | std::ios::binary);
if (header_file.fail())
{
otbMsgDevMacro(<< "MWImageIO::CanReadFile() failed header open ! ");
return false;
}
//Read header information
bool lResult = InternalReadHeaderInformation(header_file, false);
header_file.close();
return (lResult);
}
// Used to print information about this object
void MWImageIO::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
// Read a 3D image (or event more bands)... not implemented yet
void MWImageIO::ReadVolume(void*)
{
}
// Read image
void MWImageIO::Read(void* buffer)
{
char * p = static_cast<char *>(buffer);
int lNbLignes = this->GetIORegion().GetSize()[1];
int lNbColonnes = this->GetIORegion().GetSize()[0];
int lPremiereLigne = this->GetIORegion().GetIndex()[1]; // [1... ]
int lPremiereColonne = this->GetIORegion().GetIndex()[0]; // [1... ]
otbMsgDevMacro(<< " MWImageIO::Read() ");
otbMsgDevMacro(<< " Dimensions de l'image : " << m_Dimensions[0] << "," << m_Dimensions[1]);
otbMsgDevMacro(<< " Region lue (IORegion) : " << this->GetIORegion());
otbMsgDevMacro(<< " Nb Of Components : " << this->GetNumberOfComponents());
std::streamoff headerLength =
static_cast<std::streamoff> (64 * sizeof(char)) + static_cast<std::streamoff> (m_Ncom * sizeof(char));
std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(this->GetComponentSize() * m_Dimensions[0]);
std::streamoff offset;
std::streamsize numberOfBytesToBeRead = static_cast<std::streamsize>(this->GetComponentSize() * lNbColonnes);
std::streamsize numberOfBytesRead;
std::streamsize cpt = 0;
for (int LineNo = lPremiereLigne; LineNo < lPremiereLigne + lNbLignes; LineNo++)
{
offset = headerLength + numberOfBytesPerLines * static_cast<std::streamoff>(LineNo);
offset += static_cast<std::streamoff>(this->GetComponentSize() * lPremiereColonne);
m_File.seekg(offset, std::ios::beg);
m_File.read(static_cast<char *>(p + cpt), numberOfBytesToBeRead);
numberOfBytesRead = m_File.gcount();
#ifdef __APPLE_CC__
// fail() is broken in the Mac. It returns true when reaches eof().
if (numberOfBytesRead != numberOfBytesToBeRead)
#else
if ((numberOfBytesRead != numberOfBytesToBeRead) || m_File.fail())
#endif
{
itkExceptionMacro(<< "MWImageIO::Read() Can Read the specified Region"); // read failed
}
cpt += numberOfBytesToBeRead;
}
unsigned long numberOfPixelsPerLines = lNbLignes * lNbColonnes;
// Swap bytes if necessary
if (0) {}
otbSwappFileToSystemMacro(float, FLOAT, buffer, numberOfPixelsPerLines)
else
{
itkExceptionMacro(<< "MWImageIO::Read() undefined component type! ");
}
}
void MWImageIO::ReadImageInformation()
{
if (m_File.is_open())
{
m_File.close();
}
m_File.open(m_FileName.c_str(), std::ios::in | std::ios::binary);
if (m_File.fail())
{
itkExceptionMacro(<< "MWImageIO::ReadImageInformation() failed header open ! ");
}
//Read header information
InternalReadHeaderInformation(m_File, true);
otbMsgDebugMacro(<< "Driver to read: MW");
otbMsgDebugMacro(<< " Read file : " << m_FileName);
otbMsgDebugMacro(<< " Size : " << m_Dimensions[0] << "," << m_Dimensions[1]);
otbMsgDebugMacro(<< " ComponentType : " << this->GetComponentType());
otbMsgDebugMacro(<< " NumberOfComponents : " << this->GetNumberOfComponents());
otbMsgDebugMacro(<< " ComponentSize : " << this->GetComponentSize());
otbMsgDebugMacro(<< " GetPixelSize : " << this->GetPixelSize());
}
bool MWImageIO::InternalReadHeaderInformation(std::fstream& file, const bool reportError)
{
char * headerInformation = new char[64];
file.seekg(0, std::ios::beg);
file.read(headerInformation, 64);
unsigned short NbCol(0);
unsigned short NbLig(0);
unsigned short Nbcom(0);
//Set file byte order
if (headerInformation[0] == *("R") || headerInformation[1] == *("I"))
{
m_FileByteOrder = BigEndian;
//Read image dimensions
Nbcom = (static_cast<unsigned int>(headerInformation[3]) << 8) + static_cast<unsigned char> (headerInformation[2]);
m_Ncom = Nbcom;
NbCol = (static_cast<unsigned int>(headerInformation[5]) << 8) + static_cast<unsigned char> (headerInformation[4]);
NbLig = (static_cast<unsigned int>(headerInformation[7]) << 8) + static_cast<unsigned char> (headerInformation[6]);
}
else if (headerInformation[0] == *("I") || headerInformation[1] == *("R"))
{
m_FileByteOrder = LittleEndian;
//Read image dimensions
Nbcom = ((static_cast<unsigned int>(headerInformation[2])) << 8) + static_cast<unsigned char> (headerInformation[3]);
m_Ncom = Nbcom;
NbCol = ((static_cast<unsigned int>(headerInformation[4])) << 8) + static_cast<unsigned char> (headerInformation[5]);
NbLig = ((static_cast<unsigned int>(headerInformation[6])) << 8) + static_cast<unsigned char> (headerInformation[7]);
}
else
{
delete [] headerInformation;
if (reportError == true)
{
itkExceptionMacro(<< "MW : impossible to determine CodePix information of the image");
}
return false;
}
SetComponentType(FLOAT);
//Initialization of image information
m_Dimensions[0] = NbCol;
m_Dimensions[1] = NbLig;
this->SetNumberOfComponents(1);
this->SetFileTypeToBinary();
this->SetNumberOfDimensions(2);
delete[] headerInformation;
return (true);
}
bool MWImageIO::CanWriteFile(const char* filename)
{
std::string lFileName(filename);
std::string extension = GetExtension(filename);
if (extension != "mw") return false;
if (itksys::SystemTools::FileIsDirectory(lFileName.c_str()) == true) return false;
return true;
}
void MWImageIO::Write(const void* buffer)
{
if (m_FlagWriteImageInformation == true)
{
this->WriteImageInformation();
m_FlagWriteImageInformation = false;
}
unsigned long lNbLignes = this->GetIORegion().GetSize()[1];
unsigned long lNbColonnes = this->GetIORegion().GetSize()[0];
unsigned long lPremiereLigne = this->GetIORegion().GetIndex()[1]; // [1... ]
int lPremiereColonne = this->GetIORegion().GetIndex()[0]; // [1... ]
if ((lNbLignes == m_Dimensions[1]) && (lNbColonnes == m_Dimensions[0]))
{
otbMsgDevMacro(<< "Forcing offset to [0, 0]");
lPremiereLigne = 0;
lPremiereColonne = 0;
}
otbMsgDevMacro(<< " MWImageIO::Write() ");
otbMsgDevMacro(<< " Dimensions de l'image : " << m_Dimensions[0] << "," << m_Dimensions[1]);
otbMsgDevMacro(<< " Region lue (IORegion) : " << this->GetIORegion());
otbMsgDevMacro(<< " Nb Of Components : " << this->GetNumberOfComponents());
otbMsgDevMacro(<< " GetComponentSize : " << this->GetComponentSize());
std::streamoff numberOfBytesPerLines = this->GetComponentSize() * m_Dimensions[0];
std::streamoff headerLength =
static_cast<std::streamoff> (64 * sizeof(char)) + static_cast<std::streamoff> (m_Ncom * sizeof(char));
std::streamoff offset;
std::streamsize numberOfBytesToBeWrite = this->GetComponentSize() * lNbColonnes;
// std::streamsize numberOfBytesToBeWriteFloat = sizeof(float) * lNbColonnes;
std::streamsize cpt = 0;
const char * p = static_cast<const char *>(buffer);
// const float * p = dynamic_cast<const float *>(buffer);
// float floatImage[m_Dimensions[0]*m_Dimensions[1]];
// std::streamsize counter = 0;
// std::cout << "begin conversion" << std::endl;
// for (unsigned int i=0; i<m_Dimensions[0]*m_Dimensions[1]; ++i)
// {
// floatImage[i] = static_cast< float > ( *(p+counter) );
// std::cout << "float " << floatImage[i] << std::endl;
// counter+=sizeof(char);
// }
for (unsigned long LineNo = lPremiereLigne; LineNo < lPremiereLigne + lNbLignes; LineNo++)
{
offset = headerLength + numberOfBytesPerLines * static_cast<std::streamoff>(LineNo);
offset += static_cast<std::streamoff>(this->GetComponentSize() * lPremiereColonne);
m_File.seekp(offset, std::ios::beg);
m_File.write(static_cast<const char *>(p + cpt), numberOfBytesToBeWrite);
// m_File.write( (char *)( floatImage + cpt ), numberOfBytesToBeWriteFloat );
cpt += numberOfBytesToBeWrite;
}
}
void MWImageIO::WriteImageInformation()
{
if (m_FileName == "")
{
itkExceptionMacro(<< "A FileName must be specified.");
}
if (CanWriteFile(m_FileName.c_str()) == false)
{
itkExceptionMacro(<< "The file " << m_FileName.c_str() << " is not defined as a MW file");
}
// Close file from any previous image
if (m_File.is_open())
{
m_File.close();
}
// Open the new file for writing
// Actually open the file
m_File.open(m_FileName.c_str(), std::ios::out | std::ios::trunc | std::ios::binary);
if (m_File.fail())
{
itkExceptionMacro(<< "Cannot write requested file " << m_FileName.c_str() << ".");
}
//Comment by MG to review write process
//Writing header information
// if ( 0 ) {}
// if ( (this->GetComponentType() != FLOAT) )
// {
// itkExceptionMacro(<< "MegaWave fimage format only accepts FLOAT32 data type");
// }
m_ComponentType = FLOAT;
m_File.seekp(0, std::ios::beg);
char header[64];
std::string comments("Image written with otb mw_IO_factory");
m_Ncom = comments.length();
//Initialization to 0
for (unsigned int i = 0; i < 64; ++i)
header[i] = static_cast<unsigned char>(0);
//Write image size and other information
unsigned short lNbComments = m_Ncom;
unsigned short lNbLignes = static_cast<unsigned short>(this->GetIORegion().GetSize()[1]);
unsigned short lNbColonnes = static_cast<unsigned short>(this->GetIORegion().GetSize()[0]);
unsigned short low, high;
if (m_ByteOrder == BigEndian)
{
header[0] = *("R");
header[1] = *("I");
ByteSplitting(lNbComments, low, high);
header[2] = static_cast<unsigned char>(low);
header[3] = static_cast<unsigned char>(high);
ByteSplitting(lNbColonnes, low, high);
header[4] = static_cast<unsigned char>(low);
header[5] = static_cast<unsigned char>(high);
ByteSplitting(lNbLignes, low, high);
header[6] = static_cast<unsigned char>(low);
header[7] = static_cast<unsigned char>(high);
}
else if (m_ByteOrder == LittleEndian)
{
header[0] = *("I");
header[1] = *("R");
ByteSplitting(lNbComments, low, high);
header[3] = static_cast<unsigned char>(low);
header[2] = static_cast<unsigned char>(high);
ByteSplitting(lNbColonnes, low, high);
header[5] = static_cast<unsigned char>(low);
header[4] = static_cast<unsigned char>(high);
ByteSplitting(lNbLignes, low, high);
header[7] = static_cast<unsigned char>(low);
header[6] = static_cast<unsigned char>(high);
}
else
{
itkExceptionMacro(<< "Unknown Byte order");
}
m_File.write(header, 64);
m_File.write(comments.data(), 36);
otbMsgDebugMacro(<< "Driver to write: MW");
otbMsgDebugMacro(<< " Write file : " << m_FileName);
otbMsgDebugMacro(<< " Size : " << m_Dimensions[0] << "," << m_Dimensions[1]);
otbMsgDebugMacro(<< " Type Mw : " << m_TypeMW);
otbMsgDebugMacro(<< " ComponentType : " << this->GetComponentType());
otbMsgDebugMacro(<< " NumberOfComponents : " << this->GetNumberOfComponents());
otbMsgDebugMacro(<< " ComponentSize : " << this->GetComponentSize());
otbMsgDebugMacro(<< " GetPixelSize : " << this->GetPixelSize());
}
std::string MWImageIO::GetExtension(const std::string& filename)
{
// This assumes that the final '.' in a file name is the delimiter
// for the file's extension type
const std::string::size_type it = filename.find_last_of(".");
// This determines the file's type by creating a new string
// who's value is the extension of the input filename
// eg. "myimage.gif" has an extension of "gif"
std::string fileExt(filename, it + 1, filename.length());
//If the extension has a "/" in it then this is not an extension and there are no extension.
std::string::size_type it2 = fileExt.find_last_of("/");
if (it2 != std::string::npos)
{
std::string fileExt3("");
return (fileExt3);
}
return (fileExt);
}
} // end namespace otb
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbMWImageIOFactory.h"
#include "itkCreateObjectFunction.h"
#include "otbMWImageIO.h"
#include "itkVersion.h"
namespace otb
{
MWImageIOFactory::MWImageIOFactory()
{
this->RegisterOverride("otbImageIOBase",
"otbMWImageIO",
"MW Image IO",
1,
itk::CreateObjectFunction<MWImageIO>::New());
}
MWImageIOFactory::~MWImageIOFactory()
{
}
const char*
MWImageIOFactory::GetITKSourceVersion(void) const
{
return ITK_SOURCE_VERSION;
}
const char*
MWImageIOFactory::GetDescription() const
{
return "MegaWave ImageIO Factory, permettant le chargement d'image au format MW dans l'OTB";
}
// Undocumented API used to register during static initialization.
// DO NOT CALL DIRECTLY.
static bool MWImageIOFactoryHasBeenRegistered;
void MWImageIOFactoryRegister__Private(void)
{
if( ! MWImageIOFactoryHasBeenRegistered )
{
MWImageIOFactoryHasBeenRegistered = true;
MWImageIOFactory::RegisterOneFactory();
}
}
} // end namespace otb
otb_module_test()
set(OTBIOMWTests
otbIOMWTestDriver.cxx
otbMWImageIOTestCanRead.cxx
otbMWImageIOTestCanWrite.cxx
)
add_executable(otbIOMWTestDriver ${OTBIOMWTests})
target_link_libraries(otbIOMWTestDriver ${OTBIOMW-Test_LIBRARIES})
otb_module_target_label(otbIOMWTestDriver)
# Tests Declaration
otb_add_test(NAME ioTuMWImageIOCanReadIMG COMMAND otbIOMWTestDriver otbMWImageIOTestCanRead
${BASELINE}/QB_Toulouse_Ortho_PAN.img)
otb_add_test(NAME ioTuMWImageIOCanReadMW COMMAND otbIOMWTestDriver otbMWImageIOTestCanRead
${BASELINE}/QB_Toulouse_Ortho_PAN.mw)
otb_add_test(NAME ioTuMWImageIOCanWriteIMG COMMAND otbIOMWTestDriver otbMWImageIOTestCanWrite
${TEMP}/QB_Toulouse_Ortho_PAN.img)
set_property(TEST ioTuMWImageIOCanWriteIMG PROPERTY WILL_FAIL true)
otb_add_test(NAME ioTuMWImageIOCanWriteMW COMMAND otbIOMWTestDriver otbMWImageIOTestCanWrite
${TEMP}/QB_Toulouse_Ortho_PAN.mw)
#include "otbTestMain.h"
void RegisterTests()
{
REGISTER_TEST(otbMWImageIOTestCanRead);
REGISTER_TEST(otbMWImageIOTestCanWrite);
}
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbMWImageIO.h"
#include "itkMacro.h"
#include <iostream>
int otbMWImageIOTestCanRead(int itkNotUsed(argc), char* argv[])
{
otb::MWImageIO::Pointer lMWImageIO = otb::MWImageIO::New();
bool lCanRead = lMWImageIO->CanReadFile(argv[1]);
if (lCanRead == false)
{
std::cerr << "Error otb::MWImageIO : impossible to read MW image " << argv[1] << "." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbMWImageIO.h"
#include "itkMacro.h"
#include <iostream>
int otbMWImageIOTestCanWrite(int itkNotUsed(argc), char* argv[])
{
otb::MWImageIO::Pointer lMWImageIO = otb::MWImageIO::New();
bool lCanRead = lMWImageIO->CanWriteFile(argv[1]);
if (lCanRead == false)
{
std::cerr << "Error image " << argv[1] << " is not a MW image." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
...@@ -10,7 +10,6 @@ otb_module(OTBImageIO ...@@ -10,7 +10,6 @@ otb_module(OTBImageIO
OTBIOGDAL OTBIOGDAL
OTBIOLUM OTBIOLUM
OTBIOMSTAR OTBIOMSTAR
OTBIOMW
OTBIOONERA OTBIOONERA
OTBIORAD OTBIORAD
OTBIOTileMap OTBIOTileMap
......
...@@ -8,7 +8,6 @@ target_link_libraries(OTBImageIO ...@@ -8,7 +8,6 @@ target_link_libraries(OTBImageIO
${OTBIOONERA_LIBRARIES} ${OTBIOONERA_LIBRARIES}
${OTBIOLUM_LIBRARIES} ${OTBIOLUM_LIBRARIES}
${OTBImageBase_LIBRARIES} ${OTBImageBase_LIBRARIES}
${OTBIOMW_LIBRARIES}
${OTBIOMSTAR_LIBRARIES} ${OTBIOMSTAR_LIBRARIES}
${OTBIOBSQ_LIBRARIES} ${OTBIOBSQ_LIBRARIES}
${OTBIOGDAL_LIBRARIES} ${OTBIOGDAL_LIBRARIES}
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "otbLUMImageIOFactory.h" #include "otbLUMImageIOFactory.h"
#include "otbBSQImageIOFactory.h" #include "otbBSQImageIOFactory.h"
#include "otbRADImageIOFactory.h" #include "otbRADImageIOFactory.h"
#include "otbMWImageIOFactory.h"
#include "otbTileMapImageIOFactory.h" #include "otbTileMapImageIOFactory.h"
...@@ -98,7 +97,6 @@ ImageIOFactory::RegisterBuiltInFactories() ...@@ -98,7 +97,6 @@ ImageIOFactory::RegisterBuiltInFactories()
itk::ObjectFactoryBase::RegisterFactory(LUMImageIOFactory::New()); itk::ObjectFactoryBase::RegisterFactory(LUMImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(TileMapImageIOFactory::New()); itk::ObjectFactoryBase::RegisterFactory(TileMapImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(GDALImageIOFactory::New()); itk::ObjectFactoryBase::RegisterFactory(GDALImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(MWImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(ONERAImageIOFactory::New()); itk::ObjectFactoryBase::RegisterFactory(ONERAImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(MSTARImageIOFactory::New()); itk::ObjectFactoryBase::RegisterFactory(MSTARImageIOFactory::New());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment