| 684 | |
| 685 | |
| 686 | bool LasReader::processOne(PointRef& point) |
| 687 | { |
| 688 | // This is called under lock. Note that we don't remove the tile *pointer* from the |
| 689 | // vector, it just gets set to null. When we add a tile, we'll look for a null |
| 690 | // entry before we add to the vector. |
| 691 | auto getTile = [this](uint32_t chunk) |
| 692 | { |
| 693 | for (las::TilePtr& t : d->tiles) |
| 694 | if (t && t->chunk() == chunk) |
| 695 | return std::move(t); |
| 696 | return las::TilePtr(); |
| 697 | }; |
| 698 | |
| 699 | if (eof()) |
| 700 | return false; |
| 701 | |
| 702 | // If we don't have an active tile, get the next one or wait for it to be ready. |
| 703 | if (!d->currentTile) |
| 704 | { |
| 705 | { |
| 706 | std::unique_lock<std::mutex> l(d->mutex); |
| 707 | while (true) |
| 708 | { |
| 709 | d->currentTile = getTile(d->nextReadChunk); |
| 710 | if (d->currentTile) |
| 711 | break; |
| 712 | d->processedCv.wait(l); |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | // Found the tile we wanted. Queue the next file read. |
| 717 | d->nextReadChunk++; |
| 718 | d->queueNext(); |
| 719 | } |
| 720 | |
| 721 | // Load the point and advance the tile location. |
| 722 | d->loadPoint(point, d->currentTile->pos(), d->header.pointSize); |
| 723 | if (!d->currentTile->advance(d->header.pointSize)) |
| 724 | d->currentTile.reset(); |
| 725 | |
| 726 | d->index++; |
| 727 | return true; |
| 728 | } |
| 729 | |
| 730 | point_count_t LasReader::read(PointViewPtr view, point_count_t count) |
| 731 | { |