ome-files  0.1.1
Classes | Public Member Functions | Protected Attributes | List of all members
ome::files::TileCoverage Class Reference

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 &region, bool coalesce=true)
 Insert a region into the coverage cache. More...
 
bool remove (const PlaneRegion &region)
 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 &region) const
 Covered area within the region. More...
 
bool covered (const PlaneRegion &region) const
 Check if a region is completely covered. More...
 

Protected Attributes

ome::compat::shared_ptr< Implimpl
 Private implementation details.
 

Detailed Description

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.

Member Function Documentation

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.

Parameters
regionthe region to check.
Returns
the covered area.

References ome::files::PlaneRegion::area(), impl, and ome::files::PlaneRegion::valid().

Referenced by covered(), and insert().

+ Here is the caller graph for this function:

bool ome::files::TileCoverage::covered ( const PlaneRegion region) const

Check if a region is completely covered.

Parameters
regionthe region to check.
Returns
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.

Parameters
regionthe region to insert.
coalescetrue to merge with adjacent tiles, or false to ensure the region is kept separated.
Returns
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.

Parameters
regionthe region to remove.
Returns
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.

Returns
the number of separate regions.

References impl.


The documentation for this class was generated from the following files: