[Liblas-commits] hg-main-tree: add scaffolding for ByteSwapFilter
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed May 25 14:40:32 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/f0ecde445a89
changeset: 737:f0ecde445a89
user: Howard Butler <hobu.inc at gmail.com>
date: Wed May 25 13:40:26 2011 -0500
description:
add scaffolding for ByteSwapFilter
diffstat:
include/libpc/filters/ByteSwapFilter.hpp | 88 +++++++++++++++++
include/libpc/filters/ByteSwapFilterIterator.hpp | 62 ++++++++++++
src/CMakeLists.txt | 4 +
src/filters/ByteSwapFilter.cpp | 116 +++++++++++++++++++++++
src/filters/ByteSwapFilterIterator.cpp | 101 ++++++++++++++++++++
test/unit/ByteSwapFilterTest.cpp | 92 ++++++++++++++++++
test/unit/CMakeLists.txt | 1 +
7 files changed, 464 insertions(+), 0 deletions(-)
diffs (truncated from 511 to 300 lines):
diff -r f76e3f575913 -r f0ecde445a89 include/libpc/filters/ByteSwapFilter.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/filters/ByteSwapFilter.hpp Wed May 25 13:40:26 2011 -0500
@@ -0,0 +1,88 @@
+/******************************************************************************
+* Copyright (c) 2011, Howard Butler <hobu.inc at gmail.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_FILTERS_CROPFILTER_HPP
+#define INCLUDED_FILTERS_CROPFILTER_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <libpc/Filter.hpp>
+#include <libpc/FilterIterator.hpp>
+#include <libpc/Bounds.hpp>
+
+namespace libpc
+{
+ class PointBuffer;
+}
+
+namespace libpc { namespace filters {
+
+class ByteSwapFilterSequentialIterator;
+
+// removes any points outside of the given range
+// updates the header accordingly
+class LIBPC_DLL ByteSwapFilter : public Filter
+{
+public:
+ ByteSwapFilter(const Stage& prevStage);
+
+ const std::string& getDescription() const;
+ const std::string& getName() const;
+
+ bool supportsIterator (StageIteratorType t) const
+ {
+ if (t == StageIterator_Sequential ) return true;
+
+ return false;
+ }
+
+ libpc::SequentialIterator* createSequentialIterator() const;
+ libpc::RandomIterator* createRandomIterator() const { return NULL; }
+
+ // returns number of points accepted into the data buffer (which may be less than data.getNumPoints(),
+ // if we're calling this routine multiple times with the same buffer
+ boost::uint32_t processBuffer(PointBuffer& dstData, const PointBuffer& srcData) const;
+
+
+private:
+
+
+ ByteSwapFilter& operator=(const ByteSwapFilter&); // not implemented
+ ByteSwapFilter(const ByteSwapFilter&); // not implemented
+};
+
+
+} } // namespaces
+
+#endif
diff -r f76e3f575913 -r f0ecde445a89 include/libpc/filters/ByteSwapFilterIterator.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/filters/ByteSwapFilterIterator.hpp Wed May 25 13:40:26 2011 -0500
@@ -0,0 +1,62 @@
+/******************************************************************************
+* Copyright (c) 2011, Howard Butler <hobu.inc at gmail.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_FILTERS_CROPFILTERITERATOR_HPP
+#define INCLUDED_FILTERS_CROPFILTERITERATOR_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <libpc/FilterIterator.hpp>
+
+namespace libpc { namespace filters {
+
+class ByteSwapFilter;
+
+class ByteSwapFilterSequentialIterator : public libpc::FilterSequentialIterator
+{
+public:
+ ByteSwapFilterSequentialIterator(const ByteSwapFilter& filter);
+
+private:
+ boost::uint64_t skipImpl(boost::uint64_t);
+ boost::uint32_t readImpl(PointBuffer&);
+ bool atEndImpl() const;
+
+ const ByteSwapFilter& m_swapFilter;
+};
+
+
+} } // namespaces
+
+#endif
diff -r f76e3f575913 -r f0ecde445a89 src/CMakeLists.txt
--- a/src/CMakeLists.txt Wed May 25 13:30:18 2011 -0500
+++ b/src/CMakeLists.txt Wed May 25 13:40:26 2011 -0500
@@ -275,6 +275,8 @@
#
set(LIBPC_FILTERS_HPP
+ ${LIBPC_HEADERS_DIR}/filters/ByteSwapFilter.hpp
+ ${LIBPC_HEADERS_DIR}/filters/ByteSwapFilterIterator.hpp
${LIBPC_HEADERS_DIR}/filters/CacheFilter.hpp
${LIBPC_HEADERS_DIR}/filters/CacheFilterIterator.hpp
${LIBPC_HEADERS_DIR}/filters/Chipper.hpp
@@ -294,6 +296,8 @@
)
set (LIBPC_FILTERS_CPP
+ ./filters/ByteSwapFilter.cpp
+ ./filters/ByteSwapFilterIterator.cpp
./filters/CacheFilter.cpp
./filters/CacheFilterIterator.cpp
./filters/Chipper.cpp
diff -r f76e3f575913 -r f0ecde445a89 src/filters/ByteSwapFilter.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/filters/ByteSwapFilter.cpp Wed May 25 13:40:26 2011 -0500
@@ -0,0 +1,116 @@
+/******************************************************************************
+* Copyright (c) 2011, Howard Butler <hobu.inc at gmail.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/filters/ByteSwapFilter.hpp>
+
+#include <libpc/filters/ByteSwapFilterIterator.hpp>
+#include <libpc/Schema.hpp>
+#include <libpc/PointBuffer.hpp>
+
+namespace libpc { namespace filters {
+
+
+ByteSwapFilter::ByteSwapFilter(const Stage& prevStage)
+ : Filter(prevStage)
+{
+
+ this->setNumPoints(0);
+ this->setPointCountType(PointCount_Unknown);
+
+ return;
+}
+
+
+const std::string& ByteSwapFilter::getDescription() const
+{
+ static std::string name("Crop Filter");
+ return name;
+}
+
+const std::string& ByteSwapFilter::getName() const
+{
+ static std::string name("filters.byteswap");
+ return name;
+}
+
+
+
+
+// append all points from src buffer to end of dst buffer, based on the our bounds
+boost::uint32_t ByteSwapFilter::processBuffer(PointBuffer& dstData, const PointBuffer& srcData) const
+{
+ // const SchemaLayout& schemaLayout = dstData.getSchemaLayout();
+ // const Schema& schema = schemaLayout.getSchema();
+ //
+ // int fieldX = schema.getDimensionIndex(Dimension::Field_X, Dimension::Double);
+ // int fieldY = schema.getDimensionIndex(Dimension::Field_Y, Dimension::Double);
+ // int fieldZ = schema.getDimensionIndex(Dimension::Field_Z, Dimension::Double);
+ //
+ // const Bounds<double>& bounds = this->getBounds();
+ //
+ // boost::uint32_t numSrcPoints = srcData.getNumPoints();
+ // boost::uint32_t dstIndex = dstData.getNumPoints();
+ //
+ // boost::uint32_t numPointsAdded = 0;
+ //
+ // for (boost::uint32_t srcIndex=0; srcIndex<numSrcPoints; srcIndex++)
+ // {
+ //
+ // double x = srcData.getField<double>(srcIndex, fieldX);
+ // double y = srcData.getField<double>(srcIndex, fieldY);
+ // double z = srcData.getField<double>(srcIndex, fieldZ);
+ // Vector<double> point(x,y,z);
+ //
+ // if (bounds.contains(point))
+ // {
+ // dstData.copyPointFast(dstIndex, srcIndex, srcData);
+ // dstData.setNumPoints(dstIndex+1);
+ // ++dstIndex;
+ // ++numPointsAdded;
+ // }
+ // }
+ //
+ // assert(dstIndex <= dstData.getCapacity());
+
+ return 0;
+}
+
+
+libpc::SequentialIterator* ByteSwapFilter::createSequentialIterator() const
+{
+ return new ByteSwapFilterSequentialIterator(*this);
+}
+
+
+} } // namespaces
diff -r f76e3f575913 -r f0ecde445a89 src/filters/ByteSwapFilterIterator.cpp
More information about the Liblas-commits
mailing list