123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import { m as macro } from '@kitware/vtk.js/macros2.js';
- import DataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper.js';
- import velocityAsciiParser from './VelocityAsciiParser.js';
- import '@kitware/vtk.js/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js';
- // ----------------------------------------------------------------------------
- // VelocityDataReader methods
- // ----------------------------------------------------------------------------
- function VelocityDataReader(publicAPI, model) {
- // Set our className
- model.classHierarchy.push('velocityDataReader');
- // Create default dataAccessHelper if not available
- if (!model.dataAccessHelper) {
- model.dataAccessHelper = DataAccessHelper.get('http');
- }
- // Internal method to fetch Array
- function fetchData(url) {
- const {
- compression,
- progressCallback
- } = model;
- return model.dataAccessHelper.fetchText(publicAPI, url, {
- compression,
- progressCallback
- });
- }
- // Set DataSet url
- publicAPI.setUrl = function (url) {
- let option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- model.url = url;
- // Remove the file in the URL
- const path = url.split('/');
- path.pop();
- model.baseURL = path.join('/');
- model.compression = option.compression;
- // Fetch metadata
- return publicAPI.loadData({
- progressCallback: option.progressCallback
- });
- };
- // Fetch the actual data arrays
- publicAPI.loadData = function () {
- const promise = fetchData(model.url);
- promise.then(publicAPI.parseAsText);
- return promise;
- };
- publicAPI.parseAsText = content => {
- if (!content) {
- return;
- }
- if (content !== model.parseData) {
- publicAPI.modified();
- } else {
- return;
- }
- model.parseData = content;
- model.dataModel= velocityAsciiParser.parseLegacyASCII(model.parseData);
- model.output[0] = model.dataModel.dataset;
- model.output[1] = model.dataModel.velocitys;
- };
- publicAPI.requestData = (inData, outData) => {
- publicAPI.parseAsText(model.parseData);
- };
- }
- // ----------------------------------------------------------------------------
- // Object factory
- // ----------------------------------------------------------------------------
- const DEFAULT_VALUES = {
- // baseURL: null,
- // dataAccessHelper: null,
- // url: null,
- };
- // ----------------------------------------------------------------------------
- function extend(publicAPI, model) {
- let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- Object.assign(model, DEFAULT_VALUES, initialValues);
- // Build VTK API
- macro.obj(publicAPI, model);
- macro.get(publicAPI, model, ['url', 'baseURL']);
- macro.setGet(publicAPI, model, ['dataAccessHelper']);
- macro.algo(publicAPI, model, 0, 1);
- // vtkPolyDataReader methods
- VelocityDataReader(publicAPI, model);
- // To support destructuring
- if (!model.compression) {
- model.compression = null;
- }
- if (!model.progressCallback) {
- model.progressCallback = null;
- }
- }
- // ----------------------------------------------------------------------------
- const newInstance = macro.newInstance(extend, 'VelocityDataReader');
- // ----------------------------------------------------------------------------
- var VelocityDataReader$1 = {
- newInstance,
- extend
- };
- export { VelocityDataReader$1 as default, extend, newInstance };
|