Skip to content
Snippets Groups Projects
Commit 67b3aac2 authored by Alexander Rose's avatar Alexander Rose
Browse files

cleanup, removed unused files

parent b09a0c69
Branches
Tags
No related merge requests found
/**
* Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Schäfer, Marco <marco.schaefer@uni-tuebingen.de>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
......@@ -35,9 +36,3 @@ export function PlyStructure(vertexCount: number, faceCount: number, propertyCou
}
export type PlyColumns = { [name: string]: PlyColumn }
\ No newline at end of file
// export namespace CsvTable {
// export function empty(name: string): Table {
// return { rowCount: 0, name, fieldNames: [], getColumn(name: string) { return void 0; } };
// };
// }
\ No newline at end of file
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*
* Adapted from LiteMol
*/
import { Task, RuntimeContext } from 'mol-task';
export function readFromFile(file: File) {
return <Task<number | string>>readFromFileInternal(file);
}
async function processFile(ctx: RuntimeContext, e: any) {
const data = (e.target as FileReader).result;
return data as string;
}
function readData(ctx: RuntimeContext, action: string, data: XMLHttpRequest | FileReader): Promise<any> {
return new Promise<any>((resolve, reject) => {
data.onerror = (e: any) => {
const error = (<FileReader>e.target).error;
reject(error ? error : 'Failed.');
};
data.onabort = () => reject(Task.Aborted(''));
data.onprogress = (e: ProgressEvent) => {
if (e.lengthComputable) {
ctx.update({ message: action, isIndeterminate: false, current: e.loaded, max: e.total });
} else {
ctx.update({ message: `${action} ${(e.loaded / 1024 / 1024).toFixed(2)} MB`, isIndeterminate: true });
}
}
data.onload = (e: any) => resolve(e);
});
}
function readFromFileInternal(file: File): Task<string | number> {
let reader: FileReader | undefined = void 0;
return Task.create('Read File', async ctx => {
try {
reader = new FileReader();
reader.readAsBinaryString(file);
ctx.update({ message: 'Opening file...', canAbort: true });
const e = await readData(ctx, 'Reading...', reader);
const result = processFile(ctx, e);
return result;
} finally {
reader = void 0;
}
}, () => {
if (reader) reader.abort();
});
}
// /**
// * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
// *
// * @author David Sehnal <david.sehnal@gmail.com>
// */
// import { PluginStateTransform } from '../../../../mol-plugin/state/objects';
// import { PluginStateObject as SO } from '../../../../mol-plugin/state/objects';
// import { Task } from 'mol-task';
// import PLY from 'mol-io/reader/ply/parse_data/ply_parser'
// import { ParamDefinition as PD } from 'mol-util/param-definition';
// import { Transformer } from 'mol-state';
// import { readFromFile } from './data-source';
// export { ReadFile_ascii }
// type ReadFile_ascii = typeof ReadFile_ascii
// const ReadFile_ascii = PluginStateTransform.BuiltIn({
// name: 'ReadFile_ascii',
// display: { name: 'ReadFile_ascii', description: 'Read string data from the specified file' },
// from: SO.Root,
// to: [SO.Data.String],
// params: {
// file: PD.File(),
// label: PD.Optional(PD.Text('')),
// isBinary: PD.Optional(PD.Boolean(false, { description: 'If true, open file as as binary (string otherwise)' }))
// }
// })({
// apply({ params: p }) {
// return Task.create('Open File', async ctx => {
// const data = await readFromFile(p.file).runInContext(ctx);
// return new SO.Data.String(data as string, { label: p.label ? p.label : p.file.name });
// });
// },
// update({ oldParams, newParams, b }) {
// if (oldParams.label !== newParams.label) {
// (b.label as string) = newParams.label || oldParams.file.name;
// return Transformer.UpdateResult.Updated;
// }
// return Transformer.UpdateResult.Unchanged;
// },
// isSerializable: () => ({ isSerializable: false, reason: 'Cannot serialize user loaded files.' })
// });
// export { ParsePLY }
// type ParsePLY = typeof ParsePLY
// const ParsePLY = PluginStateTransform.BuiltIn({
// name: 'parse-ply',
// display: { name: 'Parse PLY', description: 'Parse PLY from String' },
// from: [SO.Data.String],
// to: SO.Format.Ply
// })({
// apply({ a }) {
// return Task.create('Parse PLY', async ctx => {
// const parsed = await (PLY(a.data).runInContext(ctx));
// if (parsed.isError) throw new Error(parsed.message);
// return new SO.Format.Ply(parsed.result);
// });
// }
// });
\ No newline at end of file
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Schäfer, Marco <marco.schaefer@uni-tuebingen.de>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import {ply_form, PlyFile} from '../../../../mol-io/reader/ply/parse_data/data-model';
import {RuntimeContext, Task} from 'mol-task';
import {Mesh} from '../../../../mol-geo/geometry/mesh/mesh';
......@@ -13,7 +20,6 @@ export interface MyData {
faces: number[],
colors: Color[],
labels: string[],
transforms: number[]
}
function collectData_for_Shape(parsedData: ply_form): MyData {
......@@ -26,7 +32,6 @@ function collectData_for_Shape(parsedData: ply_form): MyData {
faces: faces,
colors: [],
labels: [],
transforms: []
}
for (let i = 0; i<parsedData.faceCount; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment