[Liblas-commits] r1077 - in trunk: include/liblas include/liblas/detail src/detail

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Feb 25 19:53:58 EST 2009


Author: mloskot
Date: Wed Feb 25 19:53:57 2009
New Revision: 1077
URL: http://liblas.org/changeset/1077

Log:
Little refactoring and cleanup, no fixes applied.

Modified:
   trunk/include/liblas/detail/reader12.hpp
   trunk/include/liblas/detail/writer12.hpp
   trunk/include/liblas/lascolor.hpp
   trunk/src/detail/reader12.cpp
   trunk/src/detail/writer12.cpp

Modified: trunk/include/liblas/detail/reader12.hpp
==============================================================================
--- trunk/include/liblas/detail/reader12.hpp	(original)
+++ trunk/include/liblas/detail/reader12.hpp	Wed Feb 25 19:53:57 2009
@@ -58,8 +58,8 @@
     ReaderImpl(std::istream& ifs);
     std::size_t GetVersion() const;
     bool ReadHeader(LASHeader& header);
-    bool ReadNextPoint(LASPoint& point, const LASHeader& header);
-    bool ReadPointAt(std::size_t n, LASPoint& record, const LASHeader& header);
+    bool ReadNextPoint(LASPoint& point, LASHeader const& header);
+    bool ReadPointAt(std::size_t n, LASPoint& record, LASHeader const& header);
 
 };
 

Modified: trunk/include/liblas/detail/writer12.hpp
==============================================================================
--- trunk/include/liblas/detail/writer12.hpp	(original)
+++ trunk/include/liblas/detail/writer12.hpp	Wed Feb 25 19:53:57 2009
@@ -60,7 +60,7 @@
     std::size_t GetVersion() const;
     void WriteHeader(LASHeader& header);
     void UpdateHeader(LASHeader const& header);
-    void WritePointRecord(LASPoint const& record, const LASHeader& header);
+    void WritePointRecord(LASPoint const& record, LASHeader const& header);
     
 private:
 

Modified: trunk/include/liblas/lascolor.hpp
==============================================================================
--- trunk/include/liblas/lascolor.hpp	(original)
+++ trunk/include/liblas/lascolor.hpp	Wed Feb 25 19:53:57 2009
@@ -57,7 +57,7 @@
 public:
 
     /// Default constructor.
-    /// Initializes with RGB of black color.
+    /// Initializes with black color using RGB {0, 0, 0}.
     LASColor();
 
     /// Copy constructor.

Modified: trunk/src/detail/reader12.cpp
==============================================================================
--- trunk/src/detail/reader12.cpp	(original)
+++ trunk/src/detail/reader12.cpp	Wed Feb 25 19:53:57 2009
@@ -151,19 +151,24 @@
 
     // 17. Point Data Format ID
     read_n(n1, m_ifs, sizeof(n1));
-    if (n1 == LASHeader::ePointFormat0) {
+    if (n1 == LASHeader::ePointFormat0)
+    {
         header.SetDataFormatId(LASHeader::ePointFormat0);
     } 
-    else if (n1 == LASHeader::ePointFormat1) {
+    else if (n1 == LASHeader::ePointFormat1)
+    {
         header.SetDataFormatId(LASHeader::ePointFormat1);
     }
-    else if (n1 == LASHeader::ePointFormat2) {
+    else if (n1 == LASHeader::ePointFormat2)
+    {
         header.SetDataFormatId(LASHeader::ePointFormat2);
     }
-    else if (n1 == LASHeader::ePointFormat3) {
+    else if (n1 == LASHeader::ePointFormat3)
+    {
         header.SetDataFormatId(LASHeader::ePointFormat3);
     }
-    else {
+    else
+    {
         throw std::domain_error("invalid point data format");
     }
 
@@ -219,7 +224,7 @@
     return true;
 }
 
-bool ReaderImpl::ReadNextPoint(LASPoint& point, const LASHeader& header)
+bool ReaderImpl::ReadNextPoint(LASPoint& point, LASHeader const& header)
 {
     // Read point data record format 0
 
@@ -256,10 +261,13 @@
         Reader::FillPoint(record, point);
         point.SetCoordinates(header, point.GetX(), point.GetY(), point.GetZ());
 
-        if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+        if (header.GetDataFormatId() == LASHeader::ePointFormat1)
+        {
             detail::read_n(t, m_ifs, sizeof(double));
             point.SetTime(t);
-        } else if (header.GetDataFormatId() == LASHeader::ePointFormat2) {
+        }
+        else if (header.GetDataFormatId() == LASHeader::ePointFormat2)
+        {
             detail::read_n(red, m_ifs, sizeof(uint16_t));
             detail::read_n(green, m_ifs, sizeof(uint16_t));
             detail::read_n(blue, m_ifs, sizeof(uint16_t));
@@ -267,7 +275,9 @@
             color.SetBlue(blue);
             color.SetGreen(green);
             point.SetColor(color);
-        } else if (header.GetDataFormatId() == LASHeader::ePointFormat3) {
+        }
+        else if (header.GetDataFormatId() == LASHeader::ePointFormat3)
+        {
             detail::read_n(t, m_ifs, sizeof(double));
             point.SetTime(t);
             detail::read_n(red, m_ifs, sizeof(uint16_t));
@@ -278,15 +288,14 @@
             color.SetGreen(green);
             point.SetColor(color);
         }
-             
-                
+
         return true;
     }
-
+    
     return false;
 }
 
-bool ReaderImpl::ReadPointAt(std::size_t n, LASPoint& point, const LASHeader& header)
+bool ReaderImpl::ReadPointAt(std::size_t n, LASPoint& point, LASHeader const& header)
 {
     // Read point data record format 0
 
@@ -302,7 +311,9 @@
     assert(LASHeader::ePointSize0 == sizeof(record));
 
     if (m_size <= n)
+    {
         return false;
+    }
 
     std::streamsize const pos = (static_cast<std::streamsize>(n) * m_recordlength) + m_offset;
 
@@ -313,10 +324,13 @@
     Reader::FillPoint(record, point);
     point.SetCoordinates(header, point.GetX(), point.GetY(), point.GetZ());
 
-    if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+    if (header.GetDataFormatId() == LASHeader::ePointFormat1)
+    {
         detail::read_n(t, m_ifs, sizeof(double));
         point.SetTime(t);
-    } else if (header.GetDataFormatId() == LASHeader::ePointFormat2) {
+    }
+    else if (header.GetDataFormatId() == LASHeader::ePointFormat2)
+    {
         detail::read_n(red, m_ifs, sizeof(uint16_t));
         detail::read_n(blue, m_ifs, sizeof(uint16_t));
         detail::read_n(green, m_ifs, sizeof(uint16_t));
@@ -324,7 +338,9 @@
         color.SetBlue(blue);
         color.SetGreen(green);
         point.SetColor(color);
-    } else if (header.GetDataFormatId() == LASHeader::ePointFormat3) {
+    }
+    else if (header.GetDataFormatId() == LASHeader::ePointFormat3)
+    {
         detail::read_n(t, m_ifs, sizeof(double));
         point.SetTime(t);
         detail::read_n(red, m_ifs, sizeof(uint16_t));
@@ -340,6 +356,5 @@
     return true;
 }
 
-
 }}} // namespace liblas::detail::v11
 

Modified: trunk/src/detail/writer12.cpp
==============================================================================
--- trunk/src/detail/writer12.cpp	(original)
+++ trunk/src/detail/writer12.cpp	Wed Feb 25 19:53:57 2009
@@ -88,8 +88,10 @@
     // std::ios::in *and* std::ios::out, otherwise it should return false 
     // and we won't adjust the point count.
     
-    if (beginning != end) {
-        m_pointCount = ((uint32_t) end - header.GetDataOffset())/header.GetDataRecordLength();
+    if (beginning != end)
+    {
+        m_pointCount = static_cast<uint32_t>(end) - header.GetDataOffset();
+        m_pointCount /= header.GetDataRecordLength();
 
         // Position to the beginning of the file to start writing the header
         m_ofs.seekp(0, std::ios::beg);
@@ -213,7 +215,9 @@
     // If we already have points, we're going to put it at the end of the file.  
     // If we don't have any points,  we're going to leave it where it is.
     if (m_pointCount != 0)
+    {
         m_ofs.seekp(0, std::ios::end);
+    }
 }
 
 void WriterImpl::UpdateHeader(LASHeader const& header)
@@ -228,7 +232,7 @@
     }
 }
 
-void WriterImpl::WritePointRecord(LASPoint const& point, const LASHeader& header)
+void WriterImpl::WritePointRecord(LASPoint const& point, LASHeader const& header)
 {
     // TODO: Static assert would be better
     
@@ -242,10 +246,13 @@
     Writer::FillPointRecord(m_record, point, header);
     detail::write_n(m_ofs, m_record, sizeof(m_record));
 
-    if (header.GetDataFormatId() == LASHeader::ePointFormat1) {
+    if (header.GetDataFormatId() == LASHeader::ePointFormat1)
+    {
         t = point.GetTime();
         detail::write_n(m_ofs, t, sizeof(double));
-    } else if (header.GetDataFormatId() == LASHeader::ePointFormat2) {
+    }
+    else if (header.GetDataFormatId() == LASHeader::ePointFormat2)
+    {
         color = point.GetColor();
         red = color.GetRed();
         green = color.GetGreen();
@@ -253,7 +260,9 @@
         detail::write_n(m_ofs, red, sizeof(uint16_t));
         detail::write_n(m_ofs, green, sizeof(uint16_t));
         detail::write_n(m_ofs, blue, sizeof(uint16_t));
-    } else if (header.GetDataFormatId() == LASHeader::ePointFormat3) {
+    }
+    else if (header.GetDataFormatId() == LASHeader::ePointFormat3)
+    {
         t = point.GetTime();
         detail::write_n(m_ofs, t, sizeof(double));
         color = point.GetColor();


More information about the Liblas-commits mailing list