[Liblas-commits] hg-main-tree: keep track of point count vs
capacity in CropFilter
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Mar 17 10:57:08 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/e1cde8c81061
changeset: 319:e1cde8c81061
user: Howard Butler <hobu.inc at gmail.com>
date: Thu Mar 17 09:57:00 2011 -0500
description:
keep track of point count vs capacity in CropFilter
diffstat:
src/filters/CropFilter.cpp | 50 +++++++++++++++++++++++++------------------
test/unit/CropFilterTest.cpp | 2 +-
2 files changed, 30 insertions(+), 22 deletions(-)
diffs (80 lines):
diff -r e8eb76ff7d24 -r e1cde8c81061 src/filters/CropFilter.cpp
--- a/src/filters/CropFilter.cpp Thu Mar 17 09:42:09 2011 -0500
+++ b/src/filters/CropFilter.cpp Thu Mar 17 09:57:00 2011 -0500
@@ -63,7 +63,10 @@
boost::uint32_t CropFilter::readBuffer(PointData& data)
{
- boost::uint32_t numPoints = m_prevStage.read(data);
+
+ PointData srcData(data.getSchemaLayout(), data.getCapacity());
+ boost::uint32_t numSrcPointsRead = m_prevStage.read(srcData);
+
const SchemaLayout& schemaLayout = data.getSchemaLayout();
const Schema& schema = schemaLayout.getSchema();
@@ -72,27 +75,32 @@
int fieldY = schema.getDimensionIndex(Dimension::Field_Y);
int fieldZ = schema.getDimensionIndex(Dimension::Field_Z);
- // FIXME: Reconstruct a PointData
- // for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
- // {
- // float x = data.getField<float>(pointIndex, fieldX);
- // float y = data.getField<float>(pointIndex, fieldY);
- // float z = data.getField<float>(pointIndex, fieldZ);
- // Vector<double> point(x,y,z);
- // if (!m_bounds.contains(point))
- // {
- // // remove this point, and update the lower bound for Z
- // data.setValid(pointIndex, false);
- // }
- // else
- // {
- // data.setValid(pointIndex, true);
- // }
- // }
- //
- // incrementCurrentPointIndex(numPoints);
- return numPoints;
+ boost::uint32_t numPoints = data.getCapacity();
+
+ boost::uint32_t srcIndex = 0;
+ boost::uint32_t dstIndex = 0;
+ for (srcIndex=0; srcIndex<numPoints; 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 (m_bounds.contains(point))
+ {
+ data.copyPointFast(dstIndex, srcIndex, srcData);
+ data.setNumPoints(dstIndex+1);
+ dstIndex += 1;
+
+ }
+ }
+
+
+ incrementCurrentPointIndex(numPoints);
+
+ return data.getNumPoints();
}
} } // namespaces
diff -r e8eb76ff7d24 -r e1cde8c81061 test/unit/CropFilterTest.cpp
--- a/test/unit/CropFilterTest.cpp Thu Mar 17 09:42:09 2011 -0500
+++ b/test/unit/CropFilterTest.cpp Thu Mar 17 09:57:00 2011 -0500
@@ -58,7 +58,7 @@
libpc::drivers::faux::Writer writer(filter);
boost::uint64_t numWritten = writer.write(1000);
- std::cout << "numWritten: " << numWritten << std::endl;
+
// 1000 * 1/8 = 125, plus or minus 10%
BOOST_CHECK(Utils::compare_approx<double>(static_cast<double>(numWritten), 125, 12.5));
More information about the Liblas-commits
mailing list