OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimLasPointRecord2.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // File: ossimLasPointRecord2.cpp
4 //
5 // License: MIT
6 //
7 // See LICENSE.txt file in the top level directory for more details.
8 //
9 // Author: Garrett Potts
10 //
11 // Description: Container class LAS point record type 2.
12 //
13 //----------------------------------------------------------------------------
14 // $Id$
15 
17 #include <ossim/base/ossimCommon.h>
18 #include <ossim/base/ossimEndian.h>
19 #include <iomanip>
20 #include <iostream>
21 #include <istream>
22 #include <ostream>
23 
25  :
26  m_x(0),
27  m_y(0),
28  m_z(0),
29  m_intensity(0),
30  m_bitFlags(0),
31  m_classification(0),
32  m_scanAngleRank(0),
33  m_userData(0),
34  m_pointSourceId(0),
35  m_red(0),
36  m_green(0),
37  m_blue(0)
38 {
39 }
40 
43  :
44  m_x(obj.m_x),
45  m_y(obj.m_y),
46  m_z(obj.m_z),
47  m_intensity(obj.m_intensity),
48  m_bitFlags(obj.m_bitFlags),
49  m_classification(obj.m_classification),
50  m_scanAngleRank(obj.m_scanAngleRank),
51  m_userData(obj.m_userData),
52  m_pointSourceId(obj.m_pointSourceId),
53  m_red(obj.m_red),
54  m_green(obj.m_green),
55  m_blue(obj.m_blue)
56 {
57 }
58 
62 {
63  if ( this != &obj )
64  {
65  m_x = obj.m_x;
66  m_y = obj.m_y;
67  m_z = obj.m_z;
68  m_intensity = obj.m_intensity;
69  m_bitFlags = obj.m_bitFlags;
70  m_classification = obj.m_classification;
71  m_scanAngleRank = obj.m_scanAngleRank;
72  m_userData = obj.m_userData;
73  m_pointSourceId = obj.m_pointSourceId;
74  m_red = obj.m_red;
75  m_green = obj.m_green;
76  m_blue = obj.m_blue;
77  }
78  return *this;
79 }
80 
82  :
83  m_record()
84 {
85 }
86 
88  :
89  m_record(obj.m_record)
90 {
91 }
92 
94 {
95  if (this != &copy_this)
96  {
97  m_record = copy_this.m_record;
98  }
99  return *this;
100 }
101 
103 {
104 }
105 
107 {
108  in.read((char*)&m_record, 26); // sizeof reports 28 due to actual space used for STRUCT //sizeof(ossimLasPointRecord2Data));
109 
111  {
112  swap();
113  }
114 }
115 
117 {
119  {
120  // Write little endian per spec:
121  swap();
122  }
123 
124  out.write((char*)&m_record, 26); // sizeof reports 28 due to actual space used for STRUCT //sizeof(ossimLasPointRecord2Data));
125 
127  {
128  // Swap back to native byte order if needed:
129  swap();
130  }
131 }
132 
134 {
135  return m_record.m_x;
136 }
137 
139 {
140  return m_record.m_y;
141 }
142 
144 {
145  return m_record.m_z;
146 }
147 
149 {
150  return m_record.m_red;
151 }
152 
154 {
155  return m_record.m_green;
156 }
157 
159 {
160  return m_record.m_blue;
161 }
162 
164 {
165  return m_record.m_intensity;
166 }
167 
169 {
171 }
172 
174 {
176 }
177 
179 {
181 }
182 
184 {
185  // Capture the original flags.
186  std::ios_base::fmtflags f = out.flags();
187 
188  out << std::setiosflags(std::ios_base::fixed) << std::setprecision(8);
189 
190  out << "x: " << m_record.m_x
191  << "\ny: " << m_record.m_y
192  << "\nz: " << m_record.m_z
193  << "\nintensity: " << m_record.m_intensity
194  << "\nreturn: " << int(getReturnNumber())
195  << "\nnumber_of_returns: " << int(getNumberOfReturns())
196  << "\nedge: " << (getEdgeFlag()?"true":"false")
197  << "\nscan_direction: " << int(m_record.m_bitFlags.m_scanDirection)
198  << "\nclassification: " << m_record.m_classification
199  << "\nscan_angle_rank: " << int(m_record.m_scanAngleRank)
200  << "\nuser_data: " << m_record.m_userData
201  << "\npoint_source_id: " << m_record.m_pointSourceId
202  << "\nred: " << m_record.m_red
203  << "\ngreen: " << m_record.m_green
204  << "\nblue: " << m_record.m_blue
205  << std::endl;
206 
207  // Reset flags.
208  out.setf(f);
209  return out;
210 }
211 
213 {
214  ossimEndian endian;
215  endian.swap(m_record.m_x);
216  endian.swap(m_record.m_y);
217  endian.swap(m_record.m_z);
218  endian.swap(m_record.m_intensity);
219  endian.swap(m_record.m_pointSourceId);
220  endian.swap(m_record.m_red);
221  endian.swap(m_record.m_green);
222  endian.swap(m_record.m_blue);
223 }
224 
virtual ~ossimLasPointRecord2()
destructor
virtual ossim_uint8 getNumberOfReturns() const
ossimLasPointRecord2Data m_record
virtual std::ostream & print(std::ostream &out) const
const ossimLasPointRecord2Data & operator=(const ossimLasPointRecord2Data &obj)
virtual void readStream(std::istream &in)
Initialize record from stream.
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
unsigned short ossim_uint16
virtual ossim_uint16 getRed() const
virtual ossim_int32 getX() const
virtual ossim_uint8 getEdgeFlag() const
virtual void writeStream(std::ostream &out)
Writes record to stream.
virtual ossim_uint16 getBlue() const
virtual ossim_uint8 getReturnNumber() const
virtual ossim_int32 getZ() const
virtual ossim_uint16 getGreen() const
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
virtual ossim_int32 getY() const
void swap()
Performs a swap if system byte order is not little endian.
const ossimLasPointRecord2 & operator=(const ossimLasPointRecord2 &copy_this)
virtual ossim_uint16 getIntensity() const
Container class for LAS point record type 2.
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
ossimLasPointRecord2()
default constructor
unsigned char ossim_uint8
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32