1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
#ifndef TS2LAS_HPP_INCLUDED
#include <liblas/detail/private_utility.hpp>
#include <liblas/liblas.hpp>
#include <iostream>
#ifdef _WIN32
#define compare_no_case(a,b,n) _strnicmp( (a), (b), (n) )
#else
#define compare_no_case(a,b,n) strncasecmp( (a), (b), (n) )
#endif
using namespace liblas;
struct ScanRow
{
ScanRow() :
Code(0),
Line(0),
EchoInt(0),
x(0),
y(0),
z(0)
{}
boost::uint8_t Code;
boost::uint8_t Line;
boost::uint16_t EchoInt;
boost::int32_t x;
boost::int32_t y;
boost::int32_t z;
};
struct Point3d
{
Point3d() :
x(0),
y(0),
z(0)
{}
boost::int32_t x;
boost::int32_t y;
boost::int32_t z;
};
struct ScanPnt
{
ScanPnt() :
Code(0),
Echo(0),
Flag(0),
Mark(0),
Line(0),
Intensity(0)
{}
Point3d Pnt;
boost::uint8_t Code;
boost::uint8_t Echo;
boost::uint8_t Flag;
boost::uint8_t Mark;
boost::uint16_t Line;
boost::uint16_t Intensity;
};
struct ScanHdr
{
ScanHdr() :
HdrSize(0),
HdrVersion(0),
Tunniste(0),
PntCnt(0),
Units(0),
OrgX(0),
OrgY(0),
OrgZ(0),
Time(0),
Color(0)
{}
boost::int32_t HdrSize;
boost::int32_t HdrVersion;
boost::int32_t Tunniste;
char Magic[4];
boost::int32_t PntCnt;
boost::int32_t Units;
double OrgX;
double OrgY;
double OrgZ;
boost::int32_t Time;
boost::int32_t Color;
//
// int HdrSize;
// int HdrVersion;
// int Tunniste;
// char Magic[4];
// int PntCnt;
// int Units;
// double OrgX;
// double OrgY;
// double OrgZ;
// int Time;
// int Color;
};
namespace liblas { namespace detail {
template <>
inline void read_n <ScanRow>(ScanRow& dest, std::istream& src, std::streamsize const& num)
{
// TODO: Review and redesign errors handling logic if necessary
if (!src)
throw std::runtime_error("detail::liblas::read_n<ScanRow> input stream is not readable");
src.read(detail::as_buffer(dest), num);
detail::check_stream_state(src);
// Fix little-endian
LIBLAS_SWAP_BYTES(dest.x);
LIBLAS_SWAP_BYTES(dest.y);
LIBLAS_SWAP_BYTES(dest.z);
LIBLAS_SWAP_BYTES(dest.Code);
LIBLAS_SWAP_BYTES(dest.Line);
LIBLAS_SWAP_BYTES(dest.EchoInt);
}
template <>
inline void read_n <ScanPnt>(ScanPnt& dest, std::istream& src, std::streamsize const& num)
{
// TODO: Review and redesign errors handling logic if necessary
if (!src)
throw std::runtime_error("detail::liblas::read_n<ScanPnt> input stream is not readable");
src.read(detail::as_buffer(dest), num);
detail::check_stream_state(src);
// Fix little-endian
LIBLAS_SWAP_BYTES(dest.Pnt.x);
LIBLAS_SWAP_BYTES(dest.Pnt.y);
LIBLAS_SWAP_BYTES(dest.Pnt.z);
LIBLAS_SWAP_BYTES(dest.Code);
LIBLAS_SWAP_BYTES(dest.Echo);
LIBLAS_SWAP_BYTES(dest.Flag);
LIBLAS_SWAP_BYTES(dest.Mark);
LIBLAS_SWAP_BYTES(dest.Line);
LIBLAS_SWAP_BYTES(dest.Intensity);
}
template <>
inline void read_n <ScanHdr>(ScanHdr& dest, std::istream& src, std::streamsize const& num)
{
// TODO: Review and redesign errors handling logic if necessary
if (!src)
throw std::runtime_error("detail::liblas::read_n<ScanHdr> input stream is not readable");
src.read(detail::as_buffer(dest), num);
detail::check_stream_state(src);
// Fix little-endian
LIBLAS_SWAP_BYTES(dest.HdrSize);
LIBLAS_SWAP_BYTES(dest.HdrVersion);
LIBLAS_SWAP_BYTES(dest.Tunniste);
LIBLAS_SWAP_BYTES(dest.Magic);
LIBLAS_SWAP_BYTES(dest.PntCnt);
LIBLAS_SWAP_BYTES(dest.Units);
LIBLAS_SWAP_BYTES(dest.Time);
LIBLAS_SWAP_BYTES(dest.Color);
}
}} // namespace liblas::detail
#endif // TS2LAS_HPP_INCLUDED
|