| 266 | } |
| 267 | |
| 268 | BOOL LASwaveform13reader::read_waveform(const LASpoint* point) |
| 269 | { |
| 270 | U32 index = point->wavepacket.getIndex(); |
| 271 | if (index == 0) |
| 272 | { |
| 273 | return FALSE; |
| 274 | } |
| 275 | |
| 276 | if (wave_packet_descr[index] == 0) |
| 277 | { |
| 278 | laserror("wavepacket is indexing non-existant descriptor %u", index); |
| 279 | return FALSE; |
| 280 | } |
| 281 | |
| 282 | nbits = wave_packet_descr[index]->getBitsPerSample(); |
| 283 | if ((nbits != 8) && (nbits != 16)) |
| 284 | { |
| 285 | laserror("waveform with %d bits per samples not supported yet", nbits); |
| 286 | return FALSE; |
| 287 | } |
| 288 | |
| 289 | nsamples = wave_packet_descr[index]->getNumberOfSamples(); |
| 290 | |
| 291 | // temporary Optech Fix |
| 292 | // nsamples = point->wavepacket.getSize(); |
| 293 | // if (nbits == 16) nsamples / 2; |
| 294 | |
| 295 | if (nsamples == 0) |
| 296 | { |
| 297 | laserror("waveform has no samples"); |
| 298 | return FALSE; |
| 299 | } |
| 300 | |
| 301 | temporal = wave_packet_descr[index]->getTemporalSpacing(); |
| 302 | location = point->wavepacket.getLocation(); |
| 303 | |
| 304 | XYZt[0] = point->wavepacket.getXt(); |
| 305 | XYZt[1] = point->wavepacket.getYt(); |
| 306 | XYZt[2] = point->wavepacket.getZt(); |
| 307 | |
| 308 | XYZreturn[0] = point->get_x(); |
| 309 | XYZreturn[1] = point->get_y(); |
| 310 | XYZreturn[2] = point->get_z(); |
| 311 | |
| 312 | // alloc data |
| 313 | |
| 314 | if (size < ((nbits/8) * nsamples)) |
| 315 | { |
| 316 | if (samples) delete [] samples; |
| 317 | samples = new U8[((nbits/8) * nsamples)]; |
| 318 | } |
| 319 | |
| 320 | size = ((nbits/8) * nsamples); |
| 321 | |
| 322 | // read waveform |
| 323 | |
| 324 | I64 position = start_of_waveform_data_packet_record + point->wavepacket.getOffset(); |
| 325 | stream->seek(position); |
no test coverage detected