[Liblas-commits] hg-main-tree: it's not worse than it was before --
attempting to...
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Mar 16 16:52:38 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/f744545fbb0d
changeset: 306:f744545fbb0d
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Mar 16 15:52:21 2011 -0500
description:
it's not worse than it was before -- attempting to keep track of count and capacity for PointData
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/e0a263e48f83
changeset: 307:e0a263e48f83
user: Howard Butler <hobu.inc at gmail.com>
date: Wed Mar 16 15:52:29 2011 -0500
description:
merge
diffstat:
doc/sprint/notes.txt | 15 ---------------
include/libpc/PointData.hpp | 10 ++++++----
include/libpc/libpc.hpp | 37 +++++++++++++++++++++++++++++++++++++
src/CMakeLists.txt | 1 +
src/PointData.cpp | 4 ++++
src/drivers/faux/Reader.cpp | 12 ++++++++----
src/filters/CacheFilter.cpp | 2 +-
test/unit/ConfigTest.cpp | 3 +--
test/unit/main.cpp | 2 +-
9 files changed, 59 insertions(+), 27 deletions(-)
diffs (232 lines):
diff -r b77a6c054807 -r e0a263e48f83 doc/sprint/notes.txt
--- a/doc/sprint/notes.txt Wed Mar 16 14:44:04 2011 -0500
+++ b/doc/sprint/notes.txt Wed Mar 16 15:52:29 2011 -0500
@@ -12,20 +12,13 @@
* pcinfo tool - basic support
-* file names to match class names (reader.hpp, etc)
-
* CL mssgs to stdout or stderr? usage/help/error
* platform macros -- LIBPC_OS_WIN32, etc
-* libpc.hpp -- general/universal header file
-
* dump routines -- every class needs oper<<, dump()
* build swig bindings from CMake
-
-* complete the renaming of driver/filters, into subdirs; and fix IDE
- project file also
* typedef boost::uint32_t uint32_t ?
@@ -39,20 +32,12 @@
* the sequential-or-random-reads issue
-* the Stage class hierarchy naming / Writer issue
-
-* remove isValid?
-
* do we need Header class?
* does Boost give math class support for Range, Vector, Bounds?
* bitfields in Dimensions?
-* stand up libpc.org / Sphinx
-
-* Trac instance for libPC
-
* MG4/Lidar driver support, inc. CMake detection
* Text driver
diff -r b77a6c054807 -r e0a263e48f83 include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp Wed Mar 16 14:44:04 2011 -0500
+++ b/include/libpc/PointData.hpp Wed Mar 16 15:52:29 2011 -0500
@@ -69,11 +69,13 @@
// number of points in this buffer
boost::uint32_t getNumPoints() const;
- inline void setNumPoints(boost::uint32_t v) { m_numPoints = v; }
+ 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
- boost::uint32_t getCapacity();
+ inline boost::uint32_t getCapacity() { return m_capacity; }
// schema (number and kinds of fields) for a point in this buffer
const SchemaLayout& getSchemaLayout() const
@@ -119,7 +121,7 @@
inline void PointData::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_numPoints);
+ assert(offset + sizeof(T) <= m_pointSize * m_capacity);
boost::uint8_t* p = m_data + offset;
*(T*)p = value;
@@ -130,7 +132,7 @@
inline T PointData::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_numPoints);
+ assert(offset + sizeof(T) <= m_pointSize * m_capacity);
boost::uint8_t* p = m_data + offset;
return *(T*)p;
diff -r b77a6c054807 -r e0a263e48f83 include/libpc/libpc.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/libpc.hpp Wed Mar 16 15:52:29 2011 -0500
@@ -0,0 +1,37 @@
+/******************************************************************************
+* 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/export.hpp>
+#include <libpc/libpc_defines.h>
+#include <libpc/libpc_config.hpp>
diff -r b77a6c054807 -r e0a263e48f83 src/CMakeLists.txt
--- a/src/CMakeLists.txt Wed Mar 16 14:44:04 2011 -0500
+++ b/src/CMakeLists.txt Wed Mar 16 15:52:29 2011 -0500
@@ -34,6 +34,7 @@
set(LIBPC_BASE_HPP
${LIBPC_HEADERS_DIR}/exceptions.hpp
${LIBPC_HEADERS_DIR}/export.hpp
+ ${LIBPC_HEADERS_DIR}/libpc.hpp
${LIBPC_HEADERS_DIR}/libpc_config.hpp
${LIBPC_HEADERS_DIR}/Bounds.hpp
${LIBPC_HEADERS_DIR}/Color.hpp
diff -r b77a6c054807 -r e0a263e48f83 src/PointData.cpp
--- a/src/PointData.cpp Wed Mar 16 14:44:04 2011 -0500
+++ b/src/PointData.cpp Wed Mar 16 15:52:29 2011 -0500
@@ -86,6 +86,7 @@
memcpy(dest, src, len);
m_numPoints++;
+ assert(m_numPoints <= m_capacity);
return;
}
@@ -101,7 +102,10 @@
memcpy(dest, src, len * numPoints);
+ // FIXME: This needs to be smarter
m_numPoints = m_numPoints + numPoints;
+ assert(m_numPoints <= m_capacity);
+
return;
}
diff -r b77a6c054807 -r e0a263e48f83 src/drivers/faux/Reader.cpp
--- a/src/drivers/faux/Reader.cpp Wed Mar 16 14:44:04 2011 -0500
+++ b/src/drivers/faux/Reader.cpp Wed Mar 16 15:52:29 2011 -0500
@@ -101,7 +101,7 @@
// make up some data and put it into the buffer
- const boost::uint32_t numPoints = data.getNumPoints();
+ const boost::uint32_t numPoints = data.getCapacity();
assert(getCurrentPointIndex() + numPoints <= getHeader().getNumPoints());
const SchemaLayout& schemaLayout = data.getSchemaLayout();
@@ -123,7 +123,9 @@
const int offsetZ = schema.getDimensionIndex(Dimension::Field_Z);
boost::uint64_t time = getCurrentPointIndex();
-
+
+ boost::uint32_t& cnt = data.getNumPointsRef();
+ cnt = 0;
for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
{
double x;
@@ -148,11 +150,13 @@
data.setField<boost::uint64_t>(pointIndex, offsetT, time);
++time;
+ ++cnt;
+ assert(cnt <= data.getCapacity());
}
-
+
incrementCurrentPointIndex(numPoints);
- return numPoints;
+ return cnt;
}
diff -r b77a6c054807 -r e0a263e48f83 src/filters/CacheFilter.cpp
--- a/src/filters/CacheFilter.cpp Wed Mar 16 14:44:04 2011 -0500
+++ b/src/filters/CacheFilter.cpp Wed Mar 16 15:52:29 2011 -0500
@@ -138,7 +138,7 @@
incrementCurrentPointIndex(numRead);
m_numPointsRead += data.getNumPoints();
- m_numPointsRequested += data.getNumPoints();
+ m_numPointsRequested += data.getCapacity();
return numRead;
}
diff -r b77a6c054807 -r e0a263e48f83 test/unit/ConfigTest.cpp
--- a/test/unit/ConfigTest.cpp Wed Mar 16 14:44:04 2011 -0500
+++ b/test/unit/ConfigTest.cpp Wed Mar 16 15:52:29 2011 -0500
@@ -35,8 +35,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/cstdint.hpp>
-#include <libpc/libpc_defines.h>
-#include <libpc/libpc_config.hpp>
+#include <libpc/libpc.hpp>
using namespace libpc;
diff -r b77a6c054807 -r e0a263e48f83 test/unit/main.cpp
--- a/test/unit/main.cpp Wed Mar 16 14:44:04 2011 -0500
+++ b/test/unit/main.cpp Wed Mar 16 15:52:29 2011 -0500
@@ -77,7 +77,7 @@
g_data_path = argv[1];
else
g_data_path = "../test/data";
- if (g_data_path[g_data_path.size()] != '/')
+ if (g_data_path[g_data_path.size()-1] != '/')
g_data_path += "/";
#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
More information about the Liblas-commits
mailing list