[Liblas-commits] hg-main-tree: memoize fetching the indexID and blockID for the b...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Jul 27 10:06:44 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/d364ec8b549c
changeset: 953:d364ec8b549c
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Jul 27 09:06:40 2011 -0500
description:
memoize fetching the indexID and blockID for the block so we don't have to do this for every point for a good speed win

diffstat:

 include/pdal/filters/Chipper.hpp |  2 +-
 src/filters/Chipper.cpp          |  6 +++---
 src/filters/ChipperIterator.cpp  |  6 +++++-
 test/unit/ChipperTest.cpp        |  4 +++-
 4 files changed, 12 insertions(+), 6 deletions(-)

diffs (65 lines):

diff -r ae34a3faf6e7 -r d364ec8b549c include/pdal/filters/Chipper.hpp
--- a/include/pdal/filters/Chipper.hpp	Wed Jul 27 08:36:22 2011 -0500
+++ b/include/pdal/filters/Chipper.hpp	Wed Jul 27 09:06:40 2011 -0500
@@ -136,7 +136,7 @@
     std::vector<boost::uint32_t> GetIDs() const; 
     pdal::Bounds<double> const& GetBounds() const {return m_bounds;} 
     void SetBounds(pdal::Bounds<double> const& bounds) {m_bounds = bounds;}
-    void GetBuffer( Stage const& stage, PointBuffer& buffer, boost::uint32_t block_id) const;    
+    void GetBuffer( Stage const& stage, PointBuffer& buffer, boost::uint32_t block_id, boost::int32_t indexId, boost::int32_t indexBlockId) const;    
     // double GetXmin() const
     //     { return m_xmin; }
     // double GetYmin() const
diff -r ae34a3faf6e7 -r d364ec8b549c src/filters/Chipper.cpp
--- a/src/filters/Chipper.cpp	Wed Jul 27 08:36:22 2011 -0500
+++ b/src/filters/Chipper.cpp	Wed Jul 27 09:06:40 2011 -0500
@@ -92,7 +92,7 @@
     return ids;
 }
 
-void Block::GetBuffer( Stage const& stage, PointBuffer& buffer, boost::uint32_t block_id) const
+void Block::GetBuffer( Stage const& stage, PointBuffer& buffer, boost::uint32_t block_id, boost::int32_t indexId, boost::int32_t indexBlockId) const
 {
     pdal::Schema const& schema = buffer.getSchema();
 
@@ -113,8 +113,8 @@
     std::vector<boost::uint32_t>::const_iterator it;
     boost::uint32_t count = 0;
     
-    const int indexId = schema.getDimensionIndex(Dimension::Field_User1, Dimension::Int32);
-    const int indexBlockId = schema.getDimensionIndex(Dimension::Field_User2, Dimension::Int32);
+    // const int indexId = schema.getDimensionIndex(Dimension::Field_User1, Dimension::Int32);
+    // const int indexBlockId = schema.getDimensionIndex(Dimension::Field_User2, Dimension::Int32);
     
     for (it = ids.begin(); it != ids.end(); it++)
     {
diff -r ae34a3faf6e7 -r d364ec8b549c src/filters/ChipperIterator.cpp
--- a/src/filters/ChipperIterator.cpp	Wed Jul 27 08:36:22 2011 -0500
+++ b/src/filters/ChipperIterator.cpp	Wed Jul 27 09:06:40 2011 -0500
@@ -72,7 +72,11 @@
         // FIXME: Expand the buffer?
         throw pdal_error("Buffer not large enough to hold block!");
     }
-    block.GetBuffer(m_chipper.getPrevStage(), buffer, m_currentBlockId);
+    
+    Schema const& schema = buffer.getSchemaLayout().getSchema();
+    const int indexId = schema.getDimensionIndex(Dimension::Field_User1, Dimension::Int32);
+    const int indexBlockId = schema.getDimensionIndex(Dimension::Field_User2, Dimension::Int32);
+    block.GetBuffer(m_chipper.getPrevStage(), buffer, m_currentBlockId, indexId, indexBlockId);
 
     buffer.setSpatialBounds(block.GetBounds());
     m_currentBlockId++;
diff -r ae34a3faf6e7 -r d364ec8b549c test/unit/ChipperTest.cpp
--- a/test/unit/ChipperTest.cpp	Wed Jul 27 08:36:22 2011 -0500
+++ b/test/unit/ChipperTest.cpp	Wed Jul 27 09:06:40 2011 -0500
@@ -83,7 +83,9 @@
         
         pdal::Schema const& schema = reader.getSchema();
         PointBuffer buffer(schema, 15);
-        chipper.GetBlock(20).GetBuffer(reader, buffer, 70);
+        const int indexId = schema.getDimensionIndex(Dimension::Field_User1, Dimension::Int32);
+        const int indexBlockId = schema.getDimensionIndex(Dimension::Field_User2, Dimension::Int32);        
+        chipper.GetBlock(20).GetBuffer(reader, buffer, 70, indexId, indexBlockId);
 
         // 
         // std::cout << buffer.getField<boost::int32_t>(0, 0) << std::endl;


More information about the Liblas-commits mailing list