[Liblas-commits] hg-main-tree: start making the Chipper a filter

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Mar 24 13:47:13 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/232e46be1d4e
changeset: 427:232e46be1d4e
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Mar 24 12:39:43 2011 -0500
description:
start making the Chipper a filter
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/0755b16501fb
changeset: 428:0755b16501fb
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Mar 24 12:39:53 2011 -0500
description:
merge

diffstat:

 include/libpc/Chipper.hpp                 |   21 +-
 include/libpc/ChipperIterator.hpp         |   64 +++++++
 include/libpc/drivers/liblas/Iterator.hpp |   43 +++-
 include/libpc/drivers/liblas/Reader.hpp   |   16 +-
 src/CMakeLists.txt                        |    3 +
 src/Chipper.cpp                           |   61 ++++++
 src/ChipperIterator.cpp                   |  116 ++++++++++++
 src/drivers/liblas/Iterator.cpp           |  271 +++++++++++------------------
 src/drivers/liblas/Reader.cpp             |   52 +++-
 src/drivers/oci/Writer.cpp                |  173 ++----------------
 test/unit/LiblasReaderTest.cpp            |  209 +++++++++++++++++++---
 11 files changed, 638 insertions(+), 391 deletions(-)

diffs (truncated from 1475 to 300 lines):

diff -r f99d29deba24 -r 0755b16501fb include/libpc/Chipper.hpp
--- a/include/libpc/Chipper.hpp	Thu Mar 24 09:12:53 2011 -0700
+++ b/include/libpc/Chipper.hpp	Thu Mar 24 12:39:53 2011 -0500
@@ -2,10 +2,11 @@
 #define LIBLAS_CHIPPER_H
 
 #include <libpc/Stage.hpp>
+#include <libpc/Filter.hpp>
 #include <libpc/Bounds.hpp>
 #include <libpc/export.hpp>
-#include <libpc/Dimension.hpp>
 #include <libpc/Iterator.hpp>
+#include <libpc/FilterIterator.hpp>
 
 #include <boost/scoped_ptr.hpp>
 
@@ -88,6 +89,7 @@
     std::vector<boost::uint32_t> GetIDs() const; 
     libpc::Bounds<double> const& GetBounds() const {return m_bounds;} 
     void SetBounds(libpc::Bounds<double> const& bounds) {m_bounds = bounds;}
+    PointBuffer GetBuffer( Stage& stage) const;    
     // double GetXmin() const
     //     { return m_xmin; }
     // double GetYmin() const
@@ -98,12 +100,12 @@
     //     { return m_ymax; }
 };
 
-class LIBPC_DLL Chipper
+class LIBPC_DLL Chipper : public libpc::Filter
 {
 public:
     Chipper(Stage& prevStage, boost::uint32_t max_partition_size) :
-        m_stage(prevStage), m_threshold(max_partition_size),
-        m_xvec(DIR_X), m_yvec(DIR_Y), m_spare(DIR_NONE)
+        libpc::Filter(prevStage), m_stage(prevStage), m_threshold(max_partition_size),
+        m_xvec(DIR_X), m_yvec(DIR_Y), m_spare(DIR_NONE) 
     {}
 
     void Chip();
@@ -112,6 +114,13 @@
     const Block& GetBlock(std::vector<Block>::size_type i)
         { return m_blocks[i]; }
 
+    const std::string& getName() const ;
+
+    bool supportsSequentialIterator() const { return true; }
+    bool supportsRandomIterator() const { return false; }
+    libpc::SequentialIterator* createSequentialIterator() const;
+    libpc::RandomIterator* createRandomIterator() const;
+
 private:
     void Load(RefList& xvec, RefList& yvec, RefList& spare);
     void Partition(boost::uint32_t size);
@@ -124,7 +133,9 @@
         boost::uint32_t pleft, boost::uint32_t pcenter);
     void Emit(RefList& wide, boost::uint32_t widemin, boost::uint32_t widemax,
         RefList& narrow, boost::uint32_t narrowmin, boost::uint32_t narrowmax );
-
+    
+    void ConstructBuffers();
+    
     // Reader *m_reader;
     Stage& m_stage;
     boost::uint32_t m_threshold;
diff -r f99d29deba24 -r 0755b16501fb include/libpc/ChipperIterator.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/ChipperIterator.hpp	Thu Mar 24 12:39:53 2011 -0500
@@ -0,0 +1,64 @@
+/******************************************************************************
+* 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_CHIPPERITERATOR_HPP
+#define INCLUDED_CHIPPERITERATOR_HPP
+
+#include <libpc/Filter.hpp>
+#include <libpc/FilterIterator.hpp>
+
+namespace libpc {
+
+class chipper::Chipper;
+    
+namespace filters {
+
+
+class ChipperSequentialIterator : public libpc::FilterSequentialIterator
+{
+public:
+    ChipperSequentialIterator(const chipper::Chipper& chipper);
+
+private:
+    boost::uint64_t skipImpl(boost::uint64_t);
+    boost::uint32_t readImpl(PointBuffer&);
+    bool atEndImpl() const;
+
+    const chipper::Chipper& m_chipper;
+};
+
+
+} } // namespaces
+
+#endif
diff -r f99d29deba24 -r 0755b16501fb include/libpc/drivers/liblas/Iterator.hpp
--- a/include/libpc/drivers/liblas/Iterator.hpp	Thu Mar 24 09:12:53 2011 -0700
+++ b/include/libpc/drivers/liblas/Iterator.hpp	Thu Mar 24 12:39:53 2011 -0500
@@ -53,34 +53,53 @@
 class LiblasReader;
 
 
-class SequentialIterator : public libpc::SequentialIterator
+class LiblasIteratorBase
+{
+public:
+    LiblasIteratorBase(const LiblasReader& reader);
+    ~LiblasIteratorBase();
+
+protected:
+    ::liblas::Reader& getExternalReader() const;
+    const LiblasReader& getReader() const;
+    
+    boost::uint32_t readBuffer(PointBuffer& data);
+
+private:
+    const LiblasReader& m_reader;
+    std::string m_filename;
+    std::istream* m_istream;
+    ::liblas::Reader* m_externalReader;
+    
+    LiblasIteratorBase& operator=(const LiblasIteratorBase&); // not implemented
+    LiblasIteratorBase(const LiblasIteratorBase&); // not implemented};
+};
+
+
+class SequentialIterator : public LiblasIteratorBase, public libpc::SequentialIterator
 {
 public:
     SequentialIterator(const LiblasReader& reader);
     ~SequentialIterator();
 
 private:
-    boost::uint64_t skipImpl(boost::uint64_t);
-    boost::uint32_t readImpl(PointBuffer&);
+    boost::uint64_t skipImpl(boost::uint64_t count);
+    boost::uint32_t readImpl(PointBuffer& data);
     bool atEndImpl() const;
-
-    const LiblasReader& m_reader;
-    std::istream* m_istream;
 };
 
-class RandomIterator : public libpc::RandomIterator
+
+class RandomIterator : public LiblasIteratorBase, public libpc::RandomIterator
 {
 public:
     RandomIterator(const LiblasReader& reader);
     ~RandomIterator();
 
 private:
-    boost::uint64_t seekImpl(boost::uint64_t);
-    boost::uint32_t readImpl(PointBuffer&);
+    boost::uint64_t seekImpl(boost::uint64_t pos);
+    boost::uint32_t readImpl(PointBuffer& data);
+};
 
-    const LiblasReader& m_reader;
-    std::istream* m_istream;
-};
 
 } } } // namespaces
 
diff -r f99d29deba24 -r 0755b16501fb include/libpc/drivers/liblas/Reader.hpp
--- a/include/libpc/drivers/liblas/Reader.hpp	Thu Mar 24 09:12:53 2011 -0700
+++ b/include/libpc/drivers/liblas/Reader.hpp	Thu Mar 24 12:39:53 2011 -0500
@@ -50,14 +50,9 @@
 
 namespace libpc { namespace drivers { namespace liblas {
 
-class SequentialIterator;
-class RandomIterator;
 
 class LIBPC_DLL LiblasReader : public Stage
 {
-    friend class SequentialIterator;
-    friend class RandomIterator;
-
 public:
     LiblasReader(const std::string& filename);
     ~LiblasReader();
@@ -69,6 +64,10 @@
     const LiblasHeader& getLiblasHeader() const;
 
     boost::int8_t getPointFormatNumber() const;
+    
+    bool hasTimeData() const;
+    bool hasColorData() const;
+    bool hasWaveData() const;
 
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return true; }
@@ -78,13 +77,10 @@
 private:
     LiblasHeader& getLiblasHeader();
     void setLiblasHeader(const LiblasHeader&);
-    void processExternalHeader();
-    void registerFields();
+    void processExternalHeader(::liblas::Reader& externalReader);
+    void registerFields(::liblas::Reader& externalReader);
 
     std::string m_filename;
-    std::istream* m_istream;
-
-    ::liblas::Reader *m_externalReader;
 
     // LAS header properties of interest to us
     boost::uint8_t m_versionMajor;
diff -r f99d29deba24 -r 0755b16501fb src/CMakeLists.txt
--- a/src/CMakeLists.txt	Thu Mar 24 09:12:53 2011 -0700
+++ b/src/CMakeLists.txt	Thu Mar 24 12:39:53 2011 -0500
@@ -39,6 +39,8 @@
   ${LIBPC_HEADERS_DIR}/types.hpp
   ${LIBPC_HEADERS_DIR}/Bounds.hpp
   ${LIBPC_HEADERS_DIR}/Color.hpp
+  ${LIBPC_HEADERS_DIR}/Chipper.hpp
+  ${LIBPC_HEADERS_DIR}/ChipperIterator.hpp
   ${LIBPC_HEADERS_DIR}/Dimension.hpp
   ${LIBPC_HEADERS_DIR}/DimensionLayout.hpp
   ${LIBPC_HEADERS_DIR}/Filter.hpp
@@ -62,6 +64,7 @@
 set(LIBPC_BASE_CPP
   Bounds.cpp
   Chipper.cpp
+  ChipperIterator.cpp
   Color.cpp
   Dimension.cpp
   DimensionLayout.cpp
diff -r f99d29deba24 -r 0755b16501fb src/Chipper.cpp
--- a/src/Chipper.cpp	Thu Mar 24 09:12:53 2011 -0700
+++ b/src/Chipper.cpp	Thu Mar 24 12:39:53 2011 -0500
@@ -40,6 +40,8 @@
 
 #include <libpc/chipper.hpp>
 #include <libpc/Utils.hpp>
+#include <libpc/ChipperIterator.hpp>
+#include <libpc/exceptions.hpp>
 // boost
 #include <boost/cstdint.hpp>
 // std
@@ -88,6 +90,46 @@
     return ids;
 }
 
+PointBuffer Block::GetBuffer( Stage& stage) const
+{
+
+    libpc::Header const& header = stage.getHeader();
+    libpc::Schema const& schema = header.getSchema();
+        
+    boost::int32_t size = m_right - m_left + 1;
+    if (size < 0)
+        throw libpc_error("m_right - m_left + 1 was less than 0 in Block::GetBuffer()!");
+        
+    PointBuffer buffer(schema, size);
+
+    if (!stage.supportsRandomIterator())
+        throw libpc_error("Chipper GetBuffer is unable to read data source randomly!");
+            
+    boost::scoped_ptr<RandomIterator> iter(stage.createRandomIterator());
+


More information about the Liblas-commits mailing list