[Liblas-commits] hg: finish up removing header copying in reader
implementations
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Jul 26 15:57:54 EDT 2010
changeset 9b2ed4aa5cbd in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9b2ed4aa5cbd
summary: finish up removing header copying in reader implementations
diffstat:
include/liblas/detail/reader/header.hpp | 4 +-
include/liblas/detail/reader/reader.hpp | 20 +++---
include/liblas/lasreader.hpp | 6 +-
include/liblas/liblas.hpp | 10 ++-
src/detail/reader/header.cpp | 90 ++++++++++++++++----------------
src/detail/reader/reader.cpp | 38 ++++++------
src/lasreader.cpp | 20 +++---
7 files changed, 93 insertions(+), 95 deletions(-)
diffs (truncated from 638 to 300 lines):
diff -r d28899d2cbb5 -r 9b2ed4aa5cbd include/liblas/detail/reader/header.hpp
--- a/include/liblas/detail/reader/header.hpp Mon Jul 26 14:13:20 2010 -0500
+++ b/include/liblas/detail/reader/header.hpp Mon Jul 26 14:57:47 2010 -0500
@@ -60,7 +60,7 @@
Header(std::istream& ifs);
virtual ~Header();
- const liblas::Header& GetHeader() const { return m_header; }
+ HeaderPtr GetHeader() const { return m_header; }
void read();
void readvlrs();
@@ -68,7 +68,7 @@
std::istream& m_ifs;
- liblas::Header m_header;
+ HeaderPtr m_header;
private:
diff -r d28899d2cbb5 -r 9b2ed4aa5cbd include/liblas/detail/reader/reader.hpp
--- a/include/liblas/detail/reader/reader.hpp Mon Jul 26 14:13:20 2010 -0500
+++ b/include/liblas/detail/reader/reader.hpp Mon Jul 26 14:57:47 2010 -0500
@@ -64,13 +64,13 @@
~ReaderImpl();
HeaderPtr ReadHeader();
- liblas::Point const& ReadNextPoint(const liblas::Header& header);
- liblas::Point const& ReadPointAt(std::size_t n, const liblas::Header& header);
- void Seek(std::size_t n, const liblas::Header& header);
+ liblas::Point const& ReadNextPoint(HeaderPtr header);
+ liblas::Point const& ReadPointAt(std::size_t n, HeaderPtr header);
+ void Seek(std::size_t n, HeaderPtr header);
std::istream& GetStream() const;
- void Reset(liblas::Header const& header);
+ void Reset(HeaderPtr header);
protected:
void CreateTransform();
@@ -103,12 +103,12 @@
// ~CachedReaderImpl();
HeaderPtr ReadHeader();
- liblas::Point const& ReadNextPoint(const liblas::Header& header);
- liblas::Point const& ReadPointAt(std::size_t n, const liblas::Header& header);
+ liblas::Point const& ReadNextPoint(HeaderPtr header);
+ liblas::Point const& ReadPointAt(std::size_t n, HeaderPtr header);
// void SetOutputSRS(const SpatialReference& srs, const liblas::Header& header);
- void Seek(std::size_t n, const liblas::Header& header);
- void Reset(liblas::Header const& header);
+ void Seek(std::size_t n, HeaderPtr header);
+ void Reset(HeaderPtr header);
protected:
@@ -117,9 +117,9 @@
// Blocked copying operations, declared but not defined.
CachedReaderImpl(CachedReaderImpl const& other);
CachedReaderImpl& operator=(CachedReaderImpl const& rhs);
- liblas::Point const& ReadCachedPoint(liblas::uint32_t position, const liblas::Header& header);
+ liblas::Point const& ReadCachedPoint(liblas::uint32_t position, HeaderPtr header);
- void CacheData(liblas::uint32_t position, const liblas::Header& header);
+ void CacheData(liblas::uint32_t position, HeaderPtr header);
std::vector<uint8_t>::size_type m_cache_size;
std::vector<uint8_t> m_mask;
diff -r d28899d2cbb5 -r 9b2ed4aa5cbd include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp Mon Jul 26 14:13:20 2010 -0500
+++ b/include/liblas/lasreader.hpp Mon Jul 26 14:57:47 2010 -0500
@@ -59,12 +59,8 @@
#include <vector>
#include <cstddef>
-#include <boost/shared_ptr.hpp>
-
namespace liblas {
-typedef boost::shared_ptr< liblas::TransformI > TransformPtr;
-
/// Defines public interface to LAS reader implementation.
class Reader
@@ -174,7 +170,7 @@
HeaderPtr m_header;
Point* m_point;
- Point* m_empty_point;
+ PointPtr m_empty_point;
// Set if the user provides a header to override the header as
diff -r d28899d2cbb5 -r 9b2ed4aa5cbd include/liblas/liblas.hpp
--- a/include/liblas/liblas.hpp Mon Jul 26 14:13:20 2010 -0500
+++ b/include/liblas/liblas.hpp Mon Jul 26 14:57:47 2010 -0500
@@ -54,6 +54,8 @@
#include <boost/shared_ptr.hpp>
typedef boost::shared_ptr< liblas::Header > HeaderPtr;
+typedef boost::shared_ptr< liblas::Point > PointPtr;
+typedef boost::shared_ptr< liblas::TransformI > TransformPtr;
/// Namespace grouping all elements of libLAS public interface.
/// \note
@@ -160,11 +162,11 @@
public:
virtual HeaderPtr ReadHeader() = 0;
- virtual Point const& ReadNextPoint(const Header& header) = 0;
- virtual Point const& ReadPointAt(std::size_t n, const Header& header) = 0;
- virtual void Seek(std::size_t n, const Header& header) = 0;
+ virtual Point const& ReadNextPoint(HeaderPtr header) = 0;
+ virtual Point const& ReadPointAt(std::size_t n, HeaderPtr header) = 0;
+ virtual void Seek(std::size_t n, HeaderPtr header) = 0;
- virtual void Reset(const Header& header) = 0;
+ virtual void Reset(HeaderPtr header) = 0;
virtual std::istream& GetStream() const = 0;
diff -r d28899d2cbb5 -r 9b2ed4aa5cbd src/detail/reader/header.cpp
--- a/src/detail/reader/header.cpp Mon Jul 26 14:13:20 2010 -0500
+++ b/src/detail/reader/header.cpp Mon Jul 26 14:57:47 2010 -0500
@@ -48,7 +48,7 @@
namespace liblas { namespace detail { namespace reader {
Header::Header(std::istream& ifs) :
- m_ifs(ifs)
+ m_ifs(ifs), m_header(HeaderPtr(new liblas::Header()))
{
}
@@ -79,11 +79,11 @@
// 1. File Signature
read_n(fsig, m_ifs, 4);
- m_header.SetFileSignature(fsig);
+ m_header->SetFileSignature(fsig);
// 2. File Source ID
read_n(n2, m_ifs, sizeof(n2));
- m_header.SetFileSourceId(n2);
+ m_header->SetFileSourceId(n2);
// 3. Reserved
// This data must always contain Zeros.
@@ -99,46 +99,46 @@
read_n(d3, m_ifs, sizeof(d3));
read_n(d4, m_ifs, sizeof(d4));
liblas::guid g(d1, d2, d3, d4);
- m_header.SetProjectId(g);
+ m_header->SetProjectId(g);
// 8. Version major
read_n(n1, m_ifs, sizeof(n1));
- m_header.SetVersionMajor(n1);
+ m_header->SetVersionMajor(n1);
// 9. Version minor
read_n(n1, m_ifs, sizeof(n1));
- m_header.SetVersionMinor(n1);
+ m_header->SetVersionMinor(n1);
// 10. System ID
read_n(buf, m_ifs, 32);
- m_header.SetSystemId(buf);
+ m_header->SetSystemId(buf);
// 11. Generating Software ID
read_n(buf, m_ifs, 32);
- m_header.SetSoftwareId(buf);
+ m_header->SetSoftwareId(buf);
// 12. File Creation Day of Year
read_n(n2, m_ifs, sizeof(n2));
- m_header.SetCreationDOY(n2);
+ m_header->SetCreationDOY(n2);
// 13. File Creation Year
read_n(n2, m_ifs, sizeof(n2));
- m_header.SetCreationYear(n2);
+ m_header->SetCreationYear(n2);
// 14. Header Size
// NOTE: Size of the stanard header block must always be 227 bytes
read_n(n2, m_ifs, sizeof(n2));
- m_header.SetHeaderSize(n2);
+ m_header->SetHeaderSize(n2);
// 15. Offset to data
read_n(n4, m_ifs, sizeof(n4));
- if (n4 < m_header.GetHeaderSize())
+ if (n4 < m_header->GetHeaderSize())
{
std::ostringstream msg;
msg << "The offset to the start of point data, "
<< n4 << ", is smaller than the header size, "
- << m_header.GetHeaderSize() << ". This is "
+ << m_header->GetHeaderSize() << ". This is "
"an invalid condition and incorrectly written "
"file. We cannot ignore this error because we "
"do not know where to begin seeking to read the "
@@ -147,37 +147,37 @@
"will be dealt with swiftly and humanely.";
throw std::runtime_error(msg.str());
}
- m_header.SetDataOffset(n4);
+ m_header->SetDataOffset(n4);
// 16. Number of variable length records
read_n(n4, m_ifs, sizeof(n4));
- m_header.SetRecordsCount(n4);
+ m_header->SetRecordsCount(n4);
// 17. Point Data Format ID
read_n(n1, m_ifs, sizeof(n1));
if (n1 == liblas::ePointFormat0)
{
- m_header.SetDataFormatId(liblas::ePointFormat0);
+ m_header->SetDataFormatId(liblas::ePointFormat0);
}
else if (n1 == liblas::ePointFormat1)
{
- m_header.SetDataFormatId(liblas::ePointFormat1);
+ m_header->SetDataFormatId(liblas::ePointFormat1);
}
else if (n1 == liblas::ePointFormat2)
{
- m_header.SetDataFormatId(liblas::ePointFormat2);
+ m_header->SetDataFormatId(liblas::ePointFormat2);
}
else if (n1 == liblas::ePointFormat3)
{
- m_header.SetDataFormatId(liblas::ePointFormat3);
+ m_header->SetDataFormatId(liblas::ePointFormat3);
}
else if (n1 == liblas::ePointFormat4)
{
- m_header.SetDataFormatId(liblas::ePointFormat4);
+ m_header->SetDataFormatId(liblas::ePointFormat4);
}
else if (n1 == liblas::ePointFormat5)
{
- m_header.SetDataFormatId(liblas::ePointFormat5);
+ m_header->SetDataFormatId(liblas::ePointFormat5);
}
else
{
@@ -186,11 +186,11 @@
// 18. Point Data Record Length
read_n(n2, m_ifs, sizeof(n2));
- m_header.SetDataRecordLength(n2);
+ m_header->SetDataRecordLength(n2);
// 19. Number of point records
read_n(n4, m_ifs, sizeof(n4));
- m_header.SetPointRecordsCount(n4);
+ m_header->SetPointRecordsCount(n4);
// 20. Number of points by return
std::vector<uint32_t>::size_type const srbyr = 5;
@@ -198,20 +198,20 @@
read_n(rbyr, m_ifs, sizeof(rbyr));
for (std::size_t i = 0; i < srbyr; ++i)
{
- m_header.SetPointRecordsByReturnCount(i, rbyr[i]);
+ m_header->SetPointRecordsByReturnCount(i, rbyr[i]);
}
// 21-23. Scale factors
read_n(x1, m_ifs, sizeof(x1));
read_n(y1, m_ifs, sizeof(y1));
read_n(z1, m_ifs, sizeof(z1));
- m_header.SetScale(x1, y1, z1);
+ m_header->SetScale(x1, y1, z1);
// 24-26. Offsets
read_n(x1, m_ifs, sizeof(x1));
read_n(y1, m_ifs, sizeof(y1));
read_n(z1, m_ifs, sizeof(z1));
- m_header.SetOffset(x1, y1, z1);
+ m_header->SetOffset(x1, y1, z1);
// 27-28. Max/Min X
read_n(x1, m_ifs, sizeof(x1));
@@ -225,8 +225,8 @@
read_n(z1, m_ifs, sizeof(z1));
read_n(z2, m_ifs, sizeof(z2));
- m_header.SetMax(x1, y1, z1);
- m_header.SetMin(x2, y2, z2);
+ m_header->SetMax(x1, y1, z1);
+ m_header->SetMin(x2, y2, z2);
More information about the Liblas-commits
mailing list