use of qupath.lib.objects.TemporaryObject in project qupath by qupath.
the class PathObjectTileCache method addToCache.
/**
* Add a PathObject to the cache, optionally including children.
*
* @param pathObject
* @param includeChildren
*/
private void addToCache(PathObject pathObject, boolean includeChildren, Class<? extends PathObject> limitToClass) {
// If the cache isn't active, we can ignore this... it will be constructed when it is needed
if (!isActive())
return;
if (pathObject.hasROI()) {
Class<? extends PathObject> cls = pathObject.getClass();
if (limitToClass == null || cls == limitToClass) {
SpatialIndex mapObjects = map.get(cls);
if (mapObjects == null) {
mapObjects = createSpatialIndex();
map.put(cls, mapObjects);
}
Envelope envelope = getEnvelope(pathObject);
mapObjects.insert(envelope, pathObject);
}
}
// Add the children
if (includeChildren && !(pathObject instanceof TemporaryObject) && pathObject.hasChildren()) {
for (PathObject child : pathObject.getChildObjectsAsArray()) addToCache(child, includeChildren, limitToClass);
}
}
Aggregations