[Liblas-commits] hg: add sround to utility functions, use for detail::writer::Poi...

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jul 26 12:34:18 EDT 2010


changeset e59376c6e330 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=e59376c6e330
summary: add sround to utility functions, use for detail::writer::Point and the lasbounds chipper.  Remove detail::Extents

diffstat:

 apps/chipper.cpp                  |   2 +-
 apps/chipper.hpp                  |   1 +
 include/liblas/detail/utility.hpp |  63 +++++++++++++++++++++-----------------
 3 files changed, 37 insertions(+), 29 deletions(-)

diffs (110 lines):

diff -r 0528a32de5bc -r e59376c6e330 apps/chipper.cpp
--- a/apps/chipper.cpp	Mon Jul 26 17:18:23 2010 +0100
+++ b/apps/chipper.cpp	Mon Jul 26 11:34:10 2010 -0500
@@ -148,7 +148,7 @@
     m_partitions.push_back(0);
     for (uint32_t i = 0; i < num_partitions; ++i) {
         total += partition_size;
-        m_partitions.push_back((uint32_t)round(total));
+        m_partitions.push_back((uint32_t)detail::sround(total));
     }
 }
 
diff -r 0528a32de5bc -r e59376c6e330 apps/chipper.hpp
--- a/apps/chipper.hpp	Mon Jul 26 17:18:23 2010 +0100
+++ b/apps/chipper.hpp	Mon Jul 26 11:34:10 2010 -0500
@@ -3,6 +3,7 @@
 
 #include <vector>
 #include <liblas/lasreader.hpp>
+#include <liblas/detail/utility.hpp>
 
 namespace liblas
 {
diff -r 0528a32de5bc -r e59376c6e330 include/liblas/detail/utility.hpp
--- a/include/liblas/detail/utility.hpp	Mon Jul 26 17:18:23 2010 +0100
+++ b/include/liblas/detail/utility.hpp	Mon Jul 26 11:34:10 2010 -0500
@@ -53,6 +53,9 @@
 #include <limits>
 #include <sstream>
 #include <stdexcept>
+#include <cmath>
+
+
 // boost
 #ifdef HAVE_BOOST
 #include <boost/concept_check.hpp>
@@ -77,6 +80,10 @@
 
 #endif // HAVE_BOOST
 
+// From http://stackoverflow.com/questions/485525/round-for-float-in-c
+inline double sround(double r) {
+    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
+}
 
 
 /// Compile-time calculation size of array defined statically.
@@ -224,34 +231,34 @@
     return (!lhs.equal(rhs));
 }
 
-template <typename T>
-struct Extents
-{
-    Extents() {}
-    Extents(detail::Point<T> const& min, detail::Point<T> const& max)
-        : min(min), max(max)
-    {}
-
-    bool equal(Extents<T> const& other) const
-    {
-        return (min == other.min && max == other.max);
-    }
-
-    typename detail::Point<T> min;
-    typename detail::Point<T> max;
-};
-
-template <typename T>
-bool operator==(Extents<T> const& lhs, Extents<T> const& rhs)
-{
-    return lhs.equal(rhs);
-}
-
-template <typename T>
-bool operator!=(Extents<T> const& lhs, Extents<T> const& rhs)
-{
-    return (!lhs.equal(rhs));
-}
+// template <typename T>
+// struct Extents
+// {
+//     Extents() {}
+//     Extents(detail::Point<T> const& min, detail::Point<T> const& max)
+//         : min(min), max(max)
+//     {}
+// 
+//     bool equal(Extents<T> const& other) const
+//     {
+//         return (min == other.min && max == other.max);
+//     }
+// 
+//     typename detail::Point<T> min;
+//     typename detail::Point<T> max;
+// };
+// 
+// template <typename T>
+// bool operator==(Extents<T> const& lhs, Extents<T> const& rhs)
+// {
+//     return lhs.equal(rhs);
+// }
+// 
+// template <typename T>
+// bool operator!=(Extents<T> const& lhs, Extents<T> const& rhs)
+// {
+//     return (!lhs.equal(rhs));
+// }
 
 template <typename T>
 inline T generate_random_byte()


More information about the Liblas-commits mailing list