[Liblas-commits] hg: remove extraneous
liblas::Point::SetCoordinates method now t...
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Jul 28 12:51:06 EDT 2010
changeset fc5d19cd8859 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=fc5d19cd8859
summary: remove extraneous liblas::Point::SetCoordinates method now that liblas::Point has a reference to its header. Remove copy of Schema attached to liblas::detail::reader::Point and get it from its header reference.
diffstat:
include/liblas/detail/reader/point.hpp | 3 ---
include/liblas/laspoint.hpp | 17 ++++++++---------
src/detail/reader/point.cpp | 26 +++++++++++++++-----------
src/laspoint.cpp | 26 +++++++++++++++++++++-----
4 files changed, 44 insertions(+), 28 deletions(-)
diffs (200 lines):
diff -r 270605152ed9 -r fc5d19cd8859 include/liblas/detail/reader/point.hpp
--- a/include/liblas/detail/reader/point.hpp Wed Jul 28 11:00:14 2010 -0500
+++ b/include/liblas/detail/reader/point.hpp Wed Jul 28 11:51:00 2010 -0500
@@ -72,7 +72,6 @@
typedef std::istream::off_type off_type;
typedef std::istream::pos_type pos_type;
-
private:
// Blocked copying operations, declared but not defined.
@@ -83,8 +82,6 @@
HeaderPtr m_header;
PointPtr m_point;
- Schema m_format;
-
void setup();
void fill(PointRecord& record);
};
diff -r 270605152ed9 -r fc5d19cd8859 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp Wed Jul 28 11:00:14 2010 -0500
+++ b/include/liblas/laspoint.hpp Wed Jul 28 11:51:00 2010 -0500
@@ -113,7 +113,7 @@
double GetY() const;
double GetZ() const;
void SetCoordinates(double const& x, double const& y, double const& z);
- void SetCoordinates(Header const& header, double x, double y, double z);
+ // void SetCoordinates(Header const& header, double x, double y, double z);
void SetX(double const& value);
void SetY(double const& value);
@@ -193,7 +193,7 @@
bool Validate() const;
bool IsValid() const;
- std::vector<liblas::uint8_t> const& GetExtraData() const {return m_extra_data; }
+ std::vector<liblas::uint8_t> const& GetExtraData() const { return m_extra_data; }
void SetExtraData(std::vector<uint8_t> const& v) { m_extra_data = v;}
std::vector<liblas::uint8_t> const& GetData() const {return m_format_data; }
@@ -239,12 +239,12 @@
return (!(lhs == rhs));
}
-inline void Point::SetCoordinates(double const& x, double const& y, double const& z)
-{
- m_coords[0] = x;
- m_coords[1] = y;
- m_coords[2] = z;
-}
+// inline void Point::SetCoordinates(double const& x, double const& y, double const& z)
+// {
+// m_coords[0] = x;
+// m_coords[1] = y;
+// m_coords[2] = z;
+// }
inline double Point::GetX() const
{
@@ -360,7 +360,6 @@
m_color = value;
}
-
inline double& Point::operator[](std::size_t const& n)
{
if (coords_size <= n)
diff -r 270605152ed9 -r fc5d19cd8859 src/detail/reader/point.cpp
--- a/src/detail/reader/point.cpp Wed Jul 28 11:00:14 2010 -0500
+++ b/src/detail/reader/point.cpp Wed Jul 28 11:51:00 2010 -0500
@@ -55,7 +55,7 @@
}
Point::Point(std::istream& ifs, HeaderPtr header) :
- m_ifs(ifs), m_header(header), m_point(new liblas::Point()), m_format(header->GetSchema())
+ m_ifs(ifs), m_header(header), m_point(new liblas::Point())
{
setup();
}
@@ -85,14 +85,18 @@
// raw byte data necessary to fill out the point format
std::vector<uint8_t> format_data;
- format_data.resize(m_format.GetBaseByteSize());
+ format_data.resize(m_header->GetSchema().GetBaseByteSize());
detail::PointRecord record;
// TODO: Replace with compile-time assert
assert(liblas::ePointSize0 == sizeof(record));
-
+ // Set the header for the point early because
+ // SetCoordinates will use it later to scale the
+ // point
+ m_point->SetHeader(m_header);
+
try
{
detail::read_n(record, m_ifs, sizeof(PointRecord));
@@ -105,16 +109,16 @@
fill(record);
// Reader::FillPoint(record, m_point, m_header);
- m_point->SetCoordinates(*m_header, m_point->GetX(), m_point->GetY(), m_point->GetZ());
+ m_point->SetCoordinates(m_point->GetX(), m_point->GetY(), m_point->GetZ());
- if (m_format.HasTime())
+ if (m_header->GetSchema().HasTime())
{
detail::read_n(gpst, m_ifs, sizeof(double));
m_point->SetTime(gpst);
bytesread += sizeof(double);
- if (m_format.HasColor())
+ if (m_header->GetSchema().HasColor())
{
detail::read_n(red, m_ifs, sizeof(uint16_t));
detail::read_n(green, m_ifs, sizeof(uint16_t));
@@ -126,7 +130,7 @@
bytesread += 3 * sizeof(uint16_t);
}
} else {
- if (m_format.HasColor())
+ if (m_header->GetSchema().HasColor())
{
detail::read_n(red, m_ifs, sizeof(uint16_t));
detail::read_n(green, m_ifs, sizeof(uint16_t));
@@ -140,7 +144,7 @@
}
- if (m_format.GetBaseByteSize() != m_format.GetByteSize())
+ if (m_header->GetSchema().GetBaseByteSize() != m_header->GetSchema().GetByteSize())
{
std::size_t bytesleft = m_header->GetDataRecordLength() - bytesread;
@@ -155,17 +159,17 @@
}
- if (bytesread != m_format.GetByteSize()) {
+ if (bytesread != m_header->GetSchema().GetByteSize()) {
std::ostringstream msg;
msg << "The number of bytes that were read ("<< bytesread <<") does not "
"match the number of bytes the point's format "
"says it should have (" <<
- m_format.GetByteSize() << ")";
+ m_header->GetSchema().GetByteSize() << ")";
throw std::runtime_error(msg.str());
}
- m_point->SetHeader(m_header);
+
}
diff -r 270605152ed9 -r fc5d19cd8859 src/laspoint.cpp
--- a/src/laspoint.cpp Wed Jul 28 11:00:14 2010 -0500
+++ b/src/laspoint.cpp Wed Jul 28 11:51:00 2010 -0500
@@ -102,15 +102,31 @@
return *this;
}
-void Point::SetCoordinates(Header const& header, double x, double y, double z)
+// void Point::SetCoordinates(Header const& header, double x, double y, double z)
+// {
+// double const cx = (x * header.GetScaleX()) + header.GetOffsetX();
+// double const cy = (y * header.GetScaleY()) + header.GetOffsetY();
+// double const cz = (z * header.GetScaleZ()) + header.GetOffsetZ();
+//
+// SetCoordinates(cx, cy, cz);
+// }
+
+void Point::SetCoordinates(double const& x, double const& y, double const& z)
{
- double const cx = (x * header.GetScaleX()) + header.GetOffsetX();
- double const cy = (y * header.GetScaleY()) + header.GetOffsetY();
- double const cz = (z * header.GetScaleZ()) + header.GetOffsetZ();
+ if (m_hdr.get() != 0 ) {
+ m_coords[0] = (x * m_hdr->GetScaleX()) + m_hdr->GetOffsetX();
+ m_coords[1] = (y * m_hdr->GetScaleY()) + m_hdr->GetOffsetY();
+ m_coords[2] = (z * m_hdr->GetScaleZ()) + m_hdr->GetOffsetZ();
+
+ } else {
+ m_coords[0] = x;
+ m_coords[1] = y;
+ m_coords[2] = z;
+ }
- SetCoordinates(cx, cy, cz);
}
+
void Point::SetReturnNumber(uint16_t const& num)
{
// Store value in bits 0,1,2
More information about the Liblas-commits
mailing list