[Liblas-commits] libpc: working end-to-end now

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Feb 8 12:12:01 EST 2011


details:   http://hg.liblas.orglibpc/rev/d541e1299674
changeset: 10:d541e1299674
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Feb 08 09:11:46 2011 -0800
description:
working end-to-end now

diffstat:

 include/libpc/Bounds.hpp      |  102 ++++++++++++++++++++++++++++++++++++++++++
 include/libpc/CropFilter.hpp  |   10 +--
 include/libpc/Header.hpp      |   12 ++--
 include/libpc/PointLayout.hpp |    8 +-
 include/libpc/Utils.hpp       |   13 ++--
 src/Bounds.cpp                |   49 ++++++++++++++++++++
 src/ColorFilter.cpp           |   28 ++++++++--
 src/CropFilter.cpp            |   12 +---
 src/FauxReader.cpp            |   32 +++++-------
 src/Header.cpp                |   23 +++++++-
 src/PointData.cpp             |   47 ++++++++++---------
 src/main.cpp                  |    2 +-
 src/prototype.vcxproj         |    2 +
 13 files changed, 254 insertions(+), 86 deletions(-)

diffs (truncated from 637 to 300 lines):

diff -r 7ac0fe222e37 -r d541e1299674 include/libpc/Bounds.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/Bounds.hpp	Tue Feb 08 09:11:46 2011 -0800
@@ -0,0 +1,102 @@
+/******************************************************************************
+* 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.
+****************************************************************************/
+
+#ifndef INCLUDED_BOUNDS_HPP
+#define INCLUDED_BOUNDS_HPP
+
+#include <limits>
+
+class Bounds
+{
+public:
+  Bounds()
+    : m_minX(-std::numeric_limits<double>::infinity()),
+    m_maxX(std::numeric_limits<double>::infinity()),
+    m_minY(-std::numeric_limits<double>::infinity()),
+    m_maxY(std::numeric_limits<double>::infinity()),
+    m_minZ(-std::numeric_limits<double>::infinity()),
+    m_maxZ(std::numeric_limits<double>::infinity())
+  {
+  }
+
+  Bounds(double minX, double maxX, double minY, double maxY, double minZ, double maxZ)
+    : m_minX(minX),
+    m_maxX(maxX),
+    m_minY(minY),
+    m_maxY(maxY),
+    m_minZ(minZ),
+    m_maxZ(maxZ)
+  {
+  }
+
+  Bounds(const Bounds& other)
+    : m_minX(other.m_minX),
+    m_maxX(other.m_maxX),
+    m_minY(other.m_minY),
+    m_maxY(other.m_maxY),
+    m_minZ(other.m_minZ),
+    m_maxZ(other.m_maxZ)
+  {
+  }
+
+  Bounds& operator=(const Bounds & other)
+  {
+    if (this != &other)
+    {
+      m_minX = other.m_minX;
+      m_maxX = other.m_maxX;
+      m_minY = other.m_minY;
+      m_maxY = other.m_maxY;
+      m_minZ = other.m_minZ;
+      m_maxZ = other.m_maxZ;
+    }
+    return *this;
+  }
+
+  bool contains(double x, double y, double z) const
+  {
+    return (x >= m_minX && x <= m_maxX && y >= m_minY && y <= m_maxY && z >= m_minZ && z <= m_maxZ);
+  }
+
+  void dump() const;
+
+  double m_minX;
+  double m_maxX;
+  double m_minY;
+  double m_maxY;
+  double m_minZ;
+  double m_maxZ;
+};
+
+#endif
diff -r 7ac0fe222e37 -r d541e1299674 include/libpc/CropFilter.hpp
--- a/include/libpc/CropFilter.hpp	Mon Feb 07 18:39:05 2011 -0800
+++ b/include/libpc/CropFilter.hpp	Tue Feb 08 09:11:46 2011 -0800
@@ -36,13 +36,14 @@
 #define INCLUDED_CROPFILTER_HPP
 
 #include "libpc/Filter.hpp"
+#include "libpc/Bounds.hpp"
 
 
 // removes any points outside of the given range
 class CropFilter : public Filter
 {
 public:
-  CropFilter(Stage& prevStage, float minX, float maxX, float minY, float maxY, float minZ, float maxZ);
+  CropFilter(Stage& prevStage, const Bounds& bounds);
   void initialize();
 
   void updateLayout();
@@ -50,12 +51,7 @@
   void readNextPoints(PointData&);
 
 private:
-  float m_minX;
-  float m_maxX;
-  float m_minY;
-  float m_maxY;
-  float m_minZ;
-  float m_maxZ;
+  Bounds m_bounds;
 
   CropFilter& operator=(const CropFilter&); // not implemented
   CropFilter(const CropFilter&); // not implemented
diff -r 7ac0fe222e37 -r d541e1299674 include/libpc/Header.hpp
--- a/include/libpc/Header.hpp	Mon Feb 07 18:39:05 2011 -0800
+++ b/include/libpc/Header.hpp	Tue Feb 08 09:11:46 2011 -0800
@@ -36,6 +36,7 @@
 #define INCLUDED_HEADER_HPP
 
 #include "libpc/PointLayout.hpp"
+#include "libpc/Bounds.hpp"
 
 class Header
 {
@@ -44,13 +45,6 @@
   Header(const Header&);
   Header& operator=(const Header&);
 
-  double m_minX;
-  double m_maxX;
-  double m_minY;
-  double m_maxY;
-  double m_minZ;
-  double m_maxZ;
-
   const PointLayout& getConstPointLayout() const;
   PointLayout& getPointLayout();
   void setLayout(const PointLayout&);
@@ -58,11 +52,15 @@
   int getNumPoints() const;
   void setNumPoints(int);
 
+  const Bounds& getBounds() const;
+  void setBounds(const Bounds&);
+
   void dump() const;
 
 private:
   PointLayout m_pointLayout;
   int m_numPoints;
+  Bounds m_bounds;
 };
 
 #endif
diff -r 7ac0fe222e37 -r d541e1299674 include/libpc/PointLayout.hpp
--- a/include/libpc/PointLayout.hpp	Mon Feb 07 18:39:05 2011 -0800
+++ b/include/libpc/PointLayout.hpp	Tue Feb 08 09:11:46 2011 -0800
@@ -49,10 +49,10 @@
   void addField(const Field& field);
   void addFields(const std::vector<Field>& fields);
 
-  const Field& getField(int index) const { return m_fields[index]; }
-  bool isActive(int index) const { return m_isActive[index]; }
-  void setActive(int index) { m_isActive[index] = true; }
-  void setInactive(int index) { m_isActive[index] = false; }
+  const Field& getField(int fieldIndex) const { return m_fields[fieldIndex]; }
+  bool isActive(int fieldIndex) const { return m_isActive[fieldIndex]; }
+  void setActive(int fieldIndex) { m_isActive[fieldIndex] = true; }
+  void setInactive(int fieldIndex) { m_isActive[fieldIndex] = false; }
 
   int getSizeInBytes() const;
   int getNumFields() const;
diff -r 7ac0fe222e37 -r d541e1299674 include/libpc/Utils.hpp
--- a/include/libpc/Utils.hpp	Mon Feb 07 18:39:05 2011 -0800
+++ b/include/libpc/Utils.hpp	Tue Feb 08 09:11:46 2011 -0800
@@ -41,18 +41,17 @@
 class Utils
 {
 public:
-  template<class T>
-  static T random(T min, T max)
+  static double random(double min, double max)
   {
     double r = (double)rand();  // [0..32767]
-    double v = (double)(max - min) / (double)RAND_MAX;
+    double v = (max - min) / (double)RAND_MAX;
     double s = r * v; // [0..(max-min)]
-    double t = (double)min + s; // [min..max]
+    double t = min + s; // [min..max]
 
-    assert((T)t >= min);
-    assert((T)t <= max);
+    assert(t >= min);
+    assert(t <= max);
 
-    return (T)t;
+    return t;
   }
 };
 
diff -r 7ac0fe222e37 -r d541e1299674 src/Bounds.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Bounds.cpp	Tue Feb 08 09:11:46 2011 -0800
@@ -0,0 +1,49 @@
+/******************************************************************************
+* 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/Bounds.hpp"
+
+#include <iostream>
+
+using std::cout;
+
+
+void Bounds::dump(void) const
+{
+  cout << "x(" << m_minX << "," << m_maxX << ")";
+  cout << " ";
+  cout << "y(" << m_minY << "," << m_maxY << ")";
+  cout << " ";
+  cout << "z(" << m_minZ << "," << m_maxZ << ")";
+}
diff -r 7ac0fe222e37 -r d541e1299674 src/ColorFilter.cpp
--- a/src/ColorFilter.cpp	Mon Feb 07 18:39:05 2011 -0800
+++ b/src/ColorFilter.cpp	Tue Feb 08 09:11:46 2011 -0800
@@ -32,8 +32,11 @@
 * OF SUCH DAMAGE.
 ****************************************************************************/
 
+#include <cassert>
 #include "libpc/ColorFilter.hpp"
 
+
+
 ColorFilter::ColorFilter(Stage& prevStage) 
   : Filter(prevStage)
 {
@@ -58,7 +61,7 @@
   // add the three u8 fields
   myLayout.addField(Field(Field::Zred, Field::U8));
   myLayout.addField(Field(Field::Zgreen, Field::U8));
-  myLayout.addField(Field(Field::Zgreen, Field::U8));
+  myLayout.addField(Field(Field::Zblue, Field::U8));


More information about the Liblas-commits mailing list