Skip to content

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 ​

js
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.

js
reader.enableArray('pointData', 'Temperature');
reader.enableArray('pointData', 'Pressure', false);
reader.enableArray('cellData', 'CellId', true);
reader.enableArray('fieldData', 'labels', true);
ArgumentTypeRequiredDescription
locationStringYes
nameStringYes
enableBooleanNo

extend ​

Method used to decorate a given object (publicAPI+model) with vtkHttpDataSetReader characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIHttpDataSetReaderInitialValuesNo(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.

js
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 ​

ArgumentTypeRequiredDescription
busyBooleanYes

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.

ArgumentTypeRequiredDescription
initialValuesIHttpDataSetReaderInitialValuesNofor pre-setting some of its content

onBusy ​

Attach listener to monitor when the reader is downloading data or not.

js
const subscription = reader.onBusy(busy => {
  console.log('Reader is', busy ? 'downloading' : 'idle');
})

reader.update();
// much later
subscription.unsubscribe();
ArgumentTypeRequiredDescription
callbackYes

parseObject ​

Set the dataset object to use for data fetching.

ArgumentTypeRequiredDescription
manifestIDatasetManifestYesThe dataset manifest object
optionsIParseObjectOptionsYes

requestData ​

ArgumentTypeRequiredDescription
inDataYes
outDataYes

setDataAccessHelper ​

ArgumentTypeRequiredDescription
dataAccessHelperYes

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 ​

ArgumentTypeRequiredDescription
progressCallbackYes

setUrl ​

Set the url for the dataset to load.

js
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();
ArgumentTypeRequiredDescription
urlStringYesthe url of the object to load.
optionIHttpDataSetReaderOptionsNoThe Draco reader options.

updateMetadata ​