[Liblas-commits] libpc: checkpoint - Schema work
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Feb 15 11:28:49 EST 2011
details: http://hg.liblas.orglibpc/rev/cf28d93f0b27
changeset: 54:cf28d93f0b27
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Feb 14 14:57:34 2011 -0800
description:
checkpoint - Schema work
Subject: libpc: checkpoint - schema work
details: http://hg.liblas.orglibpc/rev/9be53f618e67
changeset: 55:9be53f618e67
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Feb 14 17:33:43 2011 -0800
description:
checkpoint - schema work
Subject: libpc: added Vector, to back up Range and Bounds
details: http://hg.liblas.orglibpc/rev/4985de87a2fe
changeset: 56:4985de87a2fe
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Feb 14 18:25:48 2011 -0800
description:
added Vector, to back up Range and Bounds
Subject: libpc: added SpatialReference, Metadata; split out LasSchema
details: http://hg.liblas.orglibpc/rev/931718485dda
changeset: 57:931718485dda
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Feb 14 21:14:06 2011 -0800
description:
added SpatialReference, Metadata; split out LasSchema
diffstat:
apps/pc2pc.cpp | 52 ++-
include/libpc/Bounds.hpp | 149 +++---
include/libpc/CropFilter.hpp | 4 +-
include/libpc/Dimension.hpp | 221 ++++------
include/libpc/Field.hpp | 121 -----
include/libpc/Header.hpp | 25 +-
include/libpc/LasSchema.hpp | 91 ++++
include/libpc/Metadata.hpp | 79 +++
include/libpc/PointData.hpp | 15 +-
include/libpc/PointLayout.hpp | 91 ----
include/libpc/Range.hpp | 6 +
include/libpc/Schema.hpp | 139 +----
include/libpc/SpatialReference.hpp | 69 +++
include/libpc/Vector.hpp | 173 ++++++++
include/libpc/Writer.hpp | 2 +-
src/CMakeLists.txt | 13 +-
src/ColorFilter.cpp | 18 +-
src/CropFilter.cpp | 36 +-
src/Dimension.cpp | 283 ++++++++++---
src/FauxReader.cpp | 41 +-
src/FauxWriter.cpp | 4 +-
src/Field.cpp | 193 --------
src/Header.cpp | 65 ++-
src/LasSchema.cpp | 274 ++++++++++++
src/Metadata.cpp | 117 +++++
src/MosaicFilter.cpp | 4 +-
src/PointData.cpp | 92 +--
src/PointLayout.cpp | 162 -------
src/Schema.cpp | 795 +++++-------------------------------
src/SpatialReference.cpp | 98 ++++
src/Vector.cpp | 33 +
31 files changed, 1699 insertions(+), 1766 deletions(-)
diffs (truncated from 4294 to 300 lines):
diff -r 9ffe2a363128 -r 931718485dda apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Mon Feb 14 08:42:55 2011 -0800
+++ b/apps/pc2pc.cpp Mon Feb 14 21:14:06 2011 -0800
@@ -17,9 +17,53 @@
#include "libpc/Color.hpp"
#include "libpc/Dimension.hpp"
#include "libpc/Schema.hpp"
+#include "libpc/LasSchema.hpp"
+#include "libpc/CropFilter.hpp"
+#include "libpc/ColorFilter.hpp"
+#include "libpc/MosaicFilter.hpp"
+#include "libpc/FauxReader.hpp"
+#include "libpc/FauxWriter.hpp"
using namespace libpc;
+static void test1()
+{
+ // we are faking the reader, so we need to describe it here
+ // the faux reader only supports fields (X,Y,Z,T)
+ const Bounds<double> bounds(0, 0, -100, 200, 200, 100);
+ const int numPoints = 30;
+ FauxReader reader(bounds, numPoints);
+
+ CropFilter cropper(reader, Bounds<double>(0, 0, 0, 100, 100, 100));
+
+ ColorFilter colorizer(cropper);
+
+ FauxWriter writer(colorizer);
+
+ writer.write();
+
+ return;
+}
+
+
+static void test2()
+{
+ const int numPoints = 10;
+ const Bounds<double> bounds1(0, 0, 0, 100, 100, 100);
+ FauxReader reader1(bounds1, numPoints);
+
+ const Bounds<double> bounds2(100, 100, 100, 200, 200, 100);
+ FauxReader reader2(bounds2, numPoints);
+
+ MosaicFilter mosaicker(reader1, reader2);
+
+ FauxWriter writer(mosaicker);
+
+ writer.write();
+
+ return;
+}
+
int main(int, char* [])
{
@@ -40,17 +84,21 @@
}
{
- Dimension dim("foo", 8);
+ Dimension dim("foo", Dimension::uint8_t);
std::cout << dim << std::endl;
}
{
- Schema schema(ePointFormat0);
+ LasSchema schema(LasSchema::ePointFormat0);
std::cout << schema;
}
Color c;
+ test1();
+
+ test2();
+
return 0;
}
#if 0
diff -r 9ffe2a363128 -r 931718485dda include/libpc/Bounds.hpp
--- a/include/libpc/Bounds.hpp Mon Feb 14 08:42:55 2011 -0800
+++ b/include/libpc/Bounds.hpp Mon Feb 14 21:14:06 2011 -0800
@@ -42,6 +42,7 @@
#ifndef INCLUDED_BOUNDS_HPP
#define INCLUDED_BOUNDS_HPP
+#include <cassert>
#include <vector>
#include <iostream>
#include <sstream>
@@ -49,6 +50,7 @@
#include <stdexcept>
#include "libpc/export.hpp"
+#include "libpc/Vector.hpp"
#include "libpc/Range.hpp"
#include "libpc/Utils.hpp"
@@ -126,22 +128,22 @@
}
- ////Bounds( const Point& min, const Point& max)
- ////{
- //// m_ranges.resize(3);
- ////
- //// m_ranges[0].minimum = min.GetX();
- //// m_ranges[1].minimum = min.GetY();
- //// m_ranges[2].minimum = min.GetZ();
- ////
- //// m_ranges[0].maximum = max.GetX();
- //// m_ranges[1].maximum = max.GetY();
- //// m_ranges[2].maximum = max.GetZ();
- ////
- ////#ifdef DEBUG
- //// verify();
- ////#endif
- ////}
+ Bounds(const Vector<T>& minimum, const Vector<T>& maximum)
+ {
+ assert(minimum.size() == maximum.size());
+
+ m_ranges.resize(minimum.size());
+
+ for (std::size_t i=0; i<minimum.size(); i++)
+ {
+ m_ranges[i].setMinimum(minimum.vN(i));
+ m_ranges[i].setMaximum(maximum.vN(i));
+ }
+
+ #ifdef DEBUG
+ verify();
+ #endif
+ }
T minimum(std::size_t const& index) const
{
@@ -187,36 +189,29 @@
m_ranges[index].setMaximum(v);
}
- ////liblas::Point (min)() {
- //// liblas::Point p;
- //// try
- //// {
- //// p.SetCoordinates(m_ranges[0].minimum, m_ranges[1].minimum, m_ranges[2].minimum);
- //// }
- //// catch (std::runtime_error const& e)
- //// {
- //// ::boost::ignore_unused_variable_warning(e);
- //// p.SetCoordinates(m_ranges[0].minimum, m_ranges[1].minimum, 0);
- ////
- //// }
- ////
- //// return p;
- ////}
- ////
- ////liblas::Point (max)() {
- //// liblas::Point p;
- //// try
- //// {
- //// p.SetCoordinates(m_ranges[0].maximum, m_ranges[1].maximum, m_ranges[2].maximum);
- //// }
- //// catch (std::runtime_error const& e)
- //// {
- //// ::boost::ignore_unused_variable_warning(e);
- //// p.SetCoordinates(m_ranges[0].maximum, m_ranges[1].maximum, 0);
- ////
- //// }
- //// return p;
- ////}
+ Vector<T> getMinimum()
+ {
+ std::vector<T> vec;
+
+ for (std::size_t i=0; i<m_ranges.size(); i++)
+ {
+ vec.push_back(m_ranges[i].minimum());
+ }
+
+ return Vector<T>(vec);
+ }
+
+ Vector<T> getMaximum()
+ {
+ std::vector<T> vec;
+
+ for (std::size_t i=0; i<m_ranges.size(); i++)
+ {
+ vec.push_back(m_ranges[i].maximum());
+ }
+
+ return Vector<T>(vec);
+ }
inline bool operator==(Bounds<T> const& rhs) const
{
@@ -290,8 +285,23 @@
return intersects(other);
}
+ /// Does this Bounds contain a point?
+ bool contains(Vector<T> point) const
+ {
+ if (point.size() != size())
+ return false;
+
+ for (size_type i = 0; i < size(); i++)
+ {
+ // As soon as it is not contains, we're false
+ if (! m_ranges[i].contains(point.vN(i)) )
+ return false;
+ }
+ return true;
+ }
+
/// Does this Bounds contain other?
- bool contains(Bounds const& other) const
+ bool contains(Bounds<T> const& other) const
{
for (size_type i = 0; i < size(); i++)
{
@@ -302,37 +312,6 @@
return true;
}
- /////// Does this Bounds this point other?
- ////bool contains(Point const& point) const
- ////{
- //// // std::cout << m_ranges[0].length() << std::endl;
- //// // std::cout << "x contain: " << m_ranges[0].contains(point.GetX())
- //// // << " r.x.min: " << m_ranges[0].min
- //// // << " r.x.max: " << m_ranges[0].max
- //// // << " p.x: " << point.GetX() << std::endl;
- //// // std::cout << "y contain: " << m_ranges[1].contains(point.GetY())
- //// // << " r.y.min: " << m_ranges[1].min
- //// // << " r.y.max: " << m_ranges[1].max
- //// // << " p.y: " << point.GetY() << std::endl;
- //// // std::cout << "z contain: " << m_ranges[2].contains(point.GetZ())
- //// // << " r.z.min: " << m_ranges[2].min
- //// // << " r.z.max: " << m_ranges[2].max
- //// // << " p.z: " << point.GetZ() << std::endl;
- //// if (!m_ranges[0].contains(point.GetX()))
- //// return false;
- //// if (!m_ranges[1].contains(point.GetY()))
- //// return false;
- ////
- //// // If our z bounds has no length, we'll say it's contained anyway.
- //// if (!m_ranges[2].contains(point.GetZ()))
- //// {
- //// if (detail::compare_distance(m_ranges[2].length(), 0.0))
- //// return true;
- //// return false;
- //// }
- //// return true;
- ////}
-
/// Shift each dimension by a vector of detlas
void shift(std::vector<T> deltas)
{
@@ -392,12 +371,14 @@
}
/// Expand the liblas::Bounds to include this point
- ////void grow(Point const& p)
- ////{
- //// m_ranges[0].grow(p.GetX());
- //// m_ranges[1].grow(p.GetY());
- //// m_ranges[2].grow(p.GetZ());
- ////}
+ void grow(Vector<T> const& point)
+ {
+ assert(point.size() == size());
+ for (size_type i = 0; i < size(); ++i)
+ {
+ m_ranges[i].grow(point.vN(i));
+ }
+ }
T volume() const
{
diff -r 9ffe2a363128 -r 931718485dda include/libpc/CropFilter.hpp
--- a/include/libpc/CropFilter.hpp Mon Feb 14 08:42:55 2011 -0800
+++ b/include/libpc/CropFilter.hpp Mon Feb 14 21:14:06 2011 -0800
@@ -47,9 +47,9 @@
class LIBPC_DLL CropFilter : public Filter
{
public:
- CropFilter(Stage& prevStage, const Bounds<double>& bounds);
+ CropFilter(Stage& prevStage, Bounds<double> const& bounds);
- void readNextPoints(PointData&);
+ void readPoints(PointData&);
private:
Bounds<double> m_bounds;
diff -r 9ffe2a363128 -r 931718485dda include/libpc/Dimension.hpp
--- a/include/libpc/Dimension.hpp Mon Feb 14 08:42:55 2011 -0800
More information about the Liblas-commits
mailing list