[Liblas-commits] libpc: bunch of unit test work
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Feb 23 11:39:41 EST 2011
details: http://hg.liblas.orglibpc/rev/925d511b465c
changeset: 73:925d511b465c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Feb 22 10:38:12 2011 -0800
description:
bunch of unit test work
Subject: libpc: checkpoint
details: http://hg.liblas.orglibpc/rev/5bed80c7c3cd
changeset: 74:5bed80c7c3cd
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Feb 22 13:49:03 2011 -0800
description:
checkpoint
Subject: libpc: more unit tests
details: http://hg.liblas.orglibpc/rev/c6e80ef5f98c
changeset: 75:c6e80ef5f98c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Feb 23 08:39:29 2011 -0800
description:
more unit tests
diffstat:
.hgignore | 2 +
apps/pc2pc.cpp | 10 +-
include/libpc/Bounds.hpp | 44 +++---
include/libpc/Color.hpp | 12 +-
include/libpc/Dimension.hpp | 100 +++++++++------
include/libpc/PointData.hpp | 20 +-
include/libpc/Range.hpp | 7 +
include/libpc/Schema.hpp | 60 ++++++++-
include/libpc/Utils.hpp | 48 +++++--
include/libpc/Vector.hpp | 6 +-
mpg-config.bat | 6 +-
src/Color.cpp | 6 +-
src/ColorFilter.cpp | 9 +-
src/CropFilter.cpp | 3 +-
src/Dimension.cpp | 271 ++++++++++++++++++++++++++++---------------
src/FauxReader.cpp | 11 +-
src/Header.cpp | 2 +-
src/LasHeader.cpp | 53 ++++----
src/LasReader.cpp | 38 ++---
src/LasWriter.cpp | 38 ++---
src/MosaicFilter.cpp | 8 +-
src/PointData.cpp | 78 ++++++++----
src/Schema.cpp | 183 ++++++++++++++++++++++------
src/Utils.cpp | 48 +++++++-
test/unit/BoundsTest.cpp | 103 ++++++++++++++++-
test/unit/CMakeLists.txt | 5 +
test/unit/ColorTest.cpp | 54 ++++++++
test/unit/DimensionTest.cpp | 60 +++++++++
test/unit/PointDataTest.cpp | 135 +++++++++++++++++++++
test/unit/RangeTest.cpp | 11 +-
test/unit/SchemaTest.cpp | 84 +++++++++++++
test/unit/UtilsTest.cpp | 135 +++++++++++++++++++++
test/unit/VectorTest.cpp | 13 +-
33 files changed, 1289 insertions(+), 374 deletions(-)
diffs (truncated from 2680 to 300 lines):
diff -r 674deb620627 -r c6e80ef5f98c .hgignore
--- a/.hgignore Mon Feb 21 08:59:21 2011 -0800
+++ b/.hgignore Wed Feb 23 08:39:29 2011 -0800
@@ -1,5 +1,7 @@
syntax: glob
+libpc_defines.h
+
# rst outputs
*.pdf
diff -r 674deb620627 -r c6e80ef5f98c apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Mon Feb 21 08:59:21 2011 -0800
+++ b/apps/pc2pc.cpp Wed Feb 23 08:39:29 2011 -0800
@@ -69,7 +69,7 @@
static void test3()
{
- std::istream* ifs = Utils::Open("test/data/1.2-with-color.las");
+ std::istream* ifs = Utils::openFile("test/data/1.2-with-color.las");
LasReader reader(*ifs);
@@ -77,14 +77,14 @@
std::cout << (const LasHeader&)header;
- std::ostream* ofs = Utils::Create("temp.las");
+ std::ostream* ofs = Utils::createFile("temp.las");
LasWriter lasWriter(reader, *ofs);
lasWriter.write();
- Utils::Cleanup(ofs);
+ Utils::closeFile(ofs);
- Utils::Cleanup(ifs);
+ Utils::closeFile(ifs);
return;
}
@@ -114,7 +114,7 @@
}
{
- Dimension dim("foo", Dimension::uint8_t);
+ Dimension dim("foo", Dimension::Uint8);
std::cout << dim << std::endl;
}
diff -r 674deb620627 -r c6e80ef5f98c include/libpc/Bounds.hpp
--- a/include/libpc/Bounds.hpp Mon Feb 21 08:59:21 2011 -0800
+++ b/include/libpc/Bounds.hpp Wed Feb 23 08:39:29 2011 -0800
@@ -236,29 +236,30 @@
return m_ranges.size();
}
- ///// Resize the dimensionality of the Bounds to d
- //void resize(size_type d)
- //{
- // if (m_ranges.size() < d)
- // {
- // m_ranges.resize(d);
- // }
- //}
-
/// Is this Bounds equal to other?
bool equal(Bounds<T> const& other) const
{
+ if (size() != other.size())
+ {
+ return false;
+ }
for (std::size_t i = 0; i < size(); i++)
{
- if ( m_ranges[i] != other.m_ranges[i] )
+ if (m_ranges[i] != other.m_ranges[i])
+ {
return false;
+ }
}
return true;
}
- /// Does this Bounds intersect other?
- bool intersects(Bounds const& other) const
+ /// Synonym for intersects for now
+ bool overlaps(Bounds const& other) const
{
+ if (other.size() != size())
+ {
+ return false;
+ }
for (std::size_t i = 0; i < size(); i++)
{
@@ -267,13 +268,6 @@
}
return false;
-
- }
-
- /// Synonym for intersects for now
- bool overlaps(Bounds const& other) const
- {
- return intersects(other);
}
/// Does this Bounds contain a point?
@@ -303,11 +297,11 @@
return true;
}
- /// Shift each dimension by a vector of detlas
+ /// Shift each dimension by a vector of deltas
void shift(std::vector<T> deltas)
{
std::size_t i;
- if( size() <= deltas.size())
+ if( size() != deltas.size())
{
std::ostringstream msg;
msg << "liblas::Bounds::shift: Delta vector size, " << deltas.size()
@@ -324,7 +318,7 @@
void scale(std::vector<T> deltas)
{
std::size_t i;
- if( size() <= deltas.size())
+ if( size() != deltas.size())
{
std::ostringstream msg;
msg << "liblas::Bounds::scale: Delta vector size, " << deltas.size()
@@ -369,7 +363,7 @@
T volume() const
{
- T output = T();
+ T output = T(1);
for (std::size_t i = 0; i < size(); i++)
{
output = output * m_ranges[i].length();
@@ -430,12 +424,14 @@
template<class T>
std::ostream& operator<<(std::ostream& ostr, const Bounds<T>& bounds)
{
+ ostr << "(";
for (std::size_t d = 0; d < bounds.size(); ++d)
{
const Range<T>& r = bounds.dimensions()[d];
- ostr << "[" << r.getMinimum() << ", " << r.getMaximum() << "]";
+ ostr << r;
if (d!=bounds.size()-1) ostr << ", ";
}
+ ostr << ")";
return ostr;
}
diff -r 674deb620627 -r c6e80ef5f98c include/libpc/Color.hpp
--- a/include/libpc/Color.hpp Mon Feb 21 08:59:21 2011 -0800
+++ b/include/libpc/Color.hpp Wed Feb 23 08:39:29 2011 -0800
@@ -78,37 +78,37 @@
Color& operator=(Color const& rhs);
/// Fetch value of the red image channel
- value_type GetRed() const
+ value_type getRed() const
{
return m_color[0];
}
/// Set value of the red image channel
- void SetRed(value_type const& value)
+ void setRed(value_type const& value)
{
m_color[0] = value;
}
/// Fetch value of the green image channel
- value_type GetGreen() const
+ value_type getGreen() const
{
return m_color[1];
}
/// Set value of the red image channel
- void SetGreen(value_type const& value)
+ void setGreen(value_type const& value)
{
m_color[1] = value;
}
/// Fetch value of the blue image channel
- value_type GetBlue() const
+ value_type getBlue() const
{
return m_color[2];
}
/// Set value of the blue image channel
- void SetBlue(value_type const& value)
+ void setBlue(value_type const& value)
{
m_color[2] = value;
}
diff -r 674deb620627 -r c6e80ef5f98c include/libpc/Dimension.hpp
--- a/include/libpc/Dimension.hpp Mon Feb 21 08:59:21 2011 -0800
+++ b/include/libpc/Dimension.hpp Wed Feb 23 08:39:29 2011 -0800
@@ -66,16 +66,16 @@
public:
enum DataType
{
- int8_t,
- uint8_t,
- int16_t,
- uint16_t,
- int32_t,
- uint32_t,
- int64_t,
- uint64_t,
- float_t, // 32 bits
- double_t // 64 bits
+ Int8,
+ Uint8,
+ Int16,
+ Uint16,
+ Int32,
+ Uint32,
+ Int64,
+ Uint64,
+ Float, // 32 bits
+ Double // 64 bits
};
public:
@@ -84,8 +84,7 @@
Dimension(Dimension const& other);
bool operator==(const Dimension& other) const;
-
- virtual ~Dimension() {}
+ bool operator!=(const Dimension& other) const;
inline std::string const& getName() const
{
@@ -111,20 +110,6 @@
return m_byteSize;
}
- /// The byte location to start reading/writing
- /// point data from in a composited schema. liblas::Schema
- /// will set these values for you when liblas::Dimension are
- /// added to the liblas::Schema.
- inline std::size_t getByteOffset() const
- {
- return m_byteOffset;
- }
-
- inline void setByteOffset(std::size_t v)
- {
- m_byteOffset = v;
- }
-
inline std::string getDescription() const
{
return m_description;
@@ -175,19 +160,6 @@
m_max = max;
}
- /// The index position of the index. In a standard ePointFormat0
- /// data record, the X dimension would have a position of 0, while
- /// the Y dimension would have a position of 1, for example.
- inline std::size_t getPosition() const
- {
- return m_position;
- }
-
- inline void setPosition(std::size_t v)
- {
- m_position = v;
- }
-
/// The scaling value for this dimension as a double. This should
/// be positive or negative powers of ten.
inline double getNumericScale() const
@@ -229,17 +201,63 @@
DataType m_dataType;
std::string m_name;
std::size_t m_byteSize;
- std::size_t m_byteOffset;
std::string m_description;
double m_min;
double m_max;
- std::size_t m_position;
bool m_precise;
double m_numericScale;
double m_numericOffset;
};
More information about the Liblas-commits
mailing list