[Liblas-commits] hg-main-tree: PointData now == PointBuffer
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Mar 22 13:05:07 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/ffb2b588a7cf
changeset: 386:ffb2b588a7cf
user: Howard Butler <hobu.inc at gmail.com>
date: Tue Mar 22 12:04:59 2011 -0500
description:
PointData now == PointBuffer
diffstat:
include/libpc/Chipper.hpp | 6 +-
include/libpc/Iterator.hpp | 8 +-
include/libpc/PointBuffer.hpp | 154 ++++++++++++++
include/libpc/PointBufferCache.hpp | 199 ++++++++++++++++++
include/libpc/PointData.hpp | 154 --------------
include/libpc/PointDataCache.hpp | 199 ------------------
include/libpc/Stage.hpp | 2 +-
include/libpc/Writer.hpp | 4 +-
include/libpc/drivers/faux/Iterator.hpp | 2 +-
include/libpc/drivers/faux/Writer.hpp | 2 +-
include/libpc/drivers/las/Iterator.hpp | 2 +-
include/libpc/drivers/las/Writer.hpp | 2 +-
include/libpc/drivers/liblas/Iterator.hpp | 2 +-
include/libpc/drivers/liblas/Writer.hpp | 2 +-
include/libpc/drivers/mrsid/Reader.hpp | 2 +-
include/libpc/drivers/oci/Common.hpp | 1 +
include/libpc/drivers/oci/Writer.hpp | 6 +-
include/libpc/filters/CacheFilter.hpp | 4 +-
include/libpc/filters/CacheFilterIterator.hpp | 4 +-
include/libpc/filters/ColorFilterIterator.hpp | 2 +-
include/libpc/filters/CropFilterIterator.hpp | 2 +-
include/libpc/filters/DecimationFilterIterator.hpp | 2 +-
include/libpc/filters/MosaicFilterIterator.hpp | 2 +-
src/CMakeLists.txt | 8 +-
src/Chipper.cpp | 8 +-
src/Iterator.cpp | 2 +-
src/PointBuffer.cpp | 225 +++++++++++++++++++++
src/PointBufferCache.cpp | 16 +
src/PointData.cpp | 225 ---------------------
src/PointDataCache.cpp | 16 -
src/Writer.cpp | 2 +-
src/drivers/faux/Iterator.cpp | 2 +-
src/drivers/faux/Writer.cpp | 12 +-
src/drivers/las/Iterator.cpp | 68 +++---
src/drivers/las/Writer.cpp | 62 ++--
src/drivers/liblas/Iterator.cpp | 40 +-
src/drivers/liblas/Writer.cpp | 38 +-
src/drivers/mrsid/Reader.cpp | 2 +-
src/drivers/oci/Reader.cpp | 4 +-
src/drivers/oci/Writer.cpp | 50 ++--
src/filters/CacheFilter.cpp | 4 +-
src/filters/CacheFilterIterator.cpp | 8 +-
src/filters/ColorFilterIterator.cpp | 2 +-
src/filters/CropFilterIterator.cpp | 6 +-
src/filters/DecimationFilterIterator.cpp | 4 +-
src/filters/MosaicFilterIterator.cpp | 4 +-
test/unit/CacheFilterTest.cpp | 4 +-
test/unit/DecimationFilterTest.cpp | 2 +-
test/unit/FauxReaderTest.cpp | 4 +-
test/unit/LiblasReaderTest.cpp | 4 +-
test/unit/MosaicFilterTest.cpp | 2 +-
test/unit/PointDataCacheTest.cpp | 20 +-
test/unit/PointDataTest.cpp | 26 +-
53 files changed, 817 insertions(+), 816 deletions(-)
diffs (truncated from 2541 to 300 lines):
diff -r 05f72f01754c -r ffb2b588a7cf include/libpc/Chipper.hpp
--- a/include/libpc/Chipper.hpp Tue Mar 22 11:39:21 2011 -0500
+++ b/include/libpc/Chipper.hpp Tue Mar 22 12:04:59 2011 -0500
@@ -1,7 +1,7 @@
#ifndef LIBLAS_CHIPPER_H
#define LIBLAS_CHIPPER_H
-#include <libpc/PointData.hpp>
+#include <libpc/PointBuffer.hpp>
#include <libpc/Bounds.hpp>
#include <libpc/export.hpp>
#include <libpc/Dimension.hpp>
@@ -31,7 +31,7 @@
public:
PtRef() :m_data(0) {};
- // PtRef(PointData const& data) : m_data(0), m_pointSize(data.getSchemaLayout().getByteSize()) {};
+ // PtRef(PointBuffer const& data) : m_data(0), m_pointSize(data.getSchemaLayout().getByteSize()) {};
double m_pos;
boost::uint32_t m_ptindex;
boost::uint32_t m_oindex;
@@ -107,7 +107,7 @@
class LIBPC_DLL Chipper;
-class LIBPC_DLL Block : libpc::PointData
+class LIBPC_DLL Block : libpc::PointBuffer
{
friend class Chipper;
diff -r 05f72f01754c -r ffb2b588a7cf include/libpc/Iterator.hpp
--- a/include/libpc/Iterator.hpp Tue Mar 22 11:39:21 2011 -0500
+++ b/include/libpc/Iterator.hpp Tue Mar 22 12:04:59 2011 -0500
@@ -40,7 +40,7 @@
namespace libpc
{
class Stage;
-class PointData;
+class PointBuffer;
class LIBPC_DLL Iterator
{
@@ -51,7 +51,7 @@
// This reads a set of points at the current position in the file.
//
- // The schema of the PointData buffer we are given here might
+ // The schema of the PointBuffer buffer we are given here might
// not match our own header's schema. That's okay, though: all
// that matters is that the buffer we are given has the fields
// we need to write into.
@@ -60,7 +60,7 @@
// readBuffer function below, not this one.
//
// Returns the number of valid points read.
- boost::uint32_t read(PointData&);
+ boost::uint32_t read(PointBuffer&);
// advance (or retreat) to the Nth point in the file (absolute,
// not relative). In some cases, this might be a very slow, painful
@@ -78,7 +78,7 @@
boost::uint64_t getCurrentPointIndex() const;
// Implement this to do the actual work to fill in a buffer of points.
- virtual boost::uint32_t readBuffer(PointData&) = 0;
+ virtual boost::uint32_t readBuffer(PointBuffer&) = 0;
// Each concrete stage is repsonsible for managing its own current
// point index when a read or seek occurs. Call this function t o set
diff -r 05f72f01754c -r ffb2b588a7cf include/libpc/PointBuffer.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/PointBuffer.hpp Tue Mar 22 12:04:59 2011 -0500
@@ -0,0 +1,154 @@
+/******************************************************************************
+* 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_PointBuffer_HPP
+#define INCLUDED_PointBuffer_HPP
+
+#include <boost/cstdint.hpp>
+#include <boost/scoped_array.hpp>
+
+#include <libpc/export.hpp>
+#include <libpc/Bounds.hpp>
+#include <libpc/SchemaLayout.hpp>
+
+namespace libpc
+{
+
+// a PointBuffer object is just an untyped array of N bytes,
+// where N is (the size of the given Schema * the number of points)
+//
+// That is, a PointBuffer represents the underlying data for one or more points.
+//
+// A PointBuffer object has an associated Schema object.
+//
+// Many of the methods take a first parameter "index", to specify which point in the
+// collection is to be operated upon. The point index is a uint32; you can't read
+// more than 4 billion points at a time.
+class LIBPC_DLL PointBuffer
+
+{
+
+public:
+
+ // note that when we make a PointBuffer object all the fields are initialized to inactive,
+ // regardless of what the passed-in schema says -- this is because the field object
+ // represents the state within the owning object, which in this case is a completely
+ // empty buffer (similarly, all the points in the buffer are marked "invalid")
+ PointBuffer(const SchemaLayout&, boost::uint32_t capacity);
+ PointBuffer(const PointBuffer&);
+ PointBuffer& operator=(const PointBuffer&);
+
+ ~PointBuffer();
+
+ const Bounds<double>& getSpatialBounds() const;
+ void setSpatialBounds(const Bounds<double>& bounds);
+
+ // number of points in this buffer
+ boost::uint32_t getNumPoints() const;
+
+ inline void setNumPoints(boost::uint32_t v) { assert(v <= m_capacity);m_numPoints = v; }
+
+ inline boost::uint32_t& getNumPointsRef() {assert(m_numPoints <= m_capacity);return m_numPoints; }
+
+ // number of points in this buffer that have legit data; initially will be zero,
+ // and after a read() call it will be in the range 0 to getNumPoints()-1
+ inline boost::uint32_t getCapacity() const { return m_capacity; }
+
+ // schema (number and kinds of fields) for a point in this buffer
+ const SchemaLayout& getSchemaLayout() const
+ {
+ return m_schemaLayout;
+ }
+
+ // convenience function
+ const Schema& getSchema() const
+ {
+ 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);
+
+ // bulk copy all the fields from the given point into this object
+ // NOTE: this is only legal if the src and dest schemas are exactly the same
+ // (later, this will be implemented properly, to handle the general cases slowly and the best case quickly)
+ void copyPointFast(std::size_t destPointIndex, std::size_t srcPointIndex, const PointBuffer& srcPointBuffer);
+
+ // same as above, but copies N points
+ void copyPointsFast(std::size_t destPointIndex, std::size_t srcPointIndex, const PointBuffer& srcPointBuffer, std::size_t numPoints);
+
+ // access to the raw memory
+ boost::uint8_t* getData(std::size_t pointIndex) const;
+
+private:
+
+ SchemaLayout m_schemaLayout;
+ boost::scoped_array<boost::uint8_t> m_data;
+ std::size_t m_pointSize;
+ boost::uint32_t m_numPoints;
+ boost::uint32_t m_capacity;
+ Bounds<double> m_bounds;
+
+};
+
+
+template <class T>
+inline void PointBuffer::setField(std::size_t pointIndex, std::size_t fieldIndex, T value)
+{
+ std::size_t offset = (pointIndex * m_pointSize) + m_schemaLayout.getDimensionLayout(fieldIndex).getByteOffset();
+ assert(offset + sizeof(T) <= m_pointSize * m_capacity);
+ boost::uint8_t* p = m_data.get() + offset;
+
+ *(T*)p = value;
+}
+
+
+template <class T>
+inline T PointBuffer::getField(std::size_t pointIndex, std::size_t fieldIndex) const
+{
+ std::size_t offset = (pointIndex * m_pointSize) + m_schemaLayout.getDimensionLayout(fieldIndex).getByteOffset();
+ assert(offset + sizeof(T) <= m_pointSize * m_capacity);
+ boost::uint8_t* p = m_data.get() + offset;
+
+ return *(T*)p;
+}
+
+
+LIBPC_DLL std::ostream& operator<<(std::ostream& ostr, const PointBuffer&);
+
+
+} // namespace libpc
+
+#endif
diff -r 05f72f01754c -r ffb2b588a7cf include/libpc/PointBufferCache.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/PointBufferCache.hpp Tue Mar 22 12:04:59 2011 -0500
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2010, Tim Day <timday at timday.com>
+ * Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+// This PointBuffer-specific code derived from the templated code at
+// http://www.bottlenose.demon.co.uk/article/lru.htm. It is under an
+// Internet Systems Consortium (ISC) license (an OSI-approved BSD-alike license).
+
+#ifndef INCLUDED_LIBPC_PointBufferCACHE_HPP
+#define INCLUDED_LIBPC_PointBufferCACHE_HPP
+
+
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable: 4512) // assignment operator could not be generated
+#endif
+#include <boost/bimap.hpp>
+#include <boost/bimap/list_of.hpp>
+#include <boost/bimap/set_of.hpp>
+#include <boost/function.hpp>
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+#include <libpc/PointBuffer.hpp>
+
+
+namespace libpc
+{
+
+
+class PointBufferCache
+{
+public:
+
+ typedef int dummy_type;
+
+ // Bimap with key access on left view, key access
+ // history on right view, and associated value.
+ typedef boost::bimaps::bimap<
+ boost::bimaps::set_of<boost::uint64_t>,
+ boost::bimaps::list_of<dummy_type>,
+ boost::bimaps::with_info<PointBuffer*>
+ > cache_type;
+
+ // Constuctor specifies the cached function and
+ // the maximum number of records to be stored.
+ PointBufferCache(size_t c)
+ :_capacity(c)
+ , m_numCacheLookupMisses(0)
+ , m_numCacheLookupHits(0)
+ , m_numCacheInsertMisses(0)
+ , m_numCacheInsertHits(0)
+ {
+ assert(_capacity!=0);
+ }
More information about the Liblas-commits
mailing list