ome-files
0.1.1
|
Tile coverage cache. More...
#include <ome/files/TileCoverage.h>
Classes | |
class | Impl |
Internal implementation details of TileCoverage. More... | |
Public Member Functions | |
TileCoverage () | |
Constructor. | |
virtual | ~TileCoverage () |
Destructor. | |
bool | insert (const PlaneRegion ®ion, bool coalesce=true) |
Insert a region into the coverage cache. More... | |
bool | remove (const PlaneRegion ®ion) |
Remove a region from the coverage cache. More... | |
dimension_size_type | size () const |
Get the number of separate regions in the coverage cache. More... | |
void | clear () |
Clear the coverage cache of all covered regions. | |
dimension_size_type | coverage (const PlaneRegion ®ion) const |
Covered area within the region. More... | |
bool | covered (const PlaneRegion ®ion) const |
Check if a region is completely covered. More... | |
Protected Attributes | |
ome::compat::shared_ptr< Impl > | impl |
Private implementation details. | |
Tile coverage cache.
Cache and query covered 2D regions. Regions are stored in an R*Tree as half-open ranges of [x1,y1..x2,y2). This may be used, for example, to prevent writing out incomplete tiles and to output tiles in order when used with an accompanying tile cache.
dimension_size_type ome::files::TileCoverage::coverage | ( | const PlaneRegion & | region | ) | const |
Covered area within the region.
This is the sum of all covered areas within the specified region. If the area is completely covered, this value will equal the area of the specified region.
region | the region to check. |
References ome::files::PlaneRegion::area(), impl, and ome::files::PlaneRegion::valid().
Referenced by covered(), and insert().
bool ome::files::TileCoverage::covered | ( | const PlaneRegion & | region | ) | const |
Check if a region is completely covered.
region | the region to check. |
true
if completely covered, false
otherwise. References coverage(), ome::files::PlaneRegion::h, and ome::files::PlaneRegion::w.
bool ome::files::TileCoverage::insert | ( | const PlaneRegion & | region, |
bool | coalesce = true |
||
) |
Insert a region into the coverage cache.
The insert will only succeed if the region is completely uncovered. That is, it must not overlap with any currently covered region in the cache.
Region coalescing is enabled by default because the overhead of merging adjacent regions is much less than the cost of searching the cache with thousand of tiles. If filling the cache with aligned tiles of the same size in a consistent order, this should result in a very low region count (less than 5) and hence lookups will be very fast. It will be necessary to disable coalescing if the regions will subsequently be removed, since region splitting is not implemented.
region | the region to insert. |
coalesce | true to merge with adjacent tiles, or false to ensure the region is kept separated. |
true
if the region was inserted, or false
if not inserted. References coverage(), impl, and ome::files::PlaneRegion::valid().
bool ome::files::TileCoverage::remove | ( | const PlaneRegion & | region | ) |
Remove a region from the coverage cache.
A separate region of the exact size of the specified region must exist in the coverage cache or else removal will fail. Disable coalescing if it is preventing removal due to merging adjacent tiles.
region | the region to remove. |
true
if the region was removed, or false
if not removed. References impl.
dimension_size_type ome::files::TileCoverage::size | ( | ) | const |
Get the number of separate regions in the coverage cache.
References impl.