From 6ec9760f4ab41ca0dc4feb4c524ec2862075c384 Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Tue, 11 Nov 2008 13:32:55 +0800
Subject: [PATCH] ENH: liblas, non regression test OK

---
 Code/IO/otbPointSetFileReader.txx         | 31 +++++++++++++++++++++++
 Testing/Code/IO/CMakeLists.txt            |  2 +-
 Testing/Code/IO/otbPointSetFileReader.cxx | 15 ++++++++++-
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/Code/IO/otbPointSetFileReader.txx b/Code/IO/otbPointSetFileReader.txx
index 709e6d7298..ee8508c242 100644
--- a/Code/IO/otbPointSetFileReader.txx
+++ b/Code/IO/otbPointSetFileReader.txx
@@ -86,6 +86,7 @@ namespace otb
 
     m_NumberOfPoints = header.GetPointRecordsCount();
     
+    ifs.close();
   
   }
   
@@ -133,8 +134,38 @@ namespace otb
   
 
     typename TOutputPointSet::Pointer output = this->GetOutput();
+    
+    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;
+
+    m_NumberOfPoints = header.GetPointRecordsCount();
   
+    while (reader.ReadNextPoint())
+    {
+      liblas::LASPoint const& p = reader.GetPoint();
+
+      PointType point;
+      point[0] = p.GetX();
+      point[1] = p.GetY();
+
+
+      unsigned long i = output->GetNumberOfPoints();
+      output->SetPoint( i, point );        
+
+      PixelType V;
+      V = static_cast<PixelType>( p.GetZ() );
+      output->SetPointData( i, V );
+    
+    }
+    
+    
+    ifs.close();
   }
 
 
diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt
index f838a212fd..456003eed3 100755
--- a/Testing/Code/IO/CMakeLists.txt
+++ b/Testing/Code/IO/CMakeLists.txt
@@ -1589,7 +1589,7 @@ ADD_TEST(ioTvPointSetFileReader ${IO_TESTS16}
         --compare-ascii ${TOL}  ${BASELINE_FILES}/ioPointSetFileReader.txt
                         ${TEMP}/ioPointSetFileReader.txt
         otbPointSetFileReader
-  ${INPUTDATA}/lidar.las
+  ${INPUTDATA}/srs.las
   ${TEMP}/ioPointSetFileReader.txt)
         
   
diff --git a/Testing/Code/IO/otbPointSetFileReader.cxx b/Testing/Code/IO/otbPointSetFileReader.cxx
index 7dd78d5514..56eb8691d6 100644
--- a/Testing/Code/IO/otbPointSetFileReader.cxx
+++ b/Testing/Code/IO/otbPointSetFileReader.cxx
@@ -31,8 +31,21 @@ int otbPointSetFileReader(int argc, char * argv[])
 
   PointSetType::Pointer data = reader->GetOutput();
 
+  
   std::ofstream fout (argv[2]);
-  fout << data <<std::endl;
+  unsigned long nPoints = data->GetNumberOfPoints();
+  fout << std::setprecision(15) << "Number of points: " << nPoints << std::endl;
+  
+  for(unsigned long i=0; i < nPoints; ++i)
+  {
+    PointSetType::PointType point;
+    data->GetPoint(i,&point);
+    fout << point << " : ";
+    PointSetType::PixelType value;
+    data->GetPointData(i,&value);
+    fout << value << std::endl;
+  }
+  fout << std::endl;
   fout.close();
   return EXIT_SUCCESS;
 }
-- 
GitLab