[Liblas-commits] hg: remove detail::Extents
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Jul 26 12:58:51 EDT 2010
changeset 19e55b8af7d2 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=19e55b8af7d2
summary: remove detail::Extents
diffstat:
include/liblas/detail/fwd.hpp | 1 +
include/liblas/lasbounds.hpp | 23 ++++++++++++++++-------
include/liblas/lasheader.hpp | 8 +++++---
include/liblas/laspoint.hpp | 2 +-
src/detail/reader/reader.cpp | 3 +--
src/detail/writer/point.cpp | 11 +++--------
src/lasheader.cpp | 27 ++++++++++++++++-----------
test/unit/common.hpp | 25 ++++++++++++++-----------
test/unit/lasreader_iterator_test.cpp | 7 ++++---
9 files changed, 61 insertions(+), 46 deletions(-)
diffs (truncated from 320 to 300 lines):
diff -r e59376c6e330 -r 19e55b8af7d2 include/liblas/detail/fwd.hpp
--- a/include/liblas/detail/fwd.hpp Mon Jul 26 11:34:10 2010 -0500
+++ b/include/liblas/detail/fwd.hpp Mon Jul 26 11:58:44 2010 -0500
@@ -54,6 +54,7 @@
class PointFormat;
class Classification;
class VariableRecord;
+class Bounds;
namespace detail {
diff -r e59376c6e330 -r 19e55b8af7d2 include/liblas/lasbounds.hpp
--- a/include/liblas/lasbounds.hpp Mon Jul 26 11:34:10 2010 -0500
+++ b/include/liblas/lasbounds.hpp Mon Jul 26 11:58:44 2010 -0500
@@ -43,9 +43,8 @@
#define LIBLAS_LASBOUNDS_HPP_INCLUDED
#include <liblas/lasversion.hpp>
-#include <liblas/lasheader.hpp>
+#include <liblas/detail/fwd.hpp>
#include <liblas/laspoint.hpp>
-#include <liblas/detail/fwd.hpp>
#include <liblas/liblas.hpp>
#include <vector>
@@ -79,12 +78,24 @@
Bounds& operator=(Bounds const& rhs);
double min(liblas::uint32_t i) const { return mins[i]; }
+ void min(liblas::uint32_t i, double v) { mins[i] = v; }
double max(liblas::uint32_t i) const { return maxs[i]; }
+ void max(liblas::uint32_t i, double v) { maxs[i] = v; }
bool equal(Bounds const& other) const;
bool intersects2d(Bounds const& other) const;
bool intersects3d(Bounds const& other) const;
-
+
+ bool operator==(Bounds const& rhs)
+ {
+ return equal(rhs);
+ }
+
+ bool operator!=(Bounds const& rhs)
+ {
+ return (!equal(rhs));
+ }
+
private:
Array mins;
Array maxs;
@@ -93,14 +104,12 @@
};
-template <typename T>
-bool operator==(Bounds const& lhs, Bounds const& rhs)
+inline bool operator==(Bounds const& lhs, Bounds const& rhs)
{
return lhs.equal(rhs);
}
-template <typename T>
-bool operator!=(Bounds const& lhs, Bounds const& rhs)
+inline bool operator!=(Bounds const& lhs, Bounds const& rhs)
{
return (!lhs.equal(rhs));
}
diff -r e59376c6e330 -r 19e55b8af7d2 include/liblas/lasheader.hpp
--- a/include/liblas/lasheader.hpp Mon Jul 26 11:34:10 2010 -0500
+++ b/include/liblas/lasheader.hpp Mon Jul 26 11:58:44 2010 -0500
@@ -45,6 +45,7 @@
#include <liblas/cstdint.hpp>
#include <liblas/detail/utility.hpp>
+#include <liblas/lasbounds.hpp>
#include <liblas/detail/fwd.hpp>
#include <liblas/liblas.hpp>
@@ -325,12 +326,13 @@
Schema GetSchema() const;
void SetSchema(const Schema& format);
-
+
+ void SetExtent(Bounds& b);
+ const Bounds& GetExtent() const {return m_extent; }
private:
typedef detail::Point<double> PointScales;
typedef detail::Point<double> PointOffsets;
- typedef detail::Extents<double> PointExtents;
enum
{
@@ -379,7 +381,7 @@
RecordsByReturnArray m_pointRecordsByReturn;
PointScales m_scales;
PointOffsets m_offsets;
- PointExtents m_extents;
+ Bounds m_extent;
std::vector<VariableRecord> m_vlrs;
SpatialReference m_srs;
Schema m_format;
diff -r e59376c6e330 -r 19e55b8af7d2 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp Mon Jul 26 11:34:10 2010 -0500
+++ b/include/liblas/laspoint.hpp Mon Jul 26 11:58:44 2010 -0500
@@ -46,7 +46,6 @@
#include <liblas/detail/fwd.hpp>
#include <liblas/detail/utility.hpp>
#include <liblas/lasclassification.hpp>
-#include <liblas/lasheader.hpp>
#include <liblas/lascolor.hpp>
// std
@@ -60,6 +59,7 @@
namespace liblas {
+ class Header; // forward declaration
/// Point data record composed with X, Y, Z coordinates and attributes.
class Point
diff -r e59376c6e330 -r 19e55b8af7d2 src/detail/reader/reader.cpp
--- a/src/detail/reader/reader.cpp Mon Jul 26 11:34:10 2010 -0500
+++ b/src/detail/reader/reader.cpp Mon Jul 26 11:58:44 2010 -0500
@@ -325,9 +325,8 @@
typedef std::vector<uint8_t>::size_type size_type;
size_type old_cache_start_position = m_cache_start_position;
size_type header_size = static_cast<size_type>(header.GetPointRecordsCount());
- size_type left_to_cache = std::min(m_cache_size, header_size - m_cache_start_position);
+ size_type to_mark = std::min(m_cache_size, header_size - old_cache_start_position);
- size_type to_mark = std::min(m_cache_size, header_size - old_cache_start_position);
for (uint32_t i = 0; i < to_mark; ++i) {
size_type const mark_pos = m_cache_start_position + i;
diff -r e59376c6e330 -r 19e55b8af7d2 src/detail/writer/point.cpp
--- a/src/detail/writer/point.cpp Mon Jul 26 11:34:10 2010 -0500
+++ b/src/detail/writer/point.cpp Mon Jul 26 11:58:44 2010 -0500
@@ -50,11 +50,6 @@
#include <cmath>
-// From http://stackoverflow.com/questions/485525/round-for-float-in-c
-double sround(double r) {
- return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
-}
-
namespace liblas { namespace detail { namespace writer {
@@ -186,9 +181,9 @@
{
liblas::Point& p = m_point;
- m_record.x = static_cast<int32_t>(sround(((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX())));
- m_record.y = static_cast<int32_t>(sround(((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY())));
- m_record.z = static_cast<int32_t>(sround(((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ())));
+ m_record.x = static_cast<int32_t>(detail::sround(((p.GetX() - m_header.GetOffsetX()) / m_header.GetScaleX())));
+ m_record.y = static_cast<int32_t>(detail::sround(((p.GetY() - m_header.GetOffsetY()) / m_header.GetScaleY())));
+ m_record.z = static_cast<int32_t>(detail::sround(((p.GetZ() - m_header.GetOffsetZ()) / m_header.GetScaleZ())));
Classification::bitset_type clsflags(p.GetClassification());
m_record.classification = static_cast<uint8_t>(clsflags.to_ulong());
diff -r e59376c6e330 -r 19e55b8af7d2 src/lasheader.cpp
--- a/src/lasheader.cpp Mon Jul 26 11:34:10 2010 -0500
+++ b/src/lasheader.cpp Mon Jul 26 11:58:44 2010 -0500
@@ -89,7 +89,7 @@
m_pointRecordsCount(other.m_pointRecordsCount),
m_scales(other.m_scales),
m_offsets(other.m_offsets),
- m_extents(other.m_extents),
+ m_extent(other.m_extent),
m_srs(other.m_srs),
m_format(other.m_format)
{
@@ -146,7 +146,7 @@
std::vector<VariableRecord>(rhs.m_vlrs).swap(m_vlrs);
m_scales = rhs.m_scales;
m_offsets = rhs.m_offsets;
- m_extents = rhs.m_extents;
+ m_extent = rhs.m_extent;
m_srs = rhs.m_srs;
m_format = rhs.m_format;
@@ -180,7 +180,7 @@
if (m_pointRecordsByReturn != other.m_pointRecordsByReturn) return false;
if (m_scales != other.m_scales) return false;
if (m_offsets != other.m_offsets) return false;
- if (m_extents != other.m_extents) return false;
+ if (m_extent != other.m_extent) return false;
return true;
}
@@ -490,42 +490,47 @@
double Header::GetMaxX() const
{
- return m_extents.max.x;
+ return m_extent.max(0);
}
double Header::GetMinX() const
{
- return m_extents.min.x;
+ return m_extent.min(0);
}
double Header::GetMaxY() const
{
- return m_extents.max.y;
+ return m_extent.max(1);
}
double Header::GetMinY() const
{
- return m_extents.min.y;
+ return m_extent.min(1);
}
double Header::GetMaxZ() const
{
- return m_extents.max.z;
+ return m_extent.max(2);
}
double Header::GetMinZ() const
{
- return m_extents.min.z;
+ return m_extent.min(2);
}
void Header::SetMax(double x, double y, double z)
{
- m_extents.max = detail::Point<double>(x, y, z);
+ // m_extent = Bounds(m_extent.min(0), m_extent.min(1), m_extent.max(0), m_extent.max(1), m_extent.min(2), m_extent.max(2));
+ m_extent = Bounds(m_extent.min(0), m_extent.min(1), x, y, m_extent.min(2), z);
}
void Header::SetMin(double x, double y, double z)
{
- m_extents.min = detail::Point<double>(x, y, z);
+ m_extent = Bounds(x, y, m_extent.max(0), m_extent.max(1), z, m_extent.max(2));
+}
+
+void Header::SetExtent(Bounds& b) {
+ m_extent = b;
}
void Header::AddVLR(VariableRecord const& v)
diff -r e59376c6e330 -r 19e55b8af7d2 test/unit/common.hpp
--- a/test/unit/common.hpp Mon Jul 26 11:34:10 2010 -0500
+++ b/test/unit/common.hpp Mon Jul 26 11:58:44 2010 -0500
@@ -37,7 +37,7 @@
// Functor to calculate bounding box of a set of points
struct bbox_calculator
{
- typedef liblas::detail::Extents<double> result_type;
+ typedef liblas::Bounds result_type;
bbox_calculator() : empty(true) {}
@@ -48,24 +48,27 @@
// Box initialization during first iteration only
if (empty)
{
- bbox.min.x = bbox.max.x = p.GetX();
- bbox.min.y = bbox.max.y = p.GetY();
- bbox.min.z = bbox.max.z = p.GetZ();
+ bbox.min(0, p.GetX());
+ bbox.max(0, p.GetX());
+ bbox.min(1, p.GetY());
+ bbox.max(1, p.GetY());
+ bbox.min(2, p.GetZ());
+ bbox.max(2, p.GetZ());
empty = false;
}
// Expand bounding box to include given point
- bbox.min.x = std::min(bbox.min.x, p.GetX());
- bbox.min.y = std::min(bbox.min.y, p.GetY());
- bbox.min.z = std::min(bbox.min.z, p.GetZ());
- bbox.max.x = std::max(bbox.max.x, p.GetX());
- bbox.max.y = std::max(bbox.max.y, p.GetY());
- bbox.max.z = std::max(bbox.max.z, p.GetZ());
+ bbox.min(0, std::min(bbox.min(0), p.GetX()));
+ bbox.min(1, std::min(bbox.min(1), p.GetY()));
+ bbox.min(2, std::min(bbox.min(2), p.GetZ()));
+ bbox.max(0, std::max(bbox.max(0), p.GetX()));
+ bbox.max(1, std::max(bbox.max(1), p.GetY()));
+ bbox.max(2, std::max(bbox.max(2), p.GetZ()));
}
bool empty;
- liblas::detail::Extents<double> bbox;
+ liblas::Bounds bbox;
};
More information about the Liblas-commits
mailing list