[Liblas-commits] libpc: namespacing, adding Bounds class

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Feb 10 23:53:16 EST 2011


details:   http://hg.liblas.orglibpc/rev/5b5218def9ed
changeset: 29:5b5218def9ed
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Feb 10 20:47:31 2011 -0800
description:
namespacing, adding Bounds class
Subject: libpc: merge

details:   http://hg.liblas.orglibpc/rev/605c80e02696
changeset: 30:605c80e02696
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Feb 10 20:53:09 2011 -0800
description:
merge

diffstat:

 apps/CMakeLists.txt           |    2 +-
 apps/pc2pc.cpp                |    5 +-
 apps/pcinfo.cpp               |    6 +-
 include/libpc/Bounds.hpp      |  465 +++++++++++++++++++++++++++++++++++++----
 include/libpc/ColorFilter.hpp |    9 +-
 include/libpc/CropFilter.hpp  |   11 +-
 include/libpc/FauxReader.hpp  |    9 +-
 include/libpc/FauxWriter.hpp  |    7 +-
 include/libpc/Field.hpp       |    7 +-
 include/libpc/Filter.hpp      |   10 +-
 include/libpc/Header.hpp      |   14 +-
 include/libpc/PointData.hpp   |   11 +-
 include/libpc/PointLayout.hpp |    7 +-
 include/libpc/Range.hpp       |  153 +++++++++++++
 include/libpc/Reader.hpp      |    6 +-
 include/libpc/Stage.hpp       |    6 +-
 include/libpc/Utils.hpp       |   15 +
 include/libpc/Writer.hpp      |    6 +-
 include/libpc/export.hpp      |   60 +++++
 mpg-config.bat                |    4 +-
 src/Bounds.cpp                |   36 ---
 src/CMakeLists.txt            |    4 +-
 src/ColorFilter.cpp           |    5 +-
 src/FauxReader.cpp            |   17 +-
 src/FauxWriter.cpp            |    1 +
 test/unit/CMakeLists.txt      |    2 +-
 26 files changed, 753 insertions(+), 125 deletions(-)

diffs (truncated from 1298 to 300 lines):

diff -r c60e5261cfc2 -r 605c80e02696 apps/CMakeLists.txt
--- a/apps/CMakeLists.txt	Wed Feb 09 20:14:32 2011 -0800
+++ b/apps/CMakeLists.txt	Thu Feb 10 20:53:09 2011 -0800
@@ -43,7 +43,7 @@
 # Configure build targets
 
 if(WIN32)
-    add_definitions("-DPC_DLL_EXPORT=1")
+    add_definitions("-DLIBPC_DLL_EXPORT=1")
 endif()
 
 
diff -r c60e5261cfc2 -r 605c80e02696 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Wed Feb 09 20:14:32 2011 -0800
+++ b/apps/pc2pc.cpp	Thu Feb 10 20:53:09 2011 -0800
@@ -9,10 +9,11 @@
  * See LICENSE.txt in this source distribution for more information.
  **************************************************************************/
 
-#include <stdio.h>
+#include <libpc/Bounds.hpp>
 int main(int, char* [])
 {
-  printf("Hi\n");
+  Bounds bounds(1,2,3,4,5,6);
+  bounds.dump();
   return 0;
 }
 #if 0
diff -r c60e5261cfc2 -r 605c80e02696 apps/pcinfo.cpp
--- a/apps/pcinfo.cpp	Wed Feb 09 20:14:32 2011 -0800
+++ b/apps/pcinfo.cpp	Thu Feb 10 20:53:09 2011 -0800
@@ -9,10 +9,12 @@
  * See LICENSE.txt in this source distribution for more information.
  **************************************************************************/
 
-#include <stdio.h>
+#include <libpc/Bounds.hpp>
+
 int main(int, char* [])
 {
-  printf("Hi\n");
+  Bounds bounds(0,1,2,3,4,5);
+  bounds.dump();
   return 0;
 }
 #if 0
diff -r c60e5261cfc2 -r 605c80e02696 include/libpc/Bounds.hpp
--- a/include/libpc/Bounds.hpp	Wed Feb 09 20:14:32 2011 -0800
+++ b/include/libpc/Bounds.hpp	Thu Feb 10 20:53:09 2011 -0800
@@ -1,5 +1,5 @@
 /******************************************************************************
-* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.com
 *
 * All rights reserved.
 * 
@@ -35,71 +35,432 @@
 #ifndef INCLUDED_BOUNDS_HPP
 #define INCLUDED_BOUNDS_HPP
 
-#include <limits>
+#include <vector>
+#include <iostream>
+#include <sstream>
+#include <string>
 
+#include "libpc/export.hpp"
+#include "libpc/Range.hpp"
+
+namespace libpc
+{
+
+template <typename T>
 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)
-  {
-  }
+	typedef T value_type;
+    typedef typename std::vector< Range<T> >::size_type size_type;
+    
+    typedef typename std::vector< Range<T> > RangeVec;
+private:
 
-  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)
-  {
-  }
+    RangeVec ranges;
+    
+public:
 
-  Bounds& operator=(const Bounds & other)
-  {
-    if (this != &other)
+Bounds<T>()
+{
+    ranges.resize(0);
+}
+
+Bounds(Bounds const& other)
+    : 
+    ranges(other.ranges)
+{
+}
+
+Bounds(RangeVec const& rngs)
+    : 
+    ranges(rngs)
+{
+}
+
+Bounds( T minx, 
+        T miny, 
+        T minz, 
+        T maxx, 
+        T maxy, 
+        T maxz)
+{
+    ranges.resize(3);
+    
+    ranges[0].minimum = minx;
+    ranges[1].minimum = miny;
+    ranges[2].minimum = minz;
+
+    ranges[0].maximum = maxx;
+    ranges[1].maximum = maxy;
+    ranges[2].maximum = maxz;
+    
+#ifdef DEBUG
+    verify();
+#endif
+
+}
+
+Bounds( T minx, 
+        T miny, 
+        T maxx, 
+        T maxy)
+{
+
+    ranges.resize(2);
+
+    ranges[0].minimum = minx;
+    ranges[1].minimum = miny;
+
+    ranges[0].maximum = maxx;
+    ranges[1].maximum = maxy;
+    
+#ifdef DEBUG
+    verify();
+#endif
+
+}
+
+////Bounds( const Point& min, const Point& max)
+////{
+////    ranges.resize(3);
+////    
+////    ranges[0].minimum = min.GetX();
+////    ranges[1].minimum = min.GetY();
+////    ranges[2].minimum = min.GetZ();
+////
+////    ranges[0].maximum = max.GetX();
+////    ranges[1].maximum = max.GetY();
+////    ranges[2].maximum = max.GetZ();
+////    
+////#ifdef DEBUG
+////    verify();
+////#endif
+////}
+
+T (min)(std::size_t const& index) const
+{
+    if (ranges.size() <= index) {
+        // std::ostringstream msg; 
+        // msg << "Bounds dimensions, " << ranges.size() <<", is less "
+        //     << "than the given index, " << index;
+        // throw std::runtime_error(msg.str());                
+        return 0;
+    }
+    return ranges[index].minimum;
+}
+
+void (min)(std::size_t const& index, T v)
+{
+    if (ranges.size() <= index) {
+        ranges.resize(index + 1);
+    }
+    ranges[index].minimum = v;
+}
+
+T (max)(std::size_t const& index) const
+{
+    if (ranges.size() <= index) {
+        // std::ostringstream msg; 
+        // msg << "Bounds dimensions, " << ranges.size() <<", is less "
+        //     << "than the given index, " << index;
+        // throw std::runtime_error(msg.str());    
+        return 0;
+    }
+    return ranges[index].maximum;
+}
+
+void (max)(std::size_t const& index, T v)
+{
+    if (ranges.size() <= index) {
+        ranges.resize(index + 1);
+    }
+    ranges[index].maximum = v;
+}
+
+////liblas::Point (min)() {
+////    liblas::Point p;
+////    try 
+////    {
+////        p.SetCoordinates(ranges[0].minimum, ranges[1].minimum, ranges[2].minimum);
+////    } 
+////    catch (std::runtime_error const& e)
+////    {
+////        ::boost::ignore_unused_variable_warning(e);
+////        p.SetCoordinates(ranges[0].minimum, ranges[1].minimum, 0);
+////        
+////    }
+////
+////    return p;
+////}
+////
+////liblas::Point (max)() {
+////    liblas::Point p;
+////    try 
+////    {
+////        p.SetCoordinates(ranges[0].maximum, ranges[1].maximum, ranges[2].maximum);
+////    } 
+////    catch (std::runtime_error const& e)
+////    {
+////        ::boost::ignore_unused_variable_warning(e);
+////        p.SetCoordinates(ranges[0].maximum, ranges[1].maximum, 0);
+////        
+////    }
+////    return p;
+////}
+
+#if 0
+// BUG: what are the semantics of these?
+T minx() const { if (ranges.size() == 0) return 0; return ranges[0].minimum; }
+T miny() const { if (ranges.size() < 2) return 0; return ranges[1].minimum; }
+T minz() const { if (ranges.size() < 3) return 0; return ranges[2].minimum; }
+T maxx() const { if (ranges.size() == 0) return 0; return ranges[0].maximum; }
+T maxy() const { if (ranges.size() < 2) return 0; return ranges[1].maximum; }
+T maxz() const { if (ranges.size() < 3) return 0; return ranges[2].maximum; }
+#endif
+
+inline bool operator==(Bounds<T> const& rhs) const
+{
+    return equal(rhs);
+}
+
+inline bool operator!=(Bounds<T> const& rhs) const
+{
+    return (!equal(rhs));
+}
+
+
+Bounds<T>& operator=(Bounds<T> const& rhs) 
+{
+    if (&rhs != this)
     {
-      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;
+        ranges = rhs.ranges;
     }
     return *this;


More information about the Liblas-commits mailing list