Commit 94c8c3c5 authored by Sébastien Dinot's avatar Sébastien Dinot

LICENSE: Merge existing work in relation to the license migration

parents f8d5877c b37be480
......@@ -16,7 +16,6 @@ David Dubois,
David Youssefi (CNES Intern, then CS),
Edouard Barthelet (Telecom Bretagne and Thales Communications),
Emmanuel Christophe (CNES, then CRISP, then Google),
Eric Bughin (CMLA),
Etienne Bougoin (CS),
Gr\'egoire Mercier (Telecom Bretagne),
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)
This diff is collapsed.
/*=========================================================================
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
OTBIOGDAL
OTBIOLUM
OTBIOMSTAR
OTBIOMW
OTBIOONERA
OTBIORAD
OTBIOTileMap
......
......@@ -8,7 +8,6 @@ target_link_libraries(OTBImageIO
${OTBIOONERA_LIBRARIES}
${OTBIOLUM_LIBRARIES}
${OTBImageBase_LIBRARIES}
${OTBIOMW_LIBRARIES}
${OTBIOMSTAR_LIBRARIES}
${OTBIOBSQ_LIBRARIES}
${OTBIOGDAL_LIBRARIES}
......
......@@ -29,7 +29,6 @@
#include "otbLUMImageIOFactory.h"
#include "otbBSQImageIOFactory.h"
#include "otbRADImageIOFactory.h"
#include "otbMWImageIOFactory.h"
#include "otbTileMapImageIOFactory.h"
......@@ -98,7 +97,6 @@ ImageIOFactory::RegisterBuiltInFactories()
itk::ObjectFactoryBase::RegisterFactory(LUMImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(TileMapImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(GDALImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(MWImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(ONERAImageIOFactory::New());
itk::ObjectFactoryBase::RegisterFactory(MSTARImageIOFactory::New());
......
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