[Liblas-commits] hg-main-tree: pipeline reader/stage now working

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Aug 16 12:45:09 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/0b21ca9d76d9
changeset: 1108:0b21ca9d76d9
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Aug 16 09:44:52 2011 -0700
description:
pipeline reader/stage now working

diffstat:

 include/pdal/drivers/pipeline/Iterator.hpp |  79 --------------------------
 include/pdal/drivers/pipeline/Reader.hpp   |  14 +---
 src/CMakeLists.txt                         |   2 -
 src/drivers/pipeline/Iterator.cpp          |  91 ------------------------------
 src/drivers/pipeline/Reader.cpp            |  27 ++++----
 test/unit/PipelineReaderTest.cpp           |  24 +++++++
 6 files changed, 42 insertions(+), 195 deletions(-)

diffs (truncated from 353 to 300 lines):

diff -r 730887bf9816 -r 0b21ca9d76d9 include/pdal/drivers/pipeline/Iterator.hpp
--- a/include/pdal/drivers/pipeline/Iterator.hpp	Mon Aug 15 18:56:50 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/******************************************************************************
-* 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_DRIVERS_PIPELINE_READER_ITERATOR_HPP
-#define INCLUDED_DRIVERS_PIPELINE_READER_ITERATOR_HPP
-
-#include <pdal/pdal.hpp>
-
-#include <pdal/ReaderIterator.hpp>
-
-
-namespace pdal { namespace drivers { namespace pipeline {
-
-
-class Reader;
-
-
-class SequentialIterator : public pdal::ReaderSequentialIterator
-{
-public:
-    SequentialIterator(const Reader& reader);
-
-private:
-    boost::uint64_t skipImpl(boost::uint64_t);
-    boost::uint32_t readBufferImpl(PointBuffer&);
-    bool atEndImpl() const;
-
-    const Reader& m_reader;
-};
-
-
-class RandomIterator : public pdal::ReaderRandomIterator
-{
-public:
-    RandomIterator(const Reader& reader);
-
-private:
-    boost::uint64_t seekImpl(boost::uint64_t);
-    boost::uint32_t readBufferImpl(PointBuffer&);
-
-    const Reader& m_reader;
-};
-
-
-} } } // namespaces
-
-
-#endif
diff -r 730887bf9816 -r 0b21ca9d76d9 include/pdal/drivers/pipeline/Reader.hpp
--- a/include/pdal/drivers/pipeline/Reader.hpp	Mon Aug 15 18:56:50 2011 -0700
+++ b/include/pdal/drivers/pipeline/Reader.hpp	Tue Aug 16 09:44:52 2011 -0700
@@ -39,6 +39,7 @@
 
 #include <pdal/Reader.hpp>
 #include <pdal/PipelineManager.hpp>
+#include <boost/scoped_ptr.hpp>
 
 
 namespace pdal { namespace drivers { namespace pipeline {
@@ -55,14 +56,7 @@
     virtual void initialize();
     virtual const Options getDefaultOptions() const;
     
-    bool supportsIterator (StageIteratorType t) const
-    {   
-        if (t == StageIterator_Sequential ) return true;
-        if (t == StageIterator_Random ) return true;
-        
-        return false;
-    }
-
+    bool supportsIterator (StageIteratorType t) const;
     pdal::StageSequentialIterator* createSequentialIterator() const;
     pdal::StageRandomIterator* createRandomIterator() const;
 
@@ -71,8 +65,8 @@
 
 private:
     std::string m_filename;
-    PipelineManager* m_manager;
-    Stage* m_stage;
+    boost::scoped_ptr<PipelineManager> m_manager;
+    Stage* m_stage; // owned by m_manager
 
     Reader& operator=(const Reader&); // not implemented
     Reader(const Reader&); // not implemented
diff -r 730887bf9816 -r 0b21ca9d76d9 src/CMakeLists.txt
--- a/src/CMakeLists.txt	Mon Aug 15 18:56:50 2011 -0700
+++ b/src/CMakeLists.txt	Tue Aug 16 09:44:52 2011 -0700
@@ -252,12 +252,10 @@
 set(PDAL_PIPELINE_SRC ${PROJECT_SOURCE_DIR}/src/${PDAL_PIPELINE_PATH})
 
 set (PDAL_DRIVERS_PIPELINE_HPP
-  ${PDAL_PIPELINE_HEADERS}/Iterator.hpp
   ${PDAL_PIPELINE_HEADERS}/Reader.hpp
 )
 
 set (PDAL_DRIVERS_PIPELINE_CPP 
-  ${PDAL_PIPELINE_SRC}/Iterator.cpp
   ${PDAL_PIPELINE_SRC}/Reader.cpp
 )
 
diff -r 730887bf9816 -r 0b21ca9d76d9 src/drivers/pipeline/Iterator.cpp
--- a/src/drivers/pipeline/Iterator.cpp	Mon Aug 15 18:56:50 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/******************************************************************************
-* 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 <pdal/drivers/pipeline/Iterator.hpp>
-
-#include <pdal/drivers/pipeline/Reader.hpp>
-
-
-namespace pdal { namespace drivers { namespace pipeline {
-
-SequentialIterator::SequentialIterator(const Reader& reader)
-    : pdal::ReaderSequentialIterator(reader)
-    , m_reader(reader)
-{
-    return;
-}
-
-
-boost::uint64_t SequentialIterator::skipImpl(boost::uint64_t count)
-{
-     return count;
-}
-
-
-bool SequentialIterator::atEndImpl() const
-{
-    const boost::uint64_t numPoints = getStage().getNumPoints();
-    const boost::uint64_t currPoint = getIndex();
-
-    return currPoint >= numPoints;
-}
-
-
-boost::uint32_t SequentialIterator::readBufferImpl(PointBuffer& data)
-{
-    return m_reader.processBuffer(data, getIndex());
-}
-
-
-
-RandomIterator::RandomIterator(const Reader& reader)
-    : pdal::ReaderRandomIterator(reader)
-    , m_reader(reader)
-{
-    return;
-}
-
-
-boost::uint64_t RandomIterator::seekImpl(boost::uint64_t count)
-{
-     return count;
-}
-
-
-boost::uint32_t RandomIterator::readBufferImpl(PointBuffer& data)
-{
-    return m_reader.processBuffer(data, getIndex());
-}
-
-} } } // namespaces
diff -r 730887bf9816 -r 0b21ca9d76d9 src/drivers/pipeline/Reader.cpp
--- a/src/drivers/pipeline/Reader.cpp	Mon Aug 15 18:56:50 2011 -0700
+++ b/src/drivers/pipeline/Reader.cpp	Tue Aug 16 09:44:52 2011 -0700
@@ -34,8 +34,6 @@
 
 #include <pdal/drivers/pipeline/Reader.hpp>
 
-#include <pdal/drivers/pipeline/Iterator.hpp>
-#include <pdal/exceptions.hpp>
 #include <pdal/PipelineReader.hpp>
 
 
@@ -53,7 +51,8 @@
 
 Reader::~Reader()
 {
-    delete m_manager;
+    m_manager.reset();
+    return;
 }
 
 
@@ -61,16 +60,19 @@
 {
     pdal::Reader::initialize();
 
-    m_manager = new PipelineManager;
+    boost::scoped_ptr<PipelineManager> tmp(new PipelineManager());
+    m_manager.swap(tmp);
 
     PipelineReader xmlreader(*m_manager);
     xmlreader.readReaderPipeline(m_filename);
     m_stage = m_manager->getStage();
+    m_stage->initialize();
 
     setNumPoints(m_stage->getNumPoints());
     setPointCountType(m_stage->getPointCountType());
+    setBounds(m_stage->getBounds());
 
-    setBounds(m_stage->getBounds());
+    return;
 }
 
 
@@ -81,23 +83,22 @@
 }
 
 
+bool Reader::supportsIterator (StageIteratorType t) const
+{   
+    return m_stage->supportsIterator(t);
+}
+
 
 pdal::StageSequentialIterator* Reader::createSequentialIterator() const
 {
-    return new SequentialIterator(*this);
+    return m_stage->createSequentialIterator();
 }
 
 
 pdal::StageRandomIterator* Reader::createRandomIterator() const
 {
-    return new RandomIterator(*this);
+    return m_stage->createRandomIterator();
 }
 
 


More information about the Liblas-commits mailing list