Commit 1d954a18 authored by Emmanuel Christophe's avatar Emmanuel Christophe

ENH: Continuing integration of liblas

parent 2fd7020e
......@@ -27,7 +27,7 @@ ENDIF(OTB_COMPILE_JPEG2000)
ADD_LIBRARY(OTBIO ${OTBIO_SRCS})
TARGET_LINK_LIBRARIES (OTBIO OTBCommon ITKIO ITKCommon gdal otbossim dxf otbkml)
TARGET_LINK_LIBRARIES (OTBIO OTBCommon ITKIO ITKCommon gdal otbossim dxf otbkml otbliblas)
IF( OTB_COMPILE_JPEG2000 )
TARGET_LINK_LIBRARIES (OTBIO otbopenjpeg)
ENDIF( OTB_COMPILE_JPEG2000 )
......
......@@ -28,7 +28,7 @@ namespace otb
{
/** \class ImageFileReader
* \brief Ressource en lecture pour lire une image depuis un fichier.
* \brief Ressource to read an image from a file.
*
* \sa ImageSeriesReader
* \sa ImageIOBase
......
/*=========================================================================
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 __otbPointSetFileReader_h
#define __otbPointSetFileReader_h
#include "otbPointSetSource.h"
#include "itkImageFileReader.h"
namespace otb
{
/** \class PointSetFileReader
* \brief Read a point set from a lidar file.
*
* \sa PointSetSource
*
* \ingroup IOFilters
*
*/
template<class TOutputPointSet>
class ITK_EXPORT PointSetFileReader: public otb::PointSetSource< TOutputPointSet >
{
public:
/** Standard class typedefs. */
typedef PointSetFileReader Self;
typedef otb::PointSetSource<TOutputPointSet> Superclass;
typedef itk::SmartPointer<Self> Pointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(PointSetFileReader, PointSetSource);
/** Typedef */
typedef TOutputPointSet PointSetType;
typedef typename PointSetType::PointType PointType;
typedef typename PointSetType::PixelType PixelType;
/** Specify the file to read. This is forwarded to the IO instance. */
itkSetStringMacro(FileName);
itkGetStringMacro(FileName);
virtual void GenerateOutputInformation(void);
/** Does the real work. */
virtual void GenerateData();
protected:
PointSetFileReader();
~PointSetFileReader();
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void TestFileExistanceAndReadability();
std::string m_FileName; // The file to be read
private:
PointSetFileReader(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
std::string m_ExceptionMessage;
};
} //namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbPointSetFileReader.txx"
#endif
#endif
/*=========================================================================
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 __otbPointSetFileReader_txx
#define __otbPointSetFileReader_txx
#include "otbPointSetFileReader.h"
#include "otbMacro.h"
#include <liblas/laspoint.hpp>
#include <liblas/lasreader.hpp>
#include <fstream> // std::ifstream
#include <iostream> // std::cout
namespace otb
{
template <class TOutputPointSet>
PointSetFileReader<TOutputPointSet>
::PointSetFileReader() : otb::PointSetSource<TOutputPointSet>()
{
}
template <class TOutputPointSet>
PointSetFileReader<TOutputPointSet>
::~PointSetFileReader()
{
}
template <class TOutputPointSet>
void
PointSetFileReader<TOutputPointSet>
::GenerateOutputInformation(void)
{
typename TOutputPointSet::Pointer output = this->GetOutput();
otbDebugMacro(<<"Reading file for GenerateOutputInformation()" << m_FileName);
// Check to see if we can read the file given the name or prefix
//
if ( m_FileName == "" )
{
throw itk::ImageFileReaderException(__FILE__, __LINE__, "FileName must be specified", ITK_LOCATION);
}
// Test if the file exists and if it can be open.
// An exception will be thrown otherwise.
//
try
{
m_ExceptionMessage = "";
this->TestFileExistanceAndReadability();
}
catch(itk::ExceptionObject &err)
{
m_ExceptionMessage = err.GetDescription();
}
std::ifstream ifs;
ifs.open(m_FileName.c_str(), std::ios::in | std::ios::binary);
liblas::LASReader reader(ifs);
liblas::LASHeader const& header = reader.GetHeader();
std::cout << "Signature: " << header.GetFileSignature() << std::endl;
std::cout << "Points count: " << header.GetPointRecordsCount() << std::endl;
}
template <class TOutputPointSet>
void
PointSetFileReader<TOutputPointSet>
::TestFileExistanceAndReadability()
{
// Test if the file exists.
if( ! itksys::SystemTools::FileExists( m_FileName.c_str() ) )
{
itk::ImageFileReaderException e(__FILE__, __LINE__);
OStringStream msg;
msg <<"The file doesn't exist. "
<< std::endl << "Filename = " << m_FileName
<< std::endl;
e.SetDescription(msg.str().c_str());
throw e;
return;
}
// Test if the file can be open for reading access.
std::ifstream readTester;
readTester.open( m_FileName.c_str() );
if( readTester.fail() )
{
readTester.close();
OStringStream msg;
msg <<"The file couldn't be opened for reading. "
<< std::endl << "Filename: " << m_FileName
<< std::endl;
itk::ImageFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION);
throw e;
return;
}
readTester.close();
}
template <class TOutputPointSet>
void PointSetFileReader<TOutputPointSet>
::GenerateData()
{
typename TOutputImage::Pointer output = this->GetOutput();
}
template <class TOutputPointSet>
void PointSetFileReader<TOutputPointSet>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
if (this->->GetOutput())
{
os << indent << "Number of points: " << this->->GetOutput()->GetNumberOfPoints() << std::endl;
}
else
{
os << indent << "Output: (null)" << "\n";
}
os << indent << "m_FileName: " << this->m_FileName << "\n";
}
} //namespace otb
#endif
......@@ -1582,9 +1582,17 @@ ADD_TEST(ioTvImageFileReaderTIF2RADCI4 ${IO_TESTS16}
# ${TEMP}/ioImageFileReaderPNG2RADPHA.rad )
ADD_TEST(ioTuPointSetFileReaderNew ${IO_TESTS15}
otbPointSetFileReaderNew )
ADD_TEST(ioTvPointSetFileReader ${IO_TESTS15}
--compare-ascii ${TOL} ${BASELINE_FILES}/ioPointSetFileReader.txt
${TEMP}/ioPointSetFileReader.txt
otbPointSetFileReader
${INPUTDATA}/lidar.las
${TEMP}/ioPointSetFileReader.txt)
#----------------------------------------------------------------------------------
SET(BasicIO_SRCS1
otbImageFileReaderERS.cxx
......@@ -1711,6 +1719,8 @@ otbImageFileReaderRADFloat.cxx
otbImageFileReaderRADComplexInt.cxx
otbImageFileReaderRADComplexFloat.cxx
otbImageFileReaderRADComplexDouble.cxx
otbPointSetFileReaderNew.cxx
otbPointSetFileReader.cxx
)
INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
......
/*=========================================================================
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 "otbPointSetFileReader.h"
#include "itkPointSet.h"
#include <fstream>
int otbPointSetFileReader(int argc, char * argv[])
{
typedef itk::PointSet <double, 2> PointSetType;
typedef otb::PointSetFileReader<PointSetType> PointSetFileReaderType;
PointSetFileReaderType::Pointer reader = PointSetFileReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
PointSetType::Pointer data = reader->GetOutput();
std::ofstream fout (argv[2]);
fout << data <<std::endl;
fout.close();
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 "otbPointSetFileReader.h"
#include "itkPointSet.h"
int otbPointSetFileReaderNew(int argc, char * argv[])
{
typedef itk::PointSet <double, 2> PointSetType;
typedef otb::PointSetFileReader<PointSetType> PointSetFileReaderType;
PointSetFileReaderType::Pointer object = PointSetFileReaderType::New();
return EXIT_SUCCESS;
}
......@@ -4,7 +4,7 @@ SET(liblas_VERSION_MAJOR "1")
SET(liblas_VERSION_MINOR "0")
SET(liblas_VERSION_PATCH "0")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/liblas)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
SET(liblas_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(liblas_SOURCES
......@@ -27,3 +27,13 @@ SET(liblas_SOURCES
ADD_LIBRARY(otbliblas ${liblas_SOURCES} )
INSTALL(TARGETS otbliblas
RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT Development)
FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/include/liblas/*.hpp")
INSTALL(FILES ${__files1}
DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbliblas/include/liblas
COMPONENT Development)
PROJECT(liblas)
SET(liblas_VERSION_MAJOR "1")
SET(liblas_VERSION_MINOR "0")
SET(liblas_VERSION_PATCH "0")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/liblas)
SET(liblas_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(liblas_SOURCES
${liblas_SOURCES_DIR}/las_c_api.cpp
${liblas_SOURCES_DIR}/lasfile.cpp
${liblas_SOURCES_DIR}/laspoint.cpp
${liblas_SOURCES_DIR}/lasrecordheader.cpp
${liblas_SOURCES_DIR}/laserror.cpp
${liblas_SOURCES_DIR}/lasheader.cpp
${liblas_SOURCES_DIR}/lasreader.cpp
${liblas_SOURCES_DIR}/laswriter.cpp
${liblas_SOURCES_DIR}/detail/file.cpp
${liblas_SOURCES_DIR}/detail/reader10.cpp
${liblas_SOURCES_DIR}/detail/reader11.cpp
${liblas_SOURCES_DIR}/detail/reader.cpp
${liblas_SOURCES_DIR}/detail/writer10.cpp
${liblas_SOURCES_DIR}/detail/writer11.cpp
${liblas_SOURCES_DIR}/detail/writer.cpp
)
ADD_LIBRARY(otbliblas ${liblas_SOURCES} )
\ No newline at end of file
......@@ -44,6 +44,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
${OTB_SOURCE_DIR}/Utilities/otbkml/third_party/boost_1_34_1
# ${OTB_SOURCE_DIR}/Utilities/otbkml/third_party/zlib-1.2.3
# ${OTB_SOURCE_DIR}/Utilities/otbkml/third_party/zlib-1.2.3/contrib
${OTB_SOURCE_DIR}/Utilities/otbliblas/include
)
IF(OTB_COMPILE_JPEG2000)
SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
......@@ -206,6 +207,7 @@ SET(OTB_INCLUDE_DIRS_INSTALL_TREE ${OTB_INCLUDE_DIRS_INSTALL_TREE}
${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbkml/third_party/boost_1_34_1
# ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbkml/third_party/zlib-1.2.3
# ${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbkml/third_party/zlib-1.2.3/contrib
${OTB_INSTALL_INCLUDE_DIR}/Utilities/otbliblas/include
)
IF(OTB_COMPILE_JPEG2000)
......
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