[Liblas-commits] hg-main-tree: BlockIterator scaffolding

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Mar 25 15:58:19 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/3733f45c647c
changeset: 471:3733f45c647c
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Mar 25 14:56:40 2011 -0500
description:
BlockIterator scaffolding
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/65fe5562bd8e
changeset: 472:65fe5562bd8e
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Mar 25 14:58:05 2011 -0500
description:
merge

diffstat:

 include/libpc/Stage.hpp                       |   2 +
 include/libpc/Utils.hpp                       |   7 +++--
 include/libpc/filters/ChipperIterator.hpp     |  27 ++++++++++++-------------
 include/libpc/filters/ColorFilterIterator.hpp |   5 +---
 src/FilterIterator.cpp                        |  28 +++++++++++++++++++++++++++
 src/Iterator.cpp                              |  20 +++++++++++++++++++
 src/filters/ChipperIterator.cpp               |  13 +++++------
 test/unit/UtilsTest.cpp                       |  11 ++++++++++
 8 files changed, 85 insertions(+), 28 deletions(-)

diffs (213 lines):

diff -r 5f62edc05de5 -r 65fe5562bd8e include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/include/libpc/Stage.hpp	Fri Mar 25 14:58:05 2011 -0500
@@ -47,6 +47,7 @@
 class Iterator;
 class SequentialIterator;
 class RandomIterator;
+class BlockIterator;
 
 // every stage owns its own header, they are not shared
 class LIBPC_DLL Stage
@@ -73,6 +74,7 @@
     virtual bool supportsRandomIterator() const { return false; }
     virtual SequentialIterator* createSequentialIterator() const { return NULL; }
     virtual RandomIterator* createRandomIterator() const  { return NULL; }
+    virtual BlockIterator* createBlockIterator() const  { return NULL; }
 
 protected:
     void setHeader(Header*); // stage takes ownership
diff -r 5f62edc05de5 -r 65fe5562bd8e include/libpc/Utils.hpp
--- a/include/libpc/Utils.hpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/include/libpc/Utils.hpp	Fri Mar 25 14:58:05 2011 -0500
@@ -62,13 +62,14 @@
     }
 
     // compares two values to within a given tolerance
-    // BUG: need to disallow T to be an unsigned type
+    // the value |tolerance| is compared to |actual - expected|
     template<class T>
     static bool compare_approx(const T& actual, const T& expected, const T& tolerance)
     {
-        const T diff = actual - expected;
+        const double diff = std::abs((double)actual - (double)expected);
+        const double delta = std::abs((double)tolerance);
 
-        if ( !((diff <= tolerance) && (diff >= -tolerance )) )
+        if (diff > delta)
         {
             return false;
         }
diff -r 5f62edc05de5 -r 65fe5562bd8e include/libpc/filters/ChipperIterator.hpp
--- a/include/libpc/filters/ChipperIterator.hpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/include/libpc/filters/ChipperIterator.hpp	Fri Mar 25 14:58:05 2011 -0500
@@ -38,27 +38,26 @@
 #include <libpc/libpc.hpp>
 
 #include <libpc/FilterIterator.hpp>
-
+#include <libpc/filters/Chipper.hpp>
 namespace libpc {
 
 
 namespace filters {
 
-class Chipper;
 
 
-// class ChipperBlockIterator : public libpc::FilterBlockIterator
-// {
-// public:
-//     ChipperBlockIterator(const Chipper& filter);
-// 
-// private:
-//     boost::uint64_t skipImpl(boost::uint64_t);
-//     boost::uint32_t readImpl(PointBuffer&);
-//     bool atEndImpl() const;
-// 
-//     const Chipper& m_chipper;
-// };
+class ChipperBlockIterator : public libpc::FilterBlockIterator
+{
+public:
+    ChipperBlockIterator(const Chipper& filter);
+
+private:
+    // boost::uint64_t skipImpl(boost::uint64_t);
+    // boost::uint32_t readImpl(PointBuffer&);
+    // bool atEndImpl() const;
+
+    const Chipper& m_chipper;
+};
 
 
 } } // namespaces
diff -r 5f62edc05de5 -r 65fe5562bd8e include/libpc/filters/ColorFilterIterator.hpp
--- a/include/libpc/filters/ColorFilterIterator.hpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/include/libpc/filters/ColorFilterIterator.hpp	Fri Mar 25 14:58:05 2011 -0500
@@ -36,15 +36,12 @@
 #define INCLUDED_FILTERS_COLORFILTERITERATOR_HPP
 
 #include <libpc/libpc.hpp>
-//#include <boost/cstdint.hpp>
 
-//#include <libpc/export.hpp>
-//#include <libpc/Filter.hpp>
+#include <libpc/filters/ColorFilter.hpp>
 #include <libpc/FilterIterator.hpp>
 
 namespace libpc { namespace filters {
 
-class ColorFilter;
 
 class ColorFilterSequentialIterator : public libpc::FilterSequentialIterator
 {
diff -r 5f62edc05de5 -r 65fe5562bd8e src/FilterIterator.cpp
--- a/src/FilterIterator.cpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/src/FilterIterator.cpp	Fri Mar 25 14:58:05 2011 -0500
@@ -97,5 +97,33 @@
     return *m_prevIterator;
 }
 
+FilterBlockIterator::FilterBlockIterator(const Filter& filter)
+    : BlockIterator(filter)
+    , m_filter(filter)
+    , m_prevIterator(NULL)
+{
+    m_prevIterator = m_filter.getPrevStage().createBlockIterator();
+
+    return;
+}
+
+
+FilterBlockIterator::~FilterBlockIterator()
+{
+    delete m_prevIterator;
+}
+
+
+BlockIterator& FilterBlockIterator::getPrevIterator()
+{
+    return *m_prevIterator;
+}
+
+
+const BlockIterator& FilterBlockIterator::getPrevIterator() const
+{
+    return *m_prevIterator;
+}
+
 
 } // namespace libpc
diff -r 5f62edc05de5 -r 65fe5562bd8e src/Iterator.cpp
--- a/src/Iterator.cpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/src/Iterator.cpp	Fri Mar 25 14:58:05 2011 -0500
@@ -190,4 +190,24 @@
 }
 
 
+//---------------------------------------------------------------------------
+//
+// BlockIterator
+//
+//---------------------------------------------------------------------------
+
+BlockIterator::BlockIterator(const Stage& stage)
+    : Iterator(stage)
+{
+    return;
+}
+
+
+BlockIterator::~BlockIterator()
+{
+    return;
+}
+
+
+
 } // namespace libpc
diff -r 5f62edc05de5 -r 65fe5562bd8e src/filters/ChipperIterator.cpp
--- a/src/filters/ChipperIterator.cpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/src/filters/ChipperIterator.cpp	Fri Mar 25 14:58:05 2011 -0500
@@ -38,13 +38,12 @@
 namespace libpc { namespace filters {
 
 
-// ChipperBlockIterator::ChipperBlockIterator(Chipper const& filter)
-//     : libpc::FilterBlockIterator(filter)
-//     , m_chipper(filter)
-// {
-//     return;
-// }
-
+ChipperBlockIterator::ChipperBlockIterator(Chipper const& filter)
+    : libpc::FilterBlockIterator(filter)
+    , m_chipper(filter)
+{
+    return;
+}
 
 // boost::uint64_t ChipperSequentialIterator::skipImpl(boost::uint64_t count)
 // {
diff -r 5f62edc05de5 -r 65fe5562bd8e test/unit/UtilsTest.cpp
--- a/test/unit/UtilsTest.cpp	Fri Mar 25 13:58:59 2011 -0500
+++ b/test/unit/UtilsTest.cpp	Fri Mar 25 14:58:05 2011 -0500
@@ -98,6 +98,17 @@
         ok = Utils::compare_approx<float>(1.001f, 1.0f, 0.1f);
         BOOST_CHECK(ok);
     }
+
+    {
+        ok = Utils::compare_approx<unsigned int>(10, 12, 2);
+        BOOST_CHECK(ok);
+
+        ok = Utils::compare_approx<unsigned int>(10, 12, 3);
+        BOOST_CHECK(ok);
+
+        ok = Utils::compare_approx<unsigned int>(10, 12, 1);
+        BOOST_CHECK(!ok);
+    }
 }
 
 


More information about the Liblas-commits mailing list