[Liblas-commits] hg-main-tree: remove IsValid et. al. from PointData

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Mar 16 15:37:33 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/01a57657d746
changeset: 294:01a57657d746
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Mar 16 14:14:56 2011 -0500
description:
remove IsValid et. al. from PointData
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/724c1ec91b06
changeset: 295:724c1ec91b06
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Mar 16 14:15:10 2011 -0500
description:
merge
Subject: hg-main-tree: add capacity arg to pointData

details:   http://hg.libpc.orghg-main-tree/rev/8cb96fc090bf
changeset: 296:8cb96fc090bf
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Mar 16 14:33:34 2011 -0500
description:
add capacity arg to pointData
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/51b7dd6c8a17
changeset: 297:51b7dd6c8a17
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Mar 16 14:33:44 2011 -0500
description:
merge
Subject: hg-main-tree: fix namespaced liblas reader

details:   http://hg.libpc.orghg-main-tree/rev/2bf8231103da
changeset: 298:2bf8231103da
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Mar 16 14:37:25 2011 -0500
description:
fix namespaced liblas reader

diffstat:

 apps/pc2pc.cpp                             |  10 +-
 apps/pcinfo.cpp                            |   4 +-
 include/libpc/Filter.hpp                   |   5 -
 include/libpc/Iterator.hpp                 |  52 ++++++++++++++++++
 include/libpc/PointData.hpp                |  17 +----
 include/libpc/Reader.hpp                   |   4 -
 include/libpc/drivers/las/Header.hpp       |   6 +-
 include/libpc/drivers/las/Reader.hpp       |   6 +-
 include/libpc/drivers/las/Writer.hpp       |   6 +-
 include/libpc/drivers/liblas/Header.hpp    |   6 +-
 include/libpc/drivers/liblas/Reader.hpp    |   7 +-
 include/libpc/drivers/liblas/Writer.hpp    |   9 +-
 include/libpc/drivers/oci/Reader.hpp       |   2 +
 include/libpc/filters/CropFilter.hpp       |   2 +
 include/libpc/filters/DecimationFilter.hpp |   2 +
 include/libpc/filters/MosaicFilter.hpp     |   2 +-
 src/CMakeLists.txt                         |   3 +-
 src/Filter.cpp                             |   6 --
 src/Iterator.cpp                           |  85 ++++++++++++++++++++++++++++++
 src/PointData.cpp                          |  65 +++-------------------
 src/Reader.cpp                             |  19 ------
 src/drivers/faux/Reader.cpp                |   2 -
 src/drivers/faux/Writer.cpp                |  31 ++++------
 src/drivers/las/Header.cpp                 |   9 +--
 src/drivers/las/LasHeaderReader.cpp        |   5 +-
 src/drivers/las/LasHeaderReader.hpp        |   6 +-
 src/drivers/las/LasHeaderWriter.cpp        |   9 +--
 src/drivers/las/LasHeaderWriter.hpp        |   6 +-
 src/drivers/las/Reader.cpp                 |   8 +-
 src/drivers/las/Writer.cpp                 |   7 +-
 src/drivers/liblas/Header.cpp              |  11 +--
 src/drivers/liblas/Reader.cpp              |  22 +++---
 src/drivers/liblas/Writer.cpp              |  32 +++++-----
 src/drivers/oci/Reader.cpp                 |  20 +++++++
 src/filters/ColorFilter.cpp                |  22 ++----
 src/filters/CropFilter.cpp                 |  51 +++++++++--------
 src/filters/DecimationFilter.cpp           |   6 ++
 src/filters/MosaicFilter.cpp               |  16 ++---
 test/unit/CMakeLists.txt                   |   2 +-
 test/unit/ChipperTest.cpp                  |   5 +-
 test/unit/CropFilterTest.cpp               |  20 +++---
 test/unit/LiblasReaderTest.cpp             |   6 +-
 test/unit/LiblasWriterTest.cpp             |  12 ++-
 test/unit/main.cpp                         |  56 +++++++++++++++---
 44 files changed, 390 insertions(+), 292 deletions(-)

diffs (truncated from 1501 to 300 lines):

diff -r e42e3d5bfd7e -r 2bf8231103da apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/apps/pc2pc.cpp	Wed Mar 16 14:37:25 2011 -0500
@@ -107,11 +107,11 @@
 
     if (hasOption("native"))
     {
-        LasReader reader(*ifs);
+        libpc::drivers::las::LasReader reader(*ifs);
     
         const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
 
-        LasWriter writer(reader, *ofs);
+        libpc::drivers::las::LasWriter writer(reader, *ofs);
 
         //BUG: handle laz writer.setCompressed(false);
 
@@ -127,7 +127,7 @@
     else if (hasOption("oracle"))
     {
 #ifdef HAVE_ORACLE
-        LiblasReader reader(*ifs);
+        libpc::drivers::liblas::LiblasReader reader(*ifs);
     
         const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
         
@@ -158,11 +158,11 @@
 #endif
     else
     {
-        LiblasReader reader(*ifs);
+        libpc::drivers::liblas::LiblasReader reader(*ifs);
     
         const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
 
-        LiblasWriter writer(reader, *ofs);
+        libpc::drivers::liblas::LiblasWriter writer(reader, *ofs);
 
         //BUG: handle laz writer.setCompressed(false);
 
diff -r e42e3d5bfd7e -r 2bf8231103da apps/pcinfo.cpp
--- a/apps/pcinfo.cpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/apps/pcinfo.cpp	Wed Mar 16 14:37:25 2011 -0500
@@ -81,11 +81,11 @@
     libpc::Reader* reader = NULL;
     if (hasOption("native"))
     {
-        reader = new LasReader(*ifs);
+        reader = new libpc::drivers::las::LasReader(*ifs);
     }
     else
     {
-        reader = new LiblasReader(*ifs);
+        reader = new libpc::drivers::liblas::LiblasReader(*ifs);
     }
 
     boost::uint64_t numPoints = reader->getNumPoints();
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/Filter.hpp
--- a/include/libpc/Filter.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/Filter.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -48,11 +48,6 @@
     Filter(Stage& prevStage);
 
 protected:
-    // advance (or retreat) to the Nth point in the file (absolute, 
-    // default behaviour for filters is just to call seek on the previous stage
-    virtual void seekToPoint(boost::uint64_t pointNum);
-
-protected:
     Stage& m_prevStage;
 
 private:
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/Iterator.hpp
--- a/include/libpc/Iterator.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/Iterator.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -40,7 +40,59 @@
 namespace libpc
 {
 
+class LIBPC_DLL Iterator
+{
+public:
+    Iterator(const Stage& stage);
 
+    const Stage& getStage() const;
+
+    // This reads a set of points at the current position in the file.
+    //
+    // The schema of the PointData buffer we are given here might
+    // not match our own header's schema.  That's okay, though: all
+    // that matters is that the buffer we are given has the fields
+    // we need to write into.
+    //
+    // This is NOT virtual.  Derived classes should override the 
+    // readBuffer function below, not this one.
+    //
+    // Returns the number of valid points read.
+    boost::uint32_t read(PointData&);
+
+    // advance (or retreat) to the Nth point in the file (absolute, 
+    // not relative).  In some cases, this might be a very slow, painful
+    // function to call.
+    virtual void seekToPoint(boost::uint64_t pointNum) = 0;
+
+    // Returns the current point number.  The first point is 0.
+    // If this number if > getNumPoints(), then no more points
+    // may be read (and atEnd() should be true).
+    boost::uint64_t getCurrentPointIndex() const;
+
+    // returns true after we've read all the points available to this stage
+    // (actually a convenience function that compares getCurrentPointIndex and getNumPoints)
+    bool atEnd() const;
+
+protected:
+    // Implement this to do the actual work to fill in a buffer of points.
+    virtual boost::uint32_t readBuffer(PointData&) = 0;
+
+    // Each concrete stage is repsonsible for managing its own current
+    // point index when a read or seek occurs.  Call this function to set
+    // the value.
+    void setCurrentPointIndex(boost::uint64_t delta);
+
+    // this is easier than saying setCurrentPointIndex(getCurrentPointIndex()+n)
+    void incrementCurrentPointIndex(boost::uint64_t currentPointDelta);
+
+private:
+    const Stage& m_stage;
+    boost::uint64_t m_currentPointIndex;
+
+    Iterator& operator=(const Iterator&); // not implemented
+    Iterator(const Iterator&); // not implemented
+};
 
 } // namespace libpc
 
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/PointData.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -58,21 +58,22 @@
 {
     
 public:
-    typedef std::vector<boost::uint8_t> valid_mask_type;
     
     // note that when we make a PointData object all the fields are initialized to inactive,
     // regardless of what the passed-in schema says -- this is because the field object
     // represents the state within the owning object, which in this case is a completely
     // empty buffer (similarly, all the points in the buffer are marked "invalid")
-    PointData(const SchemaLayout&, boost::uint32_t numPoints);
+    PointData(const SchemaLayout&, boost::uint32_t capacity);
     ~PointData();
 
     // number of points in this buffer
     boost::uint32_t getNumPoints() const;
+    
+    inline void setNumPoints(boost::uint32_t v) { m_numPoints = v; } 
 
     // number of points in this buffer that have legit data; initially will be zero,
     // and after a read() call it will be in the range 0 to getNumPoints()-1
-    boost::uint32_t getNumValidPoints();
+    boost::uint32_t getCapacity();
 
     // schema (number and kinds of fields) for a point in this buffer
     const SchemaLayout& getSchemaLayout() const
@@ -86,13 +87,6 @@
         return m_schemaLayout.getSchema();
     }
 
-    // "valid" means the data for the point can be used; if invalid, the point should
-    // be ignored or skipped.  (This is done for efficiency; we don't want to have to
-    // modify the buffer's size just to "delete" a point.)
-    bool isValid(valid_mask_type::size_type pointIndex) const;
-    bool allValid() const;
-    void setValid(valid_mask_type::size_type  pointIndex, bool value=true);
-    
 
     // accessors to a particular field of a particular point in this buffer
     template<class T> T getField(std::size_t pointIndex, std::size_t fieldIndex) const;
@@ -114,8 +108,7 @@
     boost::uint8_t* m_data;
     std::size_t m_pointSize;
     boost::uint32_t m_numPoints;
-    
-    valid_mask_type m_isValid; // one byte for each point
+    boost::uint32_t m_capacity;    
 
     PointData(const PointData&); // not implemented
     PointData& operator=(const PointData&); // not implemented
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/Reader.hpp
--- a/include/libpc/Reader.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/Reader.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -46,10 +46,6 @@
 public:
     Reader();
 
-    // default is to read N points manually
-    // override this if you can
-    virtual void seekToPoint(boost::uint64_t pointNum);
-
 private:
     Reader& operator=(const Reader&); // not implemented
     Reader(const Reader&); // not implemented
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/drivers/las/Header.hpp
--- a/include/libpc/drivers/las/Header.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/drivers/las/Header.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -51,8 +51,8 @@
 
 #include <libpc/Header.hpp>
 
-namespace libpc
-{
+namespace libpc { namespace drivers { namespace las {
+
 
 class LIBPC_DLL LasHeader : public Header
 {
@@ -409,6 +409,6 @@
 
 LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const LasHeader&);
 
-} // namespace libpc
+} } } // namespace
 
 #endif
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/drivers/las/Reader.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -40,8 +40,8 @@
 #include <libpc/Reader.hpp>
 #include <libpc/drivers/las/Header.hpp>
 
-namespace libpc
-{
+namespace libpc { namespace drivers { namespace las {
+
 
 class LIBPC_DLL LasReader : public Reader
 {
@@ -69,6 +69,6 @@
     LasReader(const LasReader&); // not implemented
 };
 
-} // namespace libpc
+} } } // namespaces
 
 #endif
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/drivers/las/Writer.hpp
--- a/include/libpc/drivers/las/Writer.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/drivers/las/Writer.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -38,8 +38,8 @@
 #include <libpc/Writer.hpp>
 #include <libpc/drivers/las/Header.hpp>
 
-namespace libpc
-{
+namespace libpc { namespace drivers { namespace las {
+
 
 class LIBPC_DLL LasWriter : public Writer
 {
@@ -66,6 +66,6 @@
     LasWriter(const LasWriter&); // not implemented
 };
 
-} // namespace libpc
+} } } // namespaces
 
 #endif
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/drivers/liblas/Header.hpp
--- a/include/libpc/drivers/liblas/Header.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/drivers/liblas/Header.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -43,8 +43,8 @@
 
 #include "libpc/Header.hpp"
 
-namespace libpc
-{
+namespace libpc { namespace drivers { namespace liblas {
+
 
 class LIBPC_DLL LiblasHeader : public Header
 {
@@ -58,6 +58,6 @@
 
 LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const LiblasHeader&);
 
-} // namespace libpc
+} } } // namespaces
 
 #endif
diff -r e42e3d5bfd7e -r 2bf8231103da include/libpc/drivers/liblas/Reader.hpp
--- a/include/libpc/drivers/liblas/Reader.hpp	Wed Mar 16 12:11:43 2011 -0500
+++ b/include/libpc/drivers/liblas/Reader.hpp	Wed Mar 16 14:37:25 2011 -0500
@@ -47,9 +47,8 @@
     class Reader;
 }
 
+namespace libpc { namespace drivers { namespace liblas {
 
-namespace libpc


More information about the Liblas-commits mailing list