HttpDataSetReader
Introduction
The vtkHttpDataSetReader is using a custom format that only exist in vtk.js which aims to simplify data fetching in an HTTP context. Basically the format is composed of a JSON metadata file referencing all the required data array as side binary files along with all the dataset configuration (i.e.: type, extent...).
Usage
import vtkHttpDataSetReader from '@kitware/vtk.js/IO/Core/HttpDataSetReader';
const reader = vtkHttpDataSetReader.newInstance();
reader.setURL('/Data/can.ex2/index.json').then((reader, dataset) => {
console.log('Metadata loaded with the geometry', dataset);
reader.getArrays().forEach(array => {
console.log('-', array.name, array.location, ':', array.enable);
});
reader.update()
.then((reader, dataset) => {
console.log('dataset fully loaded', dataset);
});
});Methods
clearCache
Clears all cached entries.
enableArray
Enable or disable a given array.
reader.enableArray('pointData', 'Temperature');
reader.enableArray('pointData', 'Pressure', false);
reader.enableArray('cellData', 'CellId', true);
reader.enableArray('fieldData', 'labels', true);| Argument | Type | Required | Description |
|---|---|---|---|
location | String | Yes | |
name | String | Yes | |
enable | Boolean | No |
extend
Method used to decorate a given object (publicAPI+model) with vtkHttpDataSetReader characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IHttpDataSetReaderInitialValues | No | (default: {}) |
getArrays
Get the list of available array with their location and if they are enable or not for download using the update() method.
getArraysByReference
getBaseURL
Get the base url to use to download arrays or other data from the given dataset.
reader.setURL('/Data/can.ex2/index.json');
if (reader.getBaseURL() === '/Data/can.ex2') {
console.log('Good guess...');
}getCachedArrayIds
Gets an array of all cached array ids.
getDataAccessHelper
getEnableArray
getFetchGzip
getMaxCacheSize
Gets the maximum size cached arrays are allowed to occupy. Size is given in MiB. If cache size is exceeded, the arrays that where not accessed the longest are removed.
Special settings: -1 -> Cache unlimited 0 -> Cache disabled null -> Cache disabled undefined -> Cache disabled
getUrl
Get the url of the object to load.
invokeBusy
| Argument | Type | Required | Description |
|---|---|---|---|
busy | Boolean | Yes |
isBusy
Get the current status of the reader. True means busy and False means idle.
loadData
newInstance
Method used to create a new instance of vtkHttpDataSetReader while enabling a default behavior regarding the data array and the way they should be fetched from the server.
The enableArray argument allow you to choose if you want to activate all data array by default or if you will have to manually enable them before downloading them.
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IHttpDataSetReaderInitialValues | No | for pre-setting some of its content |
onBusy
Attach listener to monitor when the reader is downloading data or not.
const subscription = reader.onBusy(busy => {
console.log('Reader is', busy ? 'downloading' : 'idle');
})
reader.update();
// much later
subscription.unsubscribe();| Argument | Type | Required | Description |
|---|---|---|---|
callback | Yes |
parseObject
Set the dataset object to use for data fetching.
| Argument | Type | Required | Description |
|---|---|---|---|
manifest | IDatasetManifest | Yes | The dataset manifest object |
options | IParseObjectOptions | Yes |
requestData
| Argument | Type | Required | Description |
|---|---|---|---|
inData | Yes | ||
outData | Yes |
setDataAccessHelper
| Argument | Type | Required | Description |
|---|---|---|---|
dataAccessHelper | Yes |
setMaxCacheSize
Sets the maximum size cached arrays are allowed to occupy. Size is given in MiB. If cache size is exceeded, the arrays that where not accessed the longest are removed. If set to "undefined" the cache is unlimited.
Special settings: -1 -> Cache unlimited 0 -> Cache disabled null -> Cache disabled undefined -> Cache disabled
setProgressCallback
| Argument | Type | Required | Description |
|---|---|---|---|
progressCallback | Yes |
setUrl
Set the url for the dataset to load.
const reader = HttpDataSetReader.newInstance();
isReady = reader.setURL('/Data/can.ex2/index.json');
// Same as
const reader = HttpDataSetReader.newInstance({ url: '/Data/can.ex2/index.json' });
isReady = reader.updateMetadata();| Argument | Type | Required | Description |
|---|---|---|---|
url | String | Yes | the url of the object to load. |
option | IHttpDataSetReaderOptions | No | The Draco reader options. |