diff --git a/CMakeLists.txt b/CMakeLists.txt index 690500e7a1eeaace3765a4df9cc1961fe288bab7..5b3f5f20586b314c715997269e12affe9ba4d3b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ IF(OTB_USE_VISU_GUI) # MESSAGE("FLUID_COMMAND -> ${FLUID_COMMAND}") # MESSAGE("FLTK_BINARY_DIR -> ${FLTK_BINARY_DIR}") # MESSAGE("FLTK_USE_FILE -> ${FLTK_USE_FILE}") -# MESSAGE("FLTK_INCLUDE_DIRS -> ${FLTK_INCLUDE_DIRS}") + MESSAGE("FLTK_INCLUDE_DIRS -> ${FLTK_INCLUDE_DIRS}") # MESSAGE("FLTK_LIBRARY_DIRS -> ${FLTK_LIBRARY_DIRS}") # MESSAGE("FLTK_LIBRARIES -> ${FLTK_LIBRARIES}") # MESSAGE("FLTK_DIR -> ${FLTK_DIR}") @@ -196,6 +196,88 @@ ENDIF(OTB_USE_VISU_GUI) #MESSAGE("FLTK_EXECUTABLE_DIRS -> ${FLTK_EXECUTABLE_DIRS}") #MESSAGE("OTB_VISU_GUI_LIBRARIES -> ${OTB_VISU_GUI_LIBRARIES}") +#------------------------------- +# Librairie ITK +#------------------------------- + +OPTION(OTB_USE_EXTERNAL_ITK "Use an outside build of ITK." OFF) +IF(OTB_USE_EXTERNAL_ITK) + FIND_PACKAGE(ITK) + IF(ITK_FOUND) + INCLUDE(${ITK_USE_FILE}) + ELSE(ITK_FOUND) + MESSAGE(FATAL_ERROR + "Cannot build OTB project without ITK. Please set ITK_DIR or set OTB_USE_EXTERNAL_ITK OFF to use INTERNAL ITK set on OTB/Utilities repository.") + ENDIF(ITK_FOUND) +ENDIF(OTB_USE_EXTERNAL_ITK) + +#SET(CURL_INCLUDE_DIR ) +#MARK_AS_ADVANCED(CURL_INCLUDE_DIRS) +#SET(CURL_LIBRARY ) +#MARK_AS_ADVANCED(CURL_LIBRARY_DIRS) + +#------------------------------- +# CURL Library +#------------------------------- +OPTION(OTB_USE_CURL "Use curl library." OFF) +MARK_AS_ADVANCED(OTB_USE_CURL) +IF(OTB_USE_CURL) + +# INCLUDE(CheckIncludeFiles) +# INCLUDE(CheckLibraryExists) +# CHECK_INCLUDE_FILES("curl/curl.h" OTB_HAVE_CURL_HEADER) +# CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" OTB_HAVE_CURL_LIBRARY) +# IF( NOT OTB_HAVE_CURL_HEADER ) +# MESSAGE("Cannot find CURL include directory. Please set CURL_INCLUDE_DIRS or SET OTB_USE_CURL OFF.") +# ENDIF( NOT OTB_HAVE_CURL_HEADER) +# IF( NOT OTB_HAVE_CURL_LIBRARY ) +# MESSAGE("Cannot find CURL include directory. Please set CURL_LIBRARY_DIRS or SET OTB_USE_CURL OFF.") +# ENDIF( NOT OTB_HAVE_CURL_LIBRARY) + + FIND_PATH(CURL_INCLUDE_DIR curl/curl.h PATHS) + MARK_AS_ADVANCED(CURL_INCLUDE_DIR) + IF (NOT CURL_INCLUDE_DIR) + MESSAGE(FATAL_ERROR + "Cannot find CURL include directory. Please set CURL_INCLUDE_DIR or SET OTB_USE_CURL OFF.") + ENDIF (NOT CURL_INCLUDE_DIR) + + FIND_LIBRARY(CURL_LIBRARY curl ) + MARK_AS_ADVANCED(CURL_LIBRARY) + IF (NOT CURL_LIBRARY) + MESSAGE(FATAL_ERROR + "Cannot find CURL library. Please set CURL_LIBRARY or SET OTB_USE_CURL OFF.") + ENDIF (NOT CURL_LIBRARY) + + # Add compiler option + ADD_DEFINITIONS(-DOTB_USE_CURL) + + INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR}) + +ENDIF(OTB_USE_CURL) + + +#------------------------------- +# GDAL Library +#------------------------------- + +#FIND_LIBRARY(GDAL_LIBRARY_DIRS gdal PATHS $ENV{GDAL_LIBRARY_DIRS} ) + +FIND_PATH(GDAL_LIBRARY_DIRS gdal PATHS $ENV{GDAL_LIBRARY_DIRS} ) +FIND_PATH(GDAL_INCLUDE_DIRS gdal.h $ENV{GDAL_INCLUDE_DIRS} /usr/include/gdal) +IF (NOT GDAL_LIBRARY_DIRS) +MESSAGE(FATAL_ERROR + "Cannot find GDAL library directory. Please set GDAL_LIBRARY_DIRS.") +ENDIF (NOT GDAL_LIBRARY_DIRS) +IF (NOT GDAL_INCLUDE_DIRS) +MESSAGE(FATAL_ERROR + "Cannot find GDAL include directory. Please set GDAL_INCLUDE_DIRS.") +ENDIF (NOT GDAL_INCLUDE_DIRS) + + +INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIRS}) +LINK_DIRECTORIES( ${GDAL_LIBRARY_DIRS} ) + + #------------------------------- # ITK Library diff --git a/Code/IO/otbImageIOFactory.cxx b/Code/IO/otbImageIOFactory.cxx index 61f40c983983bc7b6d85bb16d31ac871dd085d7d..5217a33aa2468377b57b9bf46052dec28f00ef26 100755 --- a/Code/IO/otbImageIOFactory.cxx +++ b/Code/IO/otbImageIOFactory.cxx @@ -28,6 +28,7 @@ #include "otbGDALImageIOFactory.h" #include "otbLUMImageIOFactory.h" #include "otbBSQImageIOFactory.h" +#include "otbJPEG2000ImageIOFactory.h" #ifdef OTB_USE_CURL #include "otbNetworkedQuadTreeImageIOFactory.h" #endif @@ -69,6 +70,9 @@ ImageIOFactory::RegisterBuiltInFactories() // GDAL : New format for OTB itk::ObjectFactoryBase::RegisterFactory( GDALImageIOFactory::New() ); + // JPEG2000 : New format for OTB + itk::ObjectFactoryBase::RegisterFactory( JPEG2000ImageIOFactory::New() ); + #ifdef OTB_USE_CURL // NetworkedQuadTree : New format for OTB itk::ObjectFactoryBase::RegisterFactory( NetworkedQuadTreeImageIOFactory::New() ); diff --git a/Code/IO/otbJPEG2000ImageIO.cxx b/Code/IO/otbJPEG2000ImageIO.cxx new file mode 100755 index 0000000000000000000000000000000000000000..341482911d9dd77f61cb5934e5362516b8b6833d --- /dev/null +++ b/Code/IO/otbJPEG2000ImageIO.cxx @@ -0,0 +1,170 @@ +/*========================================================================= + + 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 "otbJPEG2000ImageIO.h" + +#include "itkExceptionObject.h" +#include "otbMacro.h" + +#include "otbSystem.h" + +namespace otb +{ + +JPEG2000ImageIO::JPEG2000ImageIO() +{ + // By default set number of dimensions to two. + this->SetNumberOfDimensions(2); + m_PixelType = SCALAR; + m_ComponentType = UCHAR; + + // Set default spacing to one + m_Spacing[0] = 1.0; + m_Spacing[1] = 1.0; + // Set default origin to zero + m_Origin[0] = 0.0; + m_Origin[1] = 0.0; +} + +JPEG2000ImageIO::~JPEG2000ImageIO() +{ +} + +bool JPEG2000ImageIO::CanReadFile( const char* filename ) +{ + return false; +} + + +// Used to print information about this object +void JPEG2000ImageIO::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + +// Read a 3D image (or event more bands)... not implemented yet +void JPEG2000ImageIO::ReadVolume(void*) +{ +} + +// Read image +void JPEG2000ImageIO::Read(void* buffer) +{ + unsigned long step = this->GetNumberOfComponents(); + 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( <<" JPEG2000ImageIO::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(0); + std::streamoff numberOfBytesPerLines = static_cast<std::streamoff>(this->GetComponentSize() * m_Dimensions[0]); + std::streamoff offset; + std::streamsize numberOfBytesToBeRead = this->GetComponentSize() * lNbColonnes; + std::streamsize numberOfBytesRead; + unsigned long cpt = 0; + + // Update the step variable + step = step * (unsigned long)(this->GetComponentSize()); + + char * value = new char[numberOfBytesToBeRead]; + if(value==NULL) + { + itkExceptionMacro(<<"Memory bad alloc"); + return; + } + + + + + + delete [] value; + +} + + +void JPEG2000ImageIO::ReadImageInformation() +{ + + +otbMsgDebugMacro( <<"Driver to read: JPEG2000"); +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 JPEG2000ImageIO::CanWriteFile( const char* filename ) +{ +return false; +#if 0 + std::string lFileName(filename); + if( System::IsADirName(lFileName) == true ) + { + return false; + } + const std::string Extension = System::GetExtension(filename); + if( (Extension == "j2k") || (Extension == "J2K") || (Extension == "jp2") || (Extension == "JP2")) + { + return true; + } + else + { + return false; + } +#endif +} + +void JPEG2000ImageIO::Write(const void* buffer) +{ +} + + +void JPEG2000ImageIO::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 JPEG2000 file"); + } + +otbMsgDebugMacro( <<"Driver to write: JPEG2000"); +otbMsgDebugMacro( <<" Write 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()); + +} + + +} // end namespace otb + diff --git a/Code/IO/otbJPEG2000ImageIO.h b/Code/IO/otbJPEG2000ImageIO.h new file mode 100755 index 0000000000000000000000000000000000000000..5fbed2eeee96636677eeffcf81cfbc35f542e958 --- /dev/null +++ b/Code/IO/otbJPEG2000ImageIO.h @@ -0,0 +1,102 @@ +/*========================================================================= + + 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 __otbJPEG2000ImageIO_h +#define __otbJPEG2000ImageIO_h + +#include "itkImageIOBase.h" + + +namespace otb +{ + +/** \class JPEG2000ImageIO + * + * \brief ImageIO object for reading and writing JPEG2000 format images + * + * The streaming (read and write) is implemented. + * + * \ingroup IOFilters + * + */ +class ITK_EXPORT JPEG2000ImageIO : public itk::ImageIOBase +{ +public: + + /** Standard class typedefs. */ + typedef JPEG2000ImageIO Self; + typedef itk::ImageIOBase Superclass; + typedef itk::SmartPointer<Self> Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(JPEG2000ImageIO, itk::ImageIOBase); + + /*-------- This part of the interface deals with reading data. ------ */ + + /** Determine the file type. Returns true if this ImageIO can read the + * file specified. */ + virtual bool CanReadFile(const char*); + + /** Determine the file type. Returns true if the ImageIO can stream read the specified file */ + virtual bool CanStreamRead(){ return true; }; + + /** Set the spacing and dimention information for the set filename. */ + virtual void ReadImageInformation(); + + /** Reads the data from disk into the memory buffer provided. */ + virtual void Read(void* buffer); + + /** 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. */ + virtual bool CanWriteFile(const char*); + + /** Determine the file type. Returns true if the ImageIO can stream write the specified file */ + virtual bool CanStreamWrite() { return true; }; + + /** Writes the spacing and dimentions of the image. + * Assumes SetFileName has been called with a valid file name. */ + virtual void WriteImageInformation(); + + /** Writes the data to disk from the memory buffer provided. Make sure + * that the IORegion has been set properly. */ + virtual void Write(const void* buffer); + +protected: + /** Construtor.*/ + JPEG2000ImageIO(); + /** Destructor.*/ + ~JPEG2000ImageIO(); + + void PrintSelf(std::ostream& os, itk::Indent indent) const; + +private: + JPEG2000ImageIO(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + +}; + +} // end namespace otb + +#endif // __otbJPEG2000ImageIO_h diff --git a/Code/IO/otbJPEG2000ImageIOFactory.cxx b/Code/IO/otbJPEG2000ImageIOFactory.cxx new file mode 100755 index 0000000000000000000000000000000000000000..d6c22aefdf0b96d865b85d1a8b53cb68d57e8b1d --- /dev/null +++ b/Code/IO/otbJPEG2000ImageIOFactory.cxx @@ -0,0 +1,54 @@ +/*========================================================================= + + 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 "otbJPEG2000ImageIOFactory.h" + +#include "itkCreateObjectFunction.h" +#include "otbJPEG2000ImageIO.h" +#include "itkVersion.h" + + +namespace otb +{ + +JPEG2000ImageIOFactory::JPEG2000ImageIOFactory() +{ + this->RegisterOverride("itkImageIOBase", + "otbJPEG2000ImageIO", + "JPEG2000 Image IO", + 1, + itk::CreateObjectFunction<JPEG2000ImageIO>::New()); +} + +JPEG2000ImageIOFactory::~JPEG2000ImageIOFactory() +{ +} + +const char* +JPEG2000ImageIOFactory::GetITKSourceVersion(void) const +{ + return ITK_SOURCE_VERSION; +} + +const char* +JPEG2000ImageIOFactory::GetDescription() const +{ + return "JPEG2000 ImageIO Factory, allows the loading of JPEG2000 images into insight"; +} + +} // end namespace otb + diff --git a/Code/IO/otbJPEG2000ImageIOFactory.h b/Code/IO/otbJPEG2000ImageIOFactory.h new file mode 100755 index 0000000000000000000000000000000000000000..c305a66f081d4f13693cb563aa77a2e6276a190d --- /dev/null +++ b/Code/IO/otbJPEG2000ImageIOFactory.h @@ -0,0 +1,68 @@ +/*========================================================================= + + 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 __otbJPEG2000ImageIOFactory_h +#define __otbJPEG2000ImageIOFactory_h + +#include "itkObjectFactoryBase.h" +#include "itkImageIOBase.h" + +namespace otb +{ +/** \class JPEG2000ImageIOFactory + * \brief Create instances of JPEG2000ImageIO objects using an object factory. + */ +class ITK_EXPORT JPEG2000ImageIOFactory : public itk::ObjectFactoryBase +{ +public: + /** Standard class typedefs. */ + typedef JPEG2000ImageIOFactory 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. */ + virtual const char* GetITKSourceVersion(void) const; + virtual const char* GetDescription(void) const; + + /** Method for class instantiation. */ + itkFactorylessNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(JPEG2000ImageIOFactory, itk::ObjectFactoryBase); + + /** Register one factory of this type */ + static void RegisterOneFactory(void) + { + JPEG2000ImageIOFactory::Pointer JPEG2000Factory = JPEG2000ImageIOFactory::New(); + itk::ObjectFactoryBase::RegisterFactory(JPEG2000Factory); + } + +protected: + JPEG2000ImageIOFactory(); + ~JPEG2000ImageIOFactory(); + +private: + JPEG2000ImageIOFactory(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + +}; + + +} // end namespace otb + +#endif diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index 7a97b5640a1f2092cd5708e63a9f1c8553bd8717..39dc072b6465dd0f8c6c73a3a9d64c0255692ca7 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -30,6 +30,7 @@ SET(IO_TESTS9 ${CXX_TEST_PATH}/otbIOTests9) SET(IO_TESTS10 ${CXX_TEST_PATH}/otbIOTests10) SET(IO_TESTS11 ${CXX_TEST_PATH}/otbIOTests11) SET(IO_TESTS12 ${CXX_TEST_PATH}/otbIOTests12) +SET(IO_TESTS13 ${CXX_TEST_PATH}/otbIOTests13) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ COMMON_TESTS3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1211,23 +1212,22 @@ ADD_TEST(ioTvossimElevManagerTest ${IO_TESTS12} 500 ) -#---------------------------------------------------------------------------------- -# Exemples de tests sur les grosses images -# Tests non lanc�s pour raison taille des fichiers produits -# ADD_TEST(ioTvStreamingIFWriterPARIS_SPOT5THR_WithoutStreaming ${IO_TESTS12} -# otbStreamingImageFileWriterTest -# ${IMAGEDATA}/PARIS/SPOT5/THR -# ${TEMP}/ioStreamingImageFileWriterTestCAI_ParisSpot5THR_WithoutStreaming.hd -# 0 # Test sans streaming -# ) -# ADD_TEST(ioTvStreamingIFWriterPARIS_SPOT5THR_WithStreaming_1000 ${IO_TESTS12} -# otbStreamingImageFileWriterTest -# ${IMAGEDATA}/PARIS/SPOT5/THR -# ${TEMP}/ioStreamingImageFileWriterTestCAI_ParisSpot5THR_WithStreaming_1000.hd -# 1 # Test sans streaming -# 1000 # NbDivisionsStreaming -# ) -#---------------------------------------------------------------------------------- +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbIOTESTS13 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +# --- JPEG2000 can read --- +ADD_TEST(ioTuJPEG2000ImageIOCanRead ${IO_TESTS13} + otbJPEG2000ImageIOTestCanRead + ${INPUTDATA}/toto.j2k + ) +# --- JPEG2000 can write --- +ADD_TEST(ioTuJPEG2000ImageIOCanWrite ${IO_TESTS13} + otbJPEG2000ImageIOTestCanWrite + ${INPUTDATA}/toto.j2k + ) + @@ -1314,6 +1314,11 @@ otbImageGeometryHandlerNew.cxx otbOssimElevManagerTest.cxx ) +SET(BasicIO_SRCS13 +otbJPEG2000ImageIOTestCanRead.cxx +otbJPEG2000ImageIOTestCanWrite.cxx +) + INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") ADD_EXECUTABLE(otbIOTests1 otbIOTests1.cxx ${BasicIO_SRCS1}) @@ -1352,6 +1357,9 @@ TARGET_LINK_LIBRARIES(otbIOTests11 OTBIO OTBCommon gdal ITKIO ITKCommon dxf) ADD_EXECUTABLE(otbIOTests12 otbIOTests12.cxx ${BasicIO_SRCS12}) TARGET_LINK_LIBRARIES(otbIOTests12 OTBIO OTBCommon gdal ITKIO ITKCommon dxf) +ADD_EXECUTABLE(otbIOTests13 otbIOTests13.cxx ${BasicIO_SRCS13}) +TARGET_LINK_LIBRARIES(otbIOTests13 OTBIO OTBCommon gdal ITKIO ITKCommon dxf) + ENDIF( NOT OTB_DISABLE_CXX_TESTING ) diff --git a/Testing/Code/IO/otbIOTests13.cxx b/Testing/Code/IO/otbIOTests13.cxx new file mode 100644 index 0000000000000000000000000000000000000000..687c9fc287584dfd4cc6faf95e228494b4b212aa --- /dev/null +++ b/Testing/Code/IO/otbIOTests13.cxx @@ -0,0 +1,33 @@ +/*========================================================================= + + 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. + +=========================================================================*/ + +// this file defines the otbCommonTest for the test driver +// and all it expects is that you have a function called RegisterTests +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include <iostream> +#include "otbTestMain.h" + + +void RegisterTests() +{ +REGISTER_TEST(otbJPEG2000ImageIOTestCanRead); +REGISTER_TEST(otbJPEG2000ImageIOTestCanWrite); +} diff --git a/Testing/Code/IO/otbJPEG2000ImageIOTestCanRead.cxx b/Testing/Code/IO/otbJPEG2000ImageIOTestCanRead.cxx new file mode 100755 index 0000000000000000000000000000000000000000..e1d1d234af8eff582552f3e98fa9de3fdf6f370d --- /dev/null +++ b/Testing/Code/IO/otbJPEG2000ImageIOTestCanRead.cxx @@ -0,0 +1,37 @@ +/*========================================================================= + + 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. + +=========================================================================*/ + +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbJPEG2000ImageIO.h" +#include "itkExceptionObject.h" +#include <iostream> + +int otbJPEG2000ImageIOTestCanRead(int argc, char* argv[]) +{ + otb::JPEG2000ImageIO::Pointer lJPEG2000ImageIO = otb::JPEG2000ImageIO::New(); + bool lCanRead = lJPEG2000ImageIO->CanReadFile(argv[1]); + if ( lCanRead == false) + { + std::cerr << "Erreur otb::JPEG2000ImageIO : impossible to open the image file JPEG2000 "<<argv[1]<<"."<<std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +} diff --git a/Testing/Code/IO/otbJPEG2000ImageIOTestCanWrite.cxx b/Testing/Code/IO/otbJPEG2000ImageIOTestCanWrite.cxx new file mode 100755 index 0000000000000000000000000000000000000000..c369991dabf6551a61ae58813c429a66b68e501c --- /dev/null +++ b/Testing/Code/IO/otbJPEG2000ImageIOTestCanWrite.cxx @@ -0,0 +1,37 @@ +/*========================================================================= + + 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. + +=========================================================================*/ + +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbJPEG2000ImageIO.h" +#include "itkExceptionObject.h" +#include <iostream> + +int otbJPEG2000ImageIOTestCanWrite(int argc, char* argv[]) +{ + otb::JPEG2000ImageIO::Pointer lJPEG2000ImageIO = otb::JPEG2000ImageIO::New(); + bool lCanWrite = lJPEG2000ImageIO->CanWriteFile(argv[1]); + if ( lCanWrite == false) + { + std::cerr << "Erreur otb::JPEG2000ImageIO : impossible to create the image file JPEG2000 "<<argv[1]<<"."<<std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +}