[Liblas-commits] hg-main-tree: typo in IDE grouping

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Mar 16 14:48:38 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/34feaae2d8e1
changeset: 282:34feaae2d8e1
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 12:36:51 2011 -0400
description:
typo in IDE grouping
Subject: hg-main-tree: getting ready for iterators

details:   http://hg.libpc.orghg-main-tree/rev/dca67ac0c18f
changeset: 283:dca67ac0c18f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 12:48:57 2011 -0400
description:
getting ready for iterators
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/75963464ef43
changeset: 284:75963464ef43
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 12:49:08 2011 -0400
description:
merge
Subject: hg-main-tree: switch to doubles

details:   http://hg.libpc.orghg-main-tree/rev/7989873fcfc9
changeset: 285:7989873fcfc9
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 14:48:05 2011 -0400
description:
switch to doubles
Subject: hg-main-tree: placeholder for future work

details:   http://hg.libpc.orghg-main-tree/rev/2e4055a83b12
changeset: 286:2e4055a83b12
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 14:48:21 2011 -0400
description:
placeholder for future work
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/ad4691436b2d
changeset: 287:ad4691436b2d
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 14:48:35 2011 -0400
description:
merge

diffstat:

 include/libpc/Filter.hpp                   |   5 -
 include/libpc/Iterator.hpp                 |  52 ++++++++++++++++++
 include/libpc/Reader.hpp                   |   4 -
 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/Reader.cpp                             |  19 ------
 src/drivers/faux/Reader.cpp                |  30 +++++-----
 src/drivers/oci/Reader.cpp                 |  20 +++++++
 src/filters/CropFilter.cpp                 |   6 ++
 src/filters/DecimationFilter.cpp           |   6 ++
 src/filters/MosaicFilter.cpp               |   6 ++
 test/unit/CropFilterTest.cpp               |  18 +++---
 test/unit/FauxReaderTest.cpp               |  12 ++--
 test/unit/PointDataTest.cpp                |  13 +++-
 19 files changed, 223 insertions(+), 70 deletions(-)

diffs (truncated from 534 to 300 lines):

diff -r 05bd6aca69e4 -r ad4691436b2d include/libpc/Filter.hpp
--- a/include/libpc/Filter.hpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/include/libpc/Filter.hpp	Wed Mar 16 14:48:35 2011 -0400
@@ -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 05bd6aca69e4 -r ad4691436b2d include/libpc/Iterator.hpp
--- a/include/libpc/Iterator.hpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/include/libpc/Iterator.hpp	Wed Mar 16 14:48:35 2011 -0400
@@ -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 05bd6aca69e4 -r ad4691436b2d include/libpc/Reader.hpp
--- a/include/libpc/Reader.hpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/include/libpc/Reader.hpp	Wed Mar 16 14:48:35 2011 -0400
@@ -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 05bd6aca69e4 -r ad4691436b2d include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/include/libpc/drivers/oci/Reader.hpp	Wed Mar 16 14:48:35 2011 -0400
@@ -57,6 +57,8 @@
     ~Reader();
     
     const std::string& getName() const;
+ 
+    void seekToPoint(boost::uint64_t pointNum);
 
 private:
 
diff -r 05bd6aca69e4 -r ad4691436b2d include/libpc/filters/CropFilter.hpp
--- a/include/libpc/filters/CropFilter.hpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/include/libpc/filters/CropFilter.hpp	Wed Mar 16 14:48:35 2011 -0400
@@ -50,6 +50,8 @@
 
     const std::string& getName() const;
 
+    void seekToPoint(boost::uint64_t pointNum);
+
 private:
     boost::uint32_t readBuffer(PointData&);
 
diff -r 05bd6aca69e4 -r ad4691436b2d include/libpc/filters/DecimationFilter.hpp
--- a/include/libpc/filters/DecimationFilter.hpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/include/libpc/filters/DecimationFilter.hpp	Wed Mar 16 14:48:35 2011 -0400
@@ -50,6 +50,8 @@
 
     const std::string& getName() const;
 
+    void seekToPoint(boost::uint64_t pointNum);
+
 private:
     boost::uint32_t readBuffer(PointData&);
 
diff -r 05bd6aca69e4 -r ad4691436b2d include/libpc/filters/MosaicFilter.hpp
--- a/include/libpc/filters/MosaicFilter.hpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/include/libpc/filters/MosaicFilter.hpp	Wed Mar 16 14:48:35 2011 -0400
@@ -49,7 +49,7 @@
     
     const std::string& getName() const;
 
-    // BUG: what does seetToPoint() do for a mosaic filter?
+    void seekToPoint(boost::uint64_t pointNum);
 
 private:
     boost::uint32_t readBuffer(PointData&);
diff -r 05bd6aca69e4 -r ad4691436b2d src/CMakeLists.txt
--- a/src/CMakeLists.txt	Wed Mar 16 11:15:07 2011 -0500
+++ b/src/CMakeLists.txt	Wed Mar 16 14:48:35 2011 -0400
@@ -65,6 +65,7 @@
   DimensionLayout.cpp
   Filter.cpp
   Header.cpp
+  Iterator.cpp
   Metadata.cpp
   Vector.cpp  
   PointData.cpp
@@ -199,7 +200,7 @@
   ${LIBPC_HEADERS_DIR}/filters/MosaicFilter.hpp
 )
 
-set (LIBPC_FILTERS_HPP 
+set (LIBPC_FILTERS_CPP 
   ./filters/CacheFilter.cpp
   ./filters/ColorFilter.cpp
   ./filters/CropFilter.cpp
diff -r 05bd6aca69e4 -r ad4691436b2d src/Filter.cpp
--- a/src/Filter.cpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/src/Filter.cpp	Wed Mar 16 14:48:35 2011 -0400
@@ -48,10 +48,4 @@
 }
 
 
-void Filter::seekToPoint(boost::uint64_t pointNum)
-{
-    m_prevStage.seekToPoint(pointNum);
-}
-
-
 } // namespace libpc
diff -r 05bd6aca69e4 -r ad4691436b2d src/Iterator.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Iterator.cpp	Wed Mar 16 14:48:35 2011 -0400
@@ -0,0 +1,85 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following
+* conditions are met:
+*
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above copyright
+*       notice, this list of conditions and the following disclaimer in
+*       the documentation and/or other materials provided
+*       with the distribution.
+*     * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
+*       names of its contributors may be used to endorse or promote
+*       products derived from this software without specific prior
+*       written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+* OF SUCH DAMAGE.
+****************************************************************************/
+
+#include <libpc/Iterator.hpp>
+
+namespace libpc
+{
+
+
+Iterator::Iterator(const Stage& stage)
+    : m_stage(stage)
+    , m_currentPointIndex(0)
+{
+    return;
+}
+
+
+const Stage& Iterator::getStage() const
+{
+    return m_stage;
+}
+
+
+void Iterator::setCurrentPointIndex(boost::uint64_t currentPointIndex)
+{
+    m_currentPointIndex = currentPointIndex;
+}
+
+
+boost::uint64_t Iterator::getCurrentPointIndex() const
+{
+    return m_currentPointIndex;
+}
+
+void Iterator::incrementCurrentPointIndex(boost::uint64_t delta)
+{
+    m_currentPointIndex += delta;
+}
+
+
+boost::uint32_t Iterator::read(PointData& data)
+{
+    const boost::uint32_t numPointsRead = readBuffer(data);
+    return numPointsRead;
+}
+
+
+bool Iterator::atEnd() const
+{
+    return getCurrentPointIndex() >= getStage().getNumPoints();
+}
+
+
+} // namespace libpc
diff -r 05bd6aca69e4 -r ad4691436b2d src/Reader.cpp
--- a/src/Reader.cpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/src/Reader.cpp	Wed Mar 16 14:48:35 2011 -0400
@@ -44,24 +44,5 @@
 }
 
 
-void Reader::seekToPoint(boost::uint64_t pointNum)
-{
-    if (pointNum == getCurrentPointIndex())
-    {
-        return;
-    }
-
-    setCurrentPointIndex(0);
-    
-    // we read the points only to get to the right place -- we
-    // will just drop the points on the floor and return
-    boost::uint32_t pointNumX = (boost::uint32_t)pointNum; // BUG
-    assert(pointNumX == pointNum);
-    PointData pointData(getHeader().getSchema(), pointNumX);
-    read(pointData);
-
-    return;
-}
-
 
 } // namespace libpc
diff -r 05bd6aca69e4 -r ad4691436b2d src/drivers/faux/Reader.cpp
--- a/src/drivers/faux/Reader.cpp	Wed Mar 16 11:15:07 2011 -0500
+++ b/src/drivers/faux/Reader.cpp	Wed Mar 16 14:48:35 2011 -0400
@@ -52,9 +52,9 @@
     Header* header = new Header;
     Schema& schema = header->getSchema();
 
-    schema.addDimension(Dimension(Dimension::Field_X, Dimension::Float));
-    schema.addDimension(Dimension(Dimension::Field_Y, Dimension::Float));


More information about the Liblas-commits mailing list