[Liblas-commits] hg-main-tree: iter work

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Mar 17 15:11:06 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/c4ef3144a018
changeset: 345:c4ef3144a018
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 14:56:34 2011 -0400
description:
iter work
Subject: hg-main-tree: added bounds member

details:   http://hg.libpc.orghg-main-tree/rev/c0f0c4b82e52
changeset: 346:c0f0c4b82e52
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 15:11:02 2011 -0400
description:
added bounds member

diffstat:

 include/libpc/Filter.hpp         |   2 +
 include/libpc/FilterIterator.hpp |  57 ++++++++++++++++++++++++++++++++++++++++
 include/libpc/Iterator.hpp       |  12 ++++---
 include/libpc/PointData.hpp      |   6 +++-
 src/CMakeLists.txt               |   2 +
 src/Filter.cpp                   |   6 ++++
 src/FilterIterator.cpp           |  53 +++++++++++++++++++++++++++++++++++++
 src/Iterator.cpp                 |   8 +++--
 src/PointData.cpp                |  25 +++++++++++++----
 9 files changed, 156 insertions(+), 15 deletions(-)

diffs (truncated from 331 to 300 lines):

diff -r 39fb91c27f98 -r c0f0c4b82e52 include/libpc/Filter.hpp
--- a/include/libpc/Filter.hpp	Thu Mar 17 14:24:36 2011 -0400
+++ b/include/libpc/Filter.hpp	Thu Mar 17 15:11:02 2011 -0400
@@ -47,6 +47,8 @@
 public:
     Filter(Stage& prevStage);
 
+    Stage& getPrevStage() const;
+
 protected:
     Stage& m_prevStage;
 
diff -r 39fb91c27f98 -r c0f0c4b82e52 include/libpc/FilterIterator.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/FilterIterator.hpp	Thu Mar 17 15:11:02 2011 -0400
@@ -0,0 +1,57 @@
+/******************************************************************************
+* 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.
+****************************************************************************/
+
+#ifndef INCLUDED_FILTERITERATOR_HPP
+#define INCLUDED_FILTERITERATOR_HPP
+
+#include <libpc/Iterator.hpp>
+
+namespace libpc
+{
+class Filter;
+
+class FilterIterator : public Iterator
+{
+public:
+    FilterIterator(Filter&, const Bounds<double>& bounds);
+
+private:
+    Filter& m_stageAsFilter;
+    Iterator* m_prevIterator;
+};
+
+
+} // namespace libpc
+
+#endif
diff -r 39fb91c27f98 -r c0f0c4b82e52 include/libpc/Iterator.hpp
--- a/include/libpc/Iterator.hpp	Thu Mar 17 14:24:36 2011 -0400
+++ b/include/libpc/Iterator.hpp	Thu Mar 17 15:11:02 2011 -0400
@@ -35,18 +35,19 @@
 #ifndef INCLUDED_ITERATOR_HPP
 #define INCLUDED_ITERATOR_HPP
 
-#include <libpc/Stage.hpp>
 #include <libpc/Bounds.hpp>
 
 namespace libpc
 {
+class Stage;
+class PointData;
 
 class LIBPC_DLL Iterator
 {
 public:
-    Iterator(const Stage& stage, const Bounds<double>& bounds);
+    Iterator(Stage& stage, const Bounds<double>& bounds);
 
-    const Stage& getStage() const;
+    Stage& getStage();
 
     // This reads a set of points at the current position in the file.
     //
@@ -68,7 +69,7 @@
 
     // 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;
+    bool atEnd();
 
 protected:
     // Returns the current point number.  The first point is 0.
@@ -88,7 +89,7 @@
     void incrementCurrentPointIndex(boost::uint64_t currentPointDelta);
 
 private:
-    const Stage& m_stage;
+    Stage& m_stage;
     boost::uint64_t m_currentPointIndex;
     const Bounds<double> m_bounds;
 
@@ -96,6 +97,7 @@
     Iterator(const Iterator&); // not implemented
 };
 
+
 } // namespace libpc
 
 #endif
diff -r 39fb91c27f98 -r c0f0c4b82e52 include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp	Thu Mar 17 14:24:36 2011 -0400
+++ b/include/libpc/PointData.hpp	Thu Mar 17 15:11:02 2011 -0400
@@ -38,6 +38,7 @@
 #include <boost/cstdint.hpp>
 
 #include <libpc/export.hpp>
+#include <libpc/Bounds.hpp>
 #include <libpc/SchemaLayout.hpp>
 
 namespace libpc
@@ -66,6 +67,9 @@
     PointData(const SchemaLayout&, boost::uint32_t capacity);
     ~PointData();
 
+    const Bounds<double>& getSpatialBounds() const;
+    void setSpatialBounds(const Bounds<double>& bounds);
+
     // number of points in this buffer
     boost::uint32_t getNumPoints() const;
     
@@ -89,7 +93,6 @@
         return m_schemaLayout.getSchema();
     }
 
-
     // 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;
     template<class T> void setField(std::size_t pointIndex, std::size_t fieldIndex, T value);
@@ -111,6 +114,7 @@
     std::size_t m_pointSize;
     boost::uint32_t m_numPoints;
     boost::uint32_t m_capacity;    
+    Bounds<double> m_bounds;
 
     PointData(const PointData&); // not implemented
     PointData& operator=(const PointData&); // not implemented
diff -r 39fb91c27f98 -r c0f0c4b82e52 src/CMakeLists.txt
--- a/src/CMakeLists.txt	Thu Mar 17 14:24:36 2011 -0400
+++ b/src/CMakeLists.txt	Thu Mar 17 15:11:02 2011 -0400
@@ -42,6 +42,7 @@
   ${LIBPC_HEADERS_DIR}/Dimension.hpp
   ${LIBPC_HEADERS_DIR}/DimensionLayout.hpp
   ${LIBPC_HEADERS_DIR}/Filter.hpp
+  ${LIBPC_HEADERS_DIR}/FilterIterator.hpp
   ${LIBPC_HEADERS_DIR}/Header.hpp
   ${LIBPC_HEADERS_DIR}/Iterator.hpp
   ${LIBPC_HEADERS_DIR}/Metadata.hpp
@@ -65,6 +66,7 @@
   Dimension.cpp
   DimensionLayout.cpp
   Filter.cpp
+  FilterIterator.cpp
   Header.cpp
   Iterator.cpp
   Metadata.cpp
diff -r 39fb91c27f98 -r c0f0c4b82e52 src/Filter.cpp
--- a/src/Filter.cpp	Thu Mar 17 14:24:36 2011 -0400
+++ b/src/Filter.cpp	Thu Mar 17 15:11:02 2011 -0400
@@ -48,4 +48,10 @@
 }
 
 
+Stage& Filter::getPrevStage() const
+{
+    return m_prevStage;
+}
+
+
 } // namespace libpc
diff -r 39fb91c27f98 -r c0f0c4b82e52 src/FilterIterator.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FilterIterator.cpp	Thu Mar 17 15:11:02 2011 -0400
@@ -0,0 +1,53 @@
+/******************************************************************************
+* 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/FilterIterator.hpp>
+#include <libpc/Filter.hpp>
+
+namespace libpc
+{
+
+
+FilterIterator::FilterIterator(Filter& filter, const Bounds<double>& bounds)
+    : Iterator(filter, bounds)
+    , m_stageAsFilter(static_cast<Filter&>(filter))
+    , m_prevIterator(NULL)
+{
+    m_prevIterator = m_stageAsFilter.getPrevStage().createIterator(bounds);
+
+    return;
+}
+
+
+} // namespace libpc
diff -r 39fb91c27f98 -r c0f0c4b82e52 src/Iterator.cpp
--- a/src/Iterator.cpp	Thu Mar 17 14:24:36 2011 -0400
+++ b/src/Iterator.cpp	Thu Mar 17 15:11:02 2011 -0400
@@ -33,12 +33,14 @@
 ****************************************************************************/
 
 #include <libpc/Iterator.hpp>
+#include <libpc/Stage.hpp>
+#include <libpc/Filter.hpp>
 
 namespace libpc
 {
 
 
-Iterator::Iterator(const Stage& stage, const Bounds<double>& bounds)
+Iterator::Iterator(Stage& stage, const Bounds<double>& bounds)
     : m_stage(stage)
     , m_currentPointIndex(0)
     , m_bounds(bounds)
@@ -47,7 +49,7 @@
 }
 
 
-const Stage& Iterator::getStage() const
+Stage& Iterator::getStage()
 {
     return m_stage;
 }
@@ -77,7 +79,7 @@
 }
 
 
-bool Iterator::atEnd() const
+bool Iterator::atEnd()
 {
     return getCurrentPointIndex() >= getStage().getNumPoints();
 }
diff -r 39fb91c27f98 -r c0f0c4b82e52 src/PointData.cpp
--- a/src/PointData.cpp	Thu Mar 17 14:24:36 2011 -0400
+++ b/src/PointData.cpp	Thu Mar 17 15:11:02 2011 -0400
@@ -44,12 +44,13 @@
 {
 
 
-PointData::PointData(const SchemaLayout& schemaLayout, boost::uint32_t capacity) :
-    m_schemaLayout(schemaLayout),
-    m_data(NULL),
-    m_pointSize(m_schemaLayout.getByteSize()),


More information about the Liblas-commits mailing list