~ubuntu-branches/ubuntu/trusty/liblas/trusty-proposed

« back to all changes in this revision

Viewing changes to apps/ts2las.hpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2014-01-05 17:00:29 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140105170029-ddtp0j63x5jvck2u
Tags: 1.7.0+dfsg-2
Fixed missing linking of system boost component.
(closes: #733282)

Show diffs side-by-side

added added

removed removed

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