[Liblas-commits] hg-main-tree: add default bounds getter

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Mar 17 11:06:41 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/ffcd1e249725
changeset: 320:ffcd1e249725
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 10:20:03 2011 -0400
description:
add default bounds getter
Subject: hg-main-tree: add bounds param to read() calls

details:   http://hg.libpc.orghg-main-tree/rev/08b8eaed67a5
changeset: 321:08b8eaed67a5
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 10:40:49 2011 -0400
description:
add bounds param to read() calls
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/06bfc9a433b7
changeset: 322:06bfc9a433b7
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 10:41:03 2011 -0400
description:
merge
Subject: hg-main-tree: merge (conflicts resolved)

details:   http://hg.libpc.orghg-main-tree/rev/8f80aeb9b9fb
changeset: 323:8f80aeb9b9fb
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 10:52:25 2011 -0400
description:
merge (conflicts resolved)
Subject: hg-main-tree: lint

details:   http://hg.libpc.orghg-main-tree/rev/d7aa69030d7e
changeset: 324:d7aa69030d7e
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 10:52:54 2011 -0400
description:
lint
Subject: hg-main-tree: lint

details:   http://hg.libpc.orghg-main-tree/rev/cb25f8b475a5
changeset: 325:cb25f8b475a5
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 11:03:44 2011 -0400
description:
lint
Subject: hg-main-tree: bounds fix

details:   http://hg.libpc.orghg-main-tree/rev/cd8b21bdc195
changeset: 326:cd8b21bdc195
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 11:03:52 2011 -0400
description:
bounds fix
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/c0536bd2e7db
changeset: 327:c0536bd2e7db
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 11:04:38 2011 -0400
description:
merge
Subject: hg-main-tree: bad merge

details:   http://hg.libpc.orghg-main-tree/rev/0ab6915ad1d7
changeset: 328:0ab6915ad1d7
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 17 11:06:31 2011 -0400
description:
bad merge

diffstat:

 include/libpc/Bounds.hpp                   |  13 ++++++-
 include/libpc/Stage.hpp                    |   4 +-
 include/libpc/drivers/faux/Reader.hpp      |   2 +-
 include/libpc/drivers/las/Reader.hpp       |   2 +-
 include/libpc/drivers/liblas/Reader.hpp    |   2 +-
 include/libpc/filters/CacheFilter.hpp      |   2 +-
 include/libpc/filters/ColorFilter.hpp      |   2 +-
 include/libpc/filters/CropFilter.hpp       |   2 +-
 include/libpc/filters/DecimationFilter.hpp |   2 +-
 include/libpc/filters/MosaicFilter.hpp     |   2 +-
 src/Bounds.cpp                             |   4 ++
 src/Chipper.cpp                            |   3 +-
 src/PointData.cpp                          |   4 +-
 src/Stage.cpp                              |   4 +-
 src/Writer.cpp                             |   4 +-
 src/drivers/faux/Reader.cpp                |   4 +-
 src/drivers/las/Reader.cpp                 |   5 +-
 src/drivers/liblas/Reader.cpp              |   2 +-
 src/filters/CacheFilter.cpp                |  12 +++---
 src/filters/ColorFilter.cpp                |   5 +-
 src/filters/CropFilter.cpp                 |  50 ++++++++++++++++-------------
 src/filters/DecimationFilter.cpp           |   9 +++--
 src/filters/MosaicFilter.cpp               |   7 ++-
 test/unit/BoundsTest.cpp                   |  17 ++++++++++
 test/unit/CacheFilterTest.cpp              |   8 +++-
 test/unit/CropFilterTest.cpp               |   2 +-
 test/unit/DecimationFilterTest.cpp         |   4 +-
 test/unit/FauxReaderTest.cpp               |  16 ++++++---
 test/unit/LiblasReaderTest.cpp             |   7 ++-
 test/unit/MosaicFilterTest.cpp             |   4 +-
 test/unit/PointDataTest.cpp                |  15 ++++++---
 31 files changed, 138 insertions(+), 81 deletions(-)

diffs (truncated from 714 to 300 lines):

diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/Bounds.hpp
--- a/include/libpc/Bounds.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/Bounds.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -48,6 +48,7 @@
 #include <sstream>
 #include <string>
 #include <stdexcept>
+#include <math.h>
 
 #include <libpc/export.hpp>
 #include <libpc/Vector.hpp>
@@ -396,8 +397,8 @@
             if (getMinimum(d) > getMaximum(d) )
             {
                 // Check that we're not infinity either way
-                if (Utils::compare_distance(getMinimum(d), std::numeric_limits<T>::max()) ||
-                    Utils::compare_distance(getMaximum(d), -std::numeric_limits<T>::max()))
+                if (Utils::compare_distance<T>(getMinimum(d), std::numeric_limits<T>::max()) ||
+                    Utils::compare_distance<T>(getMaximum(d), -std::numeric_limits<T>::max()))
                 {
                     std::ostringstream msg;
                     msg << "liblas::Bounds::verify: Minimum point at dimension " << d
@@ -419,6 +420,14 @@
     ////    trans.transform(maximum);
     ////    return Bounds<T>(minimum, maximum);
     ////}
+
+    static const Bounds<T>& getDefaultSpatialExtent()
+    {
+        static T minv(std::numeric_limits<T>::min());
+        static T maxv(std::numeric_limits<T>::max());
+        static Bounds v(minv,minv,minv,maxv,maxv,maxv);
+        return v;
+    }
 };
 
 template<class T>
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/Stage.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -68,7 +68,7 @@
     // readBuffer function below, not this one.
     //
     // Returns the number of valid points read.
-    boost::uint32_t read(PointData&);
+    boost::uint32_t read(PointData&, const Bounds<double>& bounds);
 
     // advance (or retreat) to the Nth point in the file (absolute, 
     // not relative).  In some cases, this might be a very slow, painful
@@ -93,7 +93,7 @@
 
 protected:
     // 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(PointData& pointData, const Bounds<double>& bounds) = 0;
 
     // Each concrete stage is repsonsible for managing its own current
     // point index when a read or seek occurs.  Call this function to set
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/drivers/faux/Reader.hpp
--- a/include/libpc/drivers/faux/Reader.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/drivers/faux/Reader.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -70,7 +70,7 @@
     void seekToPoint(boost::uint64_t);
 
 private:
-    boost::uint32_t readBuffer(PointData&);
+    boost::uint32_t readBuffer(PointData&, const Bounds<double>& bounds);
 
     Mode m_mode;
 
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/drivers/las/Reader.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -57,7 +57,7 @@
     const LasHeader& getLasHeader() const;
 
 protected:
-    boost::uint32_t readBuffer(PointData&);
+    boost::uint32_t readBuffer(PointData& data, const Bounds<double>& bounds);
 
     LasHeader& getLasHeader();
     void setLasHeader(const LasHeader&);
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/drivers/liblas/Reader.hpp
--- a/include/libpc/drivers/liblas/Reader.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/drivers/liblas/Reader.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -65,7 +65,7 @@
     boost::int8_t getPointFormatNumber() const;
 
 private:
-    virtual boost::uint32_t readBuffer(PointData&);
+    virtual boost::uint32_t readBuffer(PointData& data, const Bounds<double>& bounds);
 
     LiblasHeader& getLiblasHeader();
     void setLiblasHeader(const LiblasHeader&);
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/filters/CacheFilter.hpp
--- a/include/libpc/filters/CacheFilter.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/filters/CacheFilter.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -78,7 +78,7 @@
                        boost::uint64_t& numCacheInsertHits) const;
 
 private:
-    boost::uint32_t readBuffer(PointData&);
+    boost::uint32_t readBuffer(PointData& data, const Bounds<double>& bounds);
 
     boost::uint64_t m_numPointsRequested;
     boost::uint64_t m_numPointsRead;
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/filters/ColorFilter.hpp
--- a/include/libpc/filters/ColorFilter.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/filters/ColorFilter.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -52,7 +52,7 @@
     const std::string& getName() const;
 
 private:
-    boost::uint32_t readBuffer(PointData&);
+    boost::uint32_t readBuffer(PointData& data, const Bounds<double>& bounds);
     void checkImpedance();
     void getColor(float value, boost::uint8_t& red, boost::uint8_t& green, boost::uint8_t& blue);
 
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/filters/CropFilter.hpp
--- a/include/libpc/filters/CropFilter.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/filters/CropFilter.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -53,7 +53,7 @@
     void seekToPoint(boost::uint64_t pointNum);
 
 private:
-    boost::uint32_t readBuffer(PointData&);
+    boost::uint32_t readBuffer(PointData& data, const Bounds<double>& bounds);
 
     Bounds<double> m_bounds;
 
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/filters/DecimationFilter.hpp
--- a/include/libpc/filters/DecimationFilter.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/filters/DecimationFilter.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -53,7 +53,7 @@
     void seekToPoint(boost::uint64_t pointNum);
 
 private:
-    boost::uint32_t readBuffer(PointData&);
+    boost::uint32_t readBuffer(PointData& data, const Bounds<double>& bounds);
 
     int m_step;
 
diff -r da66202db196 -r 0ab6915ad1d7 include/libpc/filters/MosaicFilter.hpp
--- a/include/libpc/filters/MosaicFilter.hpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/include/libpc/filters/MosaicFilter.hpp	Thu Mar 17 11:06:31 2011 -0400
@@ -52,7 +52,7 @@
     void seekToPoint(boost::uint64_t pointNum);
 
 private:
-    boost::uint32_t readBuffer(PointData&);
+    boost::uint32_t readBuffer(PointData& data, const Bounds<double>& bounds);
 
     std::vector<Stage*> m_prevStages;
 
diff -r da66202db196 -r 0ab6915ad1d7 src/Bounds.cpp
--- a/src/Bounds.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/Bounds.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -31,3 +31,7 @@
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 ****************************************************************************/
+
+
+#include <libpc/Bounds.hpp>
+#include <math.h>
diff -r da66202db196 -r 0ab6915ad1d7 src/Chipper.cpp
--- a/src/Chipper.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/Chipper.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -136,7 +136,8 @@
 
         PointData buffer(schema, num_to_read);
 
-        boost::uint32_t num_read =  m_stage.read(buffer);
+        const Bounds<double>& bounds = Bounds<double>::getDefaultSpatialExtent();
+        boost::uint32_t num_read =  m_stage.read(buffer, bounds);
         
         assert(num_read <= num_to_read);
 
diff -r da66202db196 -r 0ab6915ad1d7 src/PointData.cpp
--- a/src/PointData.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/PointData.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -85,7 +85,7 @@
     std::size_t len = getSchemaLayout().getByteSize();
 
     memcpy(dest, src, len);
-    m_numPoints++;
+
     assert(m_numPoints <= m_capacity);
 
     return;
@@ -102,8 +102,6 @@
 
     memcpy(dest, src, len * numPoints);
     
-    // FIXME: This needs to be smarter
-    m_numPoints = m_numPoints + numPoints;
     assert(m_numPoints <= m_capacity);
 
     return;
diff -r da66202db196 -r 0ab6915ad1d7 src/Stage.cpp
--- a/src/Stage.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/Stage.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -91,9 +91,9 @@
 }
 
 
-boost::uint32_t Stage::read(PointData& data)
+boost::uint32_t Stage::read(PointData& data, const Bounds<double>& bounds)
 {
-    const boost::uint32_t numPointsRead = readBuffer(data);
+    const boost::uint32_t numPointsRead = readBuffer(data, bounds);
     return numPointsRead;
 }
 
diff -r da66202db196 -r 0ab6915ad1d7 src/Writer.cpp
--- a/src/Writer.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/Writer.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -73,6 +73,8 @@
 
 boost::uint64_t Writer::write(std::size_t targetNumPointsToWrite)
 {
+    const Bounds<double>& maxBounds = Bounds<double>::getDefaultSpatialExtent();
+
     m_targetNumPointsToWrite = targetNumPointsToWrite;
     m_actualNumPointsWritten = 0;
 
@@ -85,7 +87,7 @@
 
         PointData buffer(m_prevStage.getHeader().getSchema(), numPointsToReadThisChunk);
 
-        boost::uint32_t numPointsReadThisChunk = m_prevStage.read(buffer);
+        boost::uint32_t numPointsReadThisChunk = m_prevStage.read(buffer, maxBounds);
         assert(numPointsReadThisChunk <= numPointsToReadThisChunk);
 
         boost::uint32_t numPointsWrittenThisChunk = writeBuffer(buffer);
diff -r da66202db196 -r 0ab6915ad1d7 src/drivers/faux/Reader.cpp
--- a/src/drivers/faux/Reader.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/drivers/faux/Reader.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -94,7 +94,7 @@
 }
 
 
-boost::uint32_t Reader::readBuffer(PointData& data)
+boost::uint32_t Reader::readBuffer(PointData& data, const Bounds<double>& userBounds)
 {
     if (data.getSchemaLayout().getSchema().getDimensions().size() != 4)
         throw not_yet_implemented("need to add ability to read from arbitrary fields");
@@ -108,7 +108,7 @@
     const Schema& schema = schemaLayout.getSchema();
     Header& header = getHeader();
 
-    const Bounds<double>& bounds = header.getBounds();
+    const Bounds<double>& bounds = header.getBounds(); 
     const std::vector< Range<double> >& dims = bounds.dimensions();
     const double minX = dims[0].getMinimum();
     const double maxX = dims[0].getMaximum();
diff -r da66202db196 -r 0ab6915ad1d7 src/drivers/las/Reader.cpp
--- a/src/drivers/las/Reader.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/drivers/las/Reader.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -81,14 +81,15 @@
 
     // BUG: we can move the stream a constant amount
     PointData pointData(getHeader().getSchema(), chunk);
-    read(pointData);
+    const Bounds<double>& maxBounds = Bounds<double>::getDefaultSpatialExtent();
+    read(pointData, maxBounds);
 
     // just drop the points on the floor and return
     return;
 }
 
 
-boost::uint32_t LasReader::readBuffer(PointData& pointData)
+boost::uint32_t LasReader::readBuffer(PointData& pointData, const Bounds<double>& bounds)
 {
     boost::uint32_t numPoints = pointData.getNumPoints();
 
diff -r da66202db196 -r 0ab6915ad1d7 src/drivers/liblas/Reader.cpp
--- a/src/drivers/liblas/Reader.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/drivers/liblas/Reader.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -233,7 +233,7 @@
 }
 
 
-boost::uint32_t LiblasReader::readBuffer(PointData& pointData)
+boost::uint32_t LiblasReader::readBuffer(PointData& pointData, const Bounds<double>& bounds)
 {
     boost::uint32_t numPoints = pointData.getNumPoints();
     boost::uint32_t i = 0;
diff -r da66202db196 -r 0ab6915ad1d7 src/filters/CacheFilter.cpp
--- a/src/filters/CacheFilter.cpp	Thu Mar 17 09:56:31 2011 -0400
+++ b/src/filters/CacheFilter.cpp	Thu Mar 17 11:06:31 2011 -0400
@@ -112,21 +112,21 @@
 }
 
 
-boost::uint32_t CacheFilter::readBuffer(PointData& data)
+boost::uint32_t CacheFilter::readBuffer(PointData& data, const Bounds<double>& bounds)
 {
     const boost::uint64_t currentPointIndex = getCurrentPointIndex();


More information about the Liblas-commits mailing list