[Liblas-commits] hg-main-tree: copy data in assigment and copy
constructors
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Mar 18 11:39:47 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/38f4ce88bd0e
changeset: 367:38f4ce88bd0e
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Mar 18 10:39:09 2011 -0500
description:
copy data in assigment and copy constructors
Subject: hg-main-tree: make getData public
details: http://hg.libpc.orghg-main-tree/rev/6d29326508f2
changeset: 368:6d29326508f2
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Mar 18 10:39:26 2011 -0500
description:
make getData public
Subject: hg-main-tree: fix ups to carry along raw point data with PtRef's
details: http://hg.libpc.orghg-main-tree/rev/d1d3936fca57
changeset: 369:d1d3936fca57
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Mar 18 10:39:39 2011 -0500
description:
fix ups to carry along raw point data with PtRef's
diffstat:
include/libpc/Chipper.hpp | 36 ++++++++++++++++++++++++++++++++++++
include/libpc/PointData.hpp | 3 ++-
src/Chipper.cpp | 12 +++++++++++-
src/PointData.cpp | 11 ++++++++---
4 files changed, 57 insertions(+), 5 deletions(-)
diffs (135 lines):
diff -r 2e564fcd8c21 -r d1d3936fca57 include/libpc/Chipper.hpp
--- a/include/libpc/Chipper.hpp Fri Mar 18 09:07:37 2011 -0500
+++ b/include/libpc/Chipper.hpp Fri Mar 18 10:39:39 2011 -0500
@@ -27,13 +27,49 @@
class LIBPC_DLL PtRef
{
+
public:
+ PtRef() :m_data(0) {};
+
+ // PtRef(PointData const& data) : m_data(0), m_pointSize(data.getSchemaLayout().getByteSize()) {};
double m_pos;
boost::uint32_t m_ptindex;
boost::uint32_t m_oindex;
+ boost::uint8_t* m_data;
+ boost::uint32_t m_pointSize;
bool operator < (const PtRef& pt) const
{ return m_pos < pt.m_pos; }
+
+ PtRef(const PtRef& other) :
+ m_pos(other.m_pos),
+ m_ptindex(other.m_ptindex),
+ m_oindex(other.m_oindex),
+ m_data(other.m_data)
+ {
+ if (other.m_data)
+ {
+ m_data = new boost::uint8_t[m_pointSize * 1];
+ memcpy(m_data, other.m_data, m_pointSize*1);
+ }
+ }
+
+ PtRef& operator=(const PtRef& rhs)
+ {
+ if (&rhs != this)
+ {
+ m_pos = rhs.m_pos;
+ m_ptindex = rhs.m_ptindex;
+ m_oindex = rhs.m_oindex;
+ if (rhs.m_data)
+ {
+ m_data = new boost::uint8_t [m_pointSize * 1];
+ memcpy(m_data, rhs.m_data, m_pointSize*1);
+ }
+ }
+ return *this;
+ }
+ // ~PtRef() { if (m_data) delete m_data; }
};
struct LIBPC_DLL RefList
diff -r 2e564fcd8c21 -r d1d3936fca57 include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp Fri Mar 18 09:07:37 2011 -0500
+++ b/include/libpc/PointData.hpp Fri Mar 18 10:39:39 2011 -0500
@@ -108,10 +108,11 @@
// same as above, but copies N points
void copyPointsFast(std::size_t destPointIndex, std::size_t srcPointIndex, const PointData& srcPointData, std::size_t numPoints);
-private:
// access to the raw memory
boost::uint8_t* getData(std::size_t pointIndex) const;
+private:
+
SchemaLayout m_schemaLayout;
boost::uint8_t* m_data;
std::size_t m_pointSize;
diff -r 2e564fcd8c21 -r d1d3936fca57 src/Chipper.cpp
--- a/src/Chipper.cpp Fri Mar 18 09:07:37 2011 -0500
+++ b/src/Chipper.cpp Fri Mar 18 10:39:39 2011 -0500
@@ -114,12 +114,16 @@
void Chipper::Load(RefList& xvec, RefList& yvec, RefList& spare )
{
- PtRef ref;
+
boost::uint32_t idx;
vector<PtRef>::iterator it;
libpc::Header const& header = m_stage.getHeader();
libpc::Schema const& schema = header.getSchema();
+ libpc::SchemaLayout const& layout = SchemaLayout(schema);
+
+ PtRef ref;
+ ref.m_pointSize = layout.getByteSize();
boost::uint64_t count = header.getNumPoints();
xvec.reserve(count);
@@ -160,6 +164,12 @@
for (boost::uint32_t j = 0; j < m_threshold; j++)
{
+ // PointData data(schema, 1);
+ // data.copyPointFast(j, 0, buffer);
+ boost::uint8_t* raw_data = new boost::uint8_t[ref.m_pointSize*1];
+ boost::uint8_t* src_data = buffer.getData(j);
+ memcpy(raw_data, src_data, ref.m_pointSize*1);
+
if (j == num_to_read) break; // we're outta here
// (v * m_header->GetScaleX()) + m_header->GetOffsetX();
const double x = (buffer.getField<boost::int32_t>(j, indexX) * xscale) + xoffset;
diff -r 2e564fcd8c21 -r d1d3936fca57 src/PointData.cpp
--- a/src/PointData.cpp Fri Mar 18 09:07:37 2011 -0500
+++ b/src/PointData.cpp Fri Mar 18 10:39:39 2011 -0500
@@ -65,9 +65,11 @@
, m_capacity(other.m_capacity)
, m_bounds(other.m_bounds)
{
- m_data = new boost::uint8_t[m_pointSize * m_capacity];
-
- memcpy(m_data, other.m_data, m_pointSize*m_capacity);
+ if (other.m_data)
+ {
+ m_data = new boost::uint8_t[m_pointSize * m_capacity];
+ memcpy(m_data, other.m_data, m_pointSize*m_capacity);
+ }
}
@@ -77,10 +79,13 @@
{
m_schemaLayout = rhs.getSchemaLayout();
m_data = new boost::uint8_t[m_schemaLayout.getByteSize() * rhs.getCapacity()];
+ memcpy(m_data, rhs.m_data, m_pointSize*m_capacity);
+
m_pointSize = m_schemaLayout.getByteSize();
m_numPoints = rhs.getNumPoints();
m_capacity = rhs.getCapacity();
m_bounds = rhs.getSpatialBounds();
+
}
return *this;
}
More information about the Liblas-commits
mailing list