[Liblas-commits] libpc: boost I/O fix
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Feb 16 17:23:04 EST 2011
details: http://hg.liblas.orglibpc/rev/ea5f8fd7eb39
changeset: 63:ea5f8fd7eb39
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Feb 16 13:38:01 2011 -0800
description:
boost I/O fix
Subject: libpc: debugging
details: http://hg.liblas.orglibpc/rev/68f9d8765824
changeset: 64:68f9d8765824
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Feb 16 13:38:24 2011 -0800
description:
debugging
Subject: libpc: checkpoint - las writing
details: http://hg.liblas.orglibpc/rev/3f400151fa35
changeset: 65:3f400151fa35
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Feb 16 14:22:44 2011 -0800
description:
checkpoint - las writing
diffstat:
apps/pc2pc.cpp | 16 +-
include/libpc/LasHeader.hpp | 24 +-
include/libpc/LasHeaderReader.hpp | 76 +++
include/libpc/LasHeaderWriter.hpp | 74 +++
include/libpc/LasWriter.hpp | 6 +-
include/libpc/Utils.hpp | 3 +-
include/libpc/Vector.hpp | 6 +-
src/CMakeLists.txt | 4 +
src/LasHeader.cpp | 733 +-------------------------------------
src/LasHeaderReader.cpp | 454 +++++++++++++++++++++++
src/LasHeaderWriter.cpp | 398 ++++++++++++++++++++
src/LasReader.cpp | 7 +-
src/LasWriter.cpp | 133 ++++++-
src/Utils.cpp | 12 +-
src/Writer.cpp | 24 +-
15 files changed, 1189 insertions(+), 781 deletions(-)
diffs (truncated from 2235 to 300 lines):
diff -r 9ec62d76b00f -r 3f400151fa35 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Tue Feb 15 17:25:48 2011 -0800
+++ b/apps/pc2pc.cpp Wed Feb 16 14:22:44 2011 -0800
@@ -24,6 +24,7 @@
#include "libpc/FauxWriter.hpp"
#include "libpc/LasReader.hpp"
#include "libpc/LasHeader.hpp"
+#include "libpc/LasWriter.hpp"
using namespace libpc;
@@ -77,21 +78,20 @@
std::cout << (const LasHeader&)header;
- boost::uint32_t numPoints = (boost::uint32_t)header.getNumPoints();
- PointData pointData(header.getSchema(), numPoints);
- reader.readPoints(pointData);
+ //boost::uint32_t numPoints = (boost::uint32_t)header.getNumPoints();
+ //PointData pointData(header.getSchema(), numPoints);
+ //reader.readPoints(pointData);
// std::cout << pointData;
std::ostream* ofs = Utils::Create("temp.las");
- ((LasHeader&)header).write(*ofs);
+ LasWriter lasWriter(reader, *ofs);
+ lasWriter.write();
- ofs->flush();
- delete ofs;
+ Utils::Cleanup(ofs);
-// Utils::Cleanup(ifs);
-// Utils::Cleanup(ofs);
+ Utils::Cleanup(ifs);
return;
}
diff -r 9ec62d76b00f -r 3f400151fa35 include/libpc/LasHeader.hpp
--- a/include/libpc/LasHeader.hpp Tue Feb 15 17:25:48 2011 -0800
+++ b/include/libpc/LasHeader.hpp Wed Feb 16 14:22:44 2011 -0800
@@ -57,8 +57,6 @@
class LIBPC_DLL LasHeader : public Header
{
public:
- typedef boost::uuids::uuid uuid;
-
/// Versions of point record format.
enum PointFormatId
{
@@ -155,10 +153,10 @@
/// Get project identifier.
/// \return Global Unique Identifier as an instance of liblas::guid class.
- uuid GetProjectId() const;
+ boost::uuids::uuid GetProjectId() const;
/// Set project identifier.
- void SetProjectId(uuid const& v);
+ void SetProjectId(boost::uuids::uuid const& v);
/// Get major component of version of LAS format.
/// \return Always 1 is returned as the only valid value.
@@ -352,11 +350,10 @@
//void to_rst(std::ostream& os) const;
//void to_xml(std::ostream& os) const;
//void to_json(std::ostream& os) const;
+
+ // used by LasHeaderReader
+ static void update_required_dimensions(PointFormatId data_format_id, Schema&);
-
- void read(std::istream&);
- void write(std::ostream&);
-
private:
typedef Vector<double> PointScales;
typedef Vector<double> PointOffsets;
@@ -378,26 +375,17 @@
// TODO (low-priority): replace static-size char arrays
// with std::string and return const-reference to string object.
- bool HasLAS10PadSignature(std::istream& ifs);
- void ReadVLRs(std::istream& ifs);
- void Validate(std::istream& ifs);
-
- static void update_required_dimensions(PointFormatId data_format_id, Schema&);
static void add_record0_dimensions(Schema& schema);
static void add_time(Schema& schema);
static void add_color(Schema& schema);
- void WriteLAS10PadSignature(std::ostream& ostream);
- boost::int32_t GetRequiredHeaderSize(std::ostream& ostream) const;
- void WriteVLRs(std::ostream& ostream);
-
//
// Private data members
//
char m_signature[eFileSignatureSize]; // TODO: replace with boost::array --mloskot
boost::uint16_t m_sourceId;
boost::uint16_t m_reserved;
- uuid m_projectGuid;
+ boost::uuids::uuid m_projectGuid;
boost::uint8_t m_versionMajor;
boost::uint8_t m_versionMinor;
char m_systemId[eSystemIdSize]; // TODO: replace with boost::array --mloskot
diff -r 9ec62d76b00f -r 3f400151fa35 include/libpc/LasHeaderReader.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/LasHeaderReader.hpp Wed Feb 16 14:22:44 2011 -0800
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: LAS header class
+ * Author: Mateusz Loskot, mateusz at loskot.net
+ *
+ ******************************************************************************
+ * Copyright (c) 2008, Mateusz Loskot
+ * Copyright (c) 2008, Phil Vachon
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Martin Isenburg or Iowa Department
+ * of Natural Resources nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+
+#ifndef INCLUDED_LASHEADERREADER_HPP
+#define INCLUDED_LASHEADERREADER_HPP
+
+#include <iostream>
+
+#include "libpc/LasHeader.hpp"
+
+
+namespace libpc
+{
+
+class LIBPC_DLL LasHeaderReader
+{
+public:
+ LasHeaderReader(LasHeader& header, std::istream& istream);
+
+ void read();
+
+private:
+ LasHeader& m_header;
+ std::istream& m_istream;
+
+ bool HasLAS10PadSignature();
+ void ReadVLRs();
+ void Validate();
+
+ LasHeaderReader& operator=(const LasHeaderReader&); // nope
+ LasHeaderReader(const LasHeaderReader&); // nope
+};
+
+
+} // namespace libpc
+
+#endif
diff -r 9ec62d76b00f -r 3f400151fa35 include/libpc/LasHeaderWriter.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/LasHeaderWriter.hpp Wed Feb 16 14:22:44 2011 -0800
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
+ * Purpose: LAS header class
+ * Author: Mateusz Loskot, mateusz at loskot.net
+ *
+ ******************************************************************************
+ * Copyright (c) 2008, Mateusz Loskot
+ * Copyright (c) 2008, Phil Vachon
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the Martin Isenburg or Iowa Department
+ * of Natural Resources nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+
+#ifndef INCLUDED_LASHEADERWRITER_HPP
+#define INCLUDED_LASHEADERWRITER_HPP
+
+#include <iostream>
+
+#include "libpc/LasHeader.hpp"
+
+namespace libpc
+{
+
+class LIBPC_DLL LasHeaderWriter
+{
+public:
+ LasHeaderWriter(LasHeader& header, std::ostream&);
+ void write();
+
+private:
+ void WriteLAS10PadSignature();
+ std::size_t GetRequiredHeaderSize() const;
+ void WriteVLRs();
+
+ LasHeader& m_header; // BUG: I want this to be const
+ std::ostream& m_ostream;
+
+ LasHeaderWriter& operator=(const LasHeaderWriter&); // nope
+ LasHeaderWriter(const LasHeaderWriter&); // nope
+};
+
+
+} // namespace libpc
+
+#endif
diff -r 9ec62d76b00f -r 3f400151fa35 include/libpc/LasWriter.hpp
--- a/include/libpc/LasWriter.hpp Tue Feb 15 17:25:48 2011 -0800
+++ b/include/libpc/LasWriter.hpp Wed Feb 16 14:22:44 2011 -0800
@@ -43,9 +43,9 @@
class LIBPC_DLL LasWriter : public Writer
{
public:
- LasWriter(Stage& prevStage);
+ LasWriter(Stage& prevStage, std::ostream&);
- void write();
+ //void write();
protected:
// this is called once before the loop with the writeBuffer calls
@@ -64,6 +64,8 @@
throw;
}
+ std::ostream& m_ostream;
+
LasWriter& operator=(const LasWriter&); // not implemented
LasWriter(const LasWriter&); // not implemented
};
diff -r 9ec62d76b00f -r 3f400151fa35 include/libpc/Utils.hpp
--- a/include/libpc/Utils.hpp Tue Feb 15 17:25:48 2011 -0800
+++ b/include/libpc/Utils.hpp Wed Feb 16 14:22:44 2011 -0800
@@ -94,7 +94,8 @@
T& tmp = const_cast<T&>(src);
//LIBLAS_SWAP_BYTES_N(tmp, num);
- dest.write(as_bytes(tmp), num);
+ char const* p = as_bytes(tmp);
+ dest.write(p, num);
More information about the Liblas-commits
mailing list