[Liblas-commits] hg-main-tree: rename Iterator -> SequentialIterator
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Mar 23 18:43:26 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/e78fddb2f89e
changeset: 417:e78fddb2f89e
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Mar 23 14:59:25 2011 -0700
description:
rename Iterator -> SequentialIterator
Subject: hg-main-tree: added random iterators
details: http://hg.libpc.orghg-main-tree/rev/e175564d9a6c
changeset: 418:e175564d9a6c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Mar 23 15:43:21 2011 -0700
description:
added random iterators
diffstat:
include/libpc/FilterIterator.hpp | 33 +++-
include/libpc/Iterator.hpp | 68 +++++++--
include/libpc/Stage.hpp | 8 +-
include/libpc/drivers/faux/Iterator.hpp | 16 ++-
include/libpc/drivers/faux/Reader.hpp | 5 +-
include/libpc/drivers/las/Iterator.hpp | 20 ++-
include/libpc/drivers/las/Reader.hpp | 5 +-
include/libpc/drivers/liblas/Iterator.hpp | 20 ++-
include/libpc/drivers/liblas/Reader.hpp | 11 +-
include/libpc/filters/CacheFilter.hpp | 5 +-
include/libpc/filters/CacheFilterIterator.hpp | 16 ++-
include/libpc/filters/ColorFilter.hpp | 7 +-
include/libpc/filters/ColorFilterIterator.hpp | 4 +-
include/libpc/filters/CropFilter.hpp | 7 +-
include/libpc/filters/CropFilterIterator.hpp | 4 +-
include/libpc/filters/DecimationFilter.hpp | 7 +-
include/libpc/filters/DecimationFilterIterator.hpp | 4 +-
include/libpc/filters/MosaicFilter.hpp | 5 +-
include/libpc/filters/MosaicFilterIterator.hpp | 10 +-
src/Chipper.cpp | 2 +-
src/FilterIterator.cpp | 42 +++++-
src/Iterator.cpp | 65 +++++---
src/Writer.cpp | 2 +-
src/drivers/faux/Iterator.cpp | 31 +++-
src/drivers/faux/Reader.cpp | 9 +-
src/drivers/las/Iterator.cpp | 42 +++++-
src/drivers/las/Reader.cpp | 10 +-
src/drivers/liblas/Iterator.cpp | 146 ++++++++++++++++++++-
src/drivers/liblas/Reader.cpp | 9 +-
src/filters/CacheFilter.cpp | 10 +-
src/filters/CacheFilterIterator.cpp | 75 ++++++++++-
src/filters/ColorFilter.cpp | 4 +-
src/filters/ColorFilterIterator.cpp | 10 +-
src/filters/CropFilter.cpp | 4 +-
src/filters/CropFilterIterator.cpp | 12 +-
src/filters/DecimationFilter.cpp | 4 +-
src/filters/DecimationFilterIterator.cpp | 12 +-
src/filters/MosaicFilter.cpp | 4 +-
src/filters/MosaicFilterIterator.cpp | 20 +-
test/unit/CacheFilterTest.cpp | 4 +-
test/unit/DecimationFilterTest.cpp | 2 +-
test/unit/FauxReaderTest.cpp | 107 ++++++++++++++-
test/unit/LiblasReaderTest.cpp | 53 +++++++-
test/unit/MosaicFilterTest.cpp | 2 +-
44 files changed, 771 insertions(+), 165 deletions(-)
diffs (truncated from 1788 to 300 lines):
diff -r 9798b3952688 -r e175564d9a6c include/libpc/FilterIterator.hpp
--- a/include/libpc/FilterIterator.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/FilterIterator.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -41,27 +41,46 @@
{
class Filter;
-class FilterIterator : public Iterator
+class FilterSequentialIterator : public SequentialIterator
{
public:
- FilterIterator(const Filter&);
- virtual ~FilterIterator();
+ FilterSequentialIterator(const Filter&);
+ virtual ~FilterSequentialIterator();
protected:
- // from Iterator
+ // from SequentialIterator
virtual boost::uint32_t readImpl(PointBuffer&) = 0;
virtual boost::uint64_t skipImpl(boost::uint64_t pointNum) = 0;
virtual bool atEndImpl() const = 0;
- Iterator& getPrevIterator();
- const Iterator& getPrevIterator() const;
+ SequentialIterator& getPrevIterator();
+ const SequentialIterator& getPrevIterator() const;
private:
const Filter& m_stageAsFilter;
- Iterator* m_prevIterator;
+ SequentialIterator* m_prevIterator;
};
+class FilterRandomIterator : public RandomIterator
+{
+public:
+ FilterRandomIterator(const Filter&);
+ virtual ~FilterRandomIterator();
+
+protected:
+ // from RandomIterator
+ virtual boost::uint32_t readImpl(PointBuffer&) = 0;
+ virtual boost::uint64_t seekImpl(boost::uint64_t pointNum) = 0;
+
+ RandomIterator& getPrevIterator();
+ const RandomIterator& getPrevIterator() const;
+
+private:
+ const Filter& m_stageAsFilter;
+ RandomIterator* m_prevIterator;
+};
+
} // namespace libpc
#endif
diff -r 9798b3952688 -r e175564d9a6c include/libpc/Iterator.hpp
--- a/include/libpc/Iterator.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/Iterator.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -60,19 +60,6 @@
// Returns the number of valid points read.
boost::uint32_t read(PointBuffer&);
- // advance N points ahead in the file
- //
- // In some cases, this might be a very slow, painful function to call because
- // it might entail physically reading the N points (and dropping the data on the
- // floor)
- //
- // Returns the number actually skipped (which might be less than count, if the
- // end of the stage was reached first).
- boost::uint64_t skip(boost::uint64_t count);
-
- // returns true after we've read all the points available to this stage
- bool atEnd() const;
-
// 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).
@@ -88,12 +75,11 @@
protected:
virtual boost::uint32_t readImpl(PointBuffer&) = 0;
- virtual boost::uint64_t skipImpl(boost::uint64_t pointNum) = 0;
- virtual bool atEndImpl() const = 0;
+
+ boost::uint64_t m_index;
private:
const Stage& m_stage;
- boost::uint64_t m_index;
boost::uint32_t m_chunkSize;
Iterator& operator=(const Iterator&); // not implemented
@@ -101,6 +87,56 @@
};
+class LIBPC_DLL SequentialIterator : public Iterator
+{
+public:
+ SequentialIterator(const Stage& stage);
+ virtual ~SequentialIterator();
+
+ // advance N points ahead in the file
+ //
+ // In some cases, this might be a very slow, painful function to call because
+ // it might entail physically reading the N points (and dropping the data on the
+ // floor)
+ //
+ // Returns the number actually skipped (which might be less than count, if the
+ // end of the stage was reached first).
+ boost::uint64_t skip(boost::uint64_t count);
+
+ // returns true after we've read all the points available to this stage
+ bool atEnd() const;
+
+protected:
+ // from Iterator
+ virtual boost::uint32_t readImpl(PointBuffer&) = 0;
+
+ virtual boost::uint64_t skipImpl(boost::uint64_t pointNum) = 0;
+ virtual bool atEndImpl() const = 0;
+};
+
+
+class LIBPC_DLL RandomIterator : public Iterator
+{
+public:
+ RandomIterator(const Stage& stage);
+ virtual ~RandomIterator();
+
+ // seek to point N (an absolute value)
+ //
+ // In some cases, this might be a very slow, painful function to call because
+ // it might entail physically reading the N points (and dropping the data on the
+ // floor)
+ //
+ // Returns the number actually seeked to (which might be less than asked for, if the
+ // end of the stage was reached first).
+ boost::uint64_t seek(boost::uint64_t position);
+
+protected:
+ // from Iterator
+ virtual boost::uint64_t seekImpl(boost::uint64_t position) = 0;
+};
+
+
} // namespace libpc
#endif
diff -r 9798b3952688 -r e175564d9a6c include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/Stage.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -45,7 +45,8 @@
namespace libpc
{
-class Iterator;
+class SequentialIterator;
+class RandomIterator;
// every stage owns its own header, they are not shared
class LIBPC_DLL Stage
@@ -66,7 +67,10 @@
const Header& getHeader() const;
Header& getHeader();
- virtual Iterator* createIterator() const = 0;
+ virtual bool supportsSequentialIterator() const = 0;
+ virtual bool supportsRandomIterator() const = 0;
+ virtual SequentialIterator* createSequentialIterator() const = 0;
+ virtual RandomIterator* createRandomIterator() const = 0;
protected:
void setHeader(Header*); // stage takes ownership
diff -r 9798b3952688 -r e175564d9a6c include/libpc/drivers/faux/Iterator.hpp
--- a/include/libpc/drivers/faux/Iterator.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/drivers/faux/Iterator.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -43,10 +43,10 @@
class Reader;
-class Iterator : public libpc::Iterator
+class SequentialIterator : public libpc::SequentialIterator
{
public:
- Iterator(const Reader& reader);
+ SequentialIterator(const Reader& reader);
private:
boost::uint64_t skipImpl(boost::uint64_t);
@@ -57,6 +57,18 @@
};
+class RandomIterator : public libpc::RandomIterator
+{
+public:
+ RandomIterator(const Reader& reader);
+
+private:
+ boost::uint64_t seekImpl(boost::uint64_t);
+ boost::uint32_t readImpl(PointBuffer&);
+
+ const Reader& m_reader;
+};
+
} } } // namespaces
#endif
diff -r 9798b3952688 -r e175564d9a6c include/libpc/drivers/faux/Reader.hpp
--- a/include/libpc/drivers/faux/Reader.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/drivers/faux/Reader.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -70,7 +70,10 @@
Mode getMode() const;
- libpc::Iterator* createIterator() const;
+ bool supportsSequentialIterator() const { return true; }
+ bool supportsRandomIterator() const { return true; }
+ libpc::SequentialIterator* createSequentialIterator() const;
+ libpc::RandomIterator* createRandomIterator() const;
// this is called by the stage's iterator
boost::uint32_t processBuffer(PointBuffer& data, boost::uint64_t index) const;
diff -r 9798b3952688 -r e175564d9a6c include/libpc/drivers/las/Iterator.hpp
--- a/include/libpc/drivers/las/Iterator.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/drivers/las/Iterator.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -45,11 +45,11 @@
class LasReader;
-class Iterator : public libpc::Iterator
+class SequentialIterator : public libpc::SequentialIterator
{
public:
- Iterator(const LasReader& reader);
- ~Iterator();
+ SequentialIterator(const LasReader& reader);
+ ~SequentialIterator();
private:
boost::uint64_t skipImpl(boost::uint64_t);
@@ -61,6 +61,20 @@
};
+class RandomIterator : public libpc::RandomIterator
+{
+public:
+ RandomIterator(const LasReader& reader);
+ ~RandomIterator();
+
+private:
+ boost::uint64_t seekImpl(boost::uint64_t);
+ boost::uint32_t readImpl(PointBuffer&);
+
+ const LasReader& m_reader;
+ std::istream* m_istream;
+};
+
} } } // namespaces
#endif
diff -r 9798b3952688 -r e175564d9a6c include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/drivers/las/Reader.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -54,7 +54,10 @@
const LasHeader& getLasHeader() const;
- libpc::Iterator* createIterator() const;
+ bool supportsSequentialIterator() const { return true; }
+ bool supportsRandomIterator() const { return true; }
+ libpc::SequentialIterator* createSequentialIterator() const;
+ libpc::RandomIterator* createRandomIterator() const;
// this is called by the stage's iterator
boost::uint32_t processBuffer(PointBuffer& PointBuffer, std::istream& stream) const;
diff -r 9798b3952688 -r e175564d9a6c include/libpc/drivers/liblas/Iterator.hpp
--- a/include/libpc/drivers/liblas/Iterator.hpp Wed Mar 23 16:37:10 2011 -0500
+++ b/include/libpc/drivers/liblas/Iterator.hpp Wed Mar 23 15:43:21 2011 -0700
@@ -53,11 +53,11 @@
class LiblasReader;
-class Iterator : public libpc::Iterator
+class SequentialIterator : public libpc::SequentialIterator
{
public:
- Iterator(const LiblasReader& reader);
- ~Iterator();
+ SequentialIterator(const LiblasReader& reader);
+ ~SequentialIterator();
private:
boost::uint64_t skipImpl(boost::uint64_t);
@@ -68,6 +68,20 @@
More information about the Liblas-commits
mailing list