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

cleanup, removed unused files

parent b09a0c69
No related branches found
No related tags found
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>
*/
......@@ -27,17 +28,11 @@ export interface ply_form {
readonly vertices: number[],
readonly colors: number[],
readonly normals: number[],
readonly faces: number[],
readonly faces: number[],
}
export function PlyStructure(vertexCount: number, faceCount: number, propertyCount: number, initialHead: string[], propertyNames: string[], properties: number[], vertices: number[], colors: number[], normals: number[], faces: number[]): ply_form {
return {vertexCount, faceCount, propertyCount, initialHead: [...initialHead], propertyNames: [...propertyNames], properties: [...properties], vertices: [...vertices], colors: [...colors], normals: [...normals], faces: [...faces]};
}
export type PlyColumns = { [name: string]: PlyColumn }
// 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
export type PlyColumns = { [name: string]: PlyColumn }
\ 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,13 +32,12 @@ function collectData_for_Shape(parsedData: ply_form): MyData {
faces: faces,
colors: [],
labels: [],
transforms: []
}
for (let i = 0; i<parsedData.faceCount; i++) {
data.colors[i] = Color.fromRgb(colors[faces[4*i+1]*3+0], colors[faces[4*i+1]*3+1], colors[faces[4*i+1]*3+2]);
data.labels[i] = parsedData.properties[parsedData.propertyCount * faces[4*i+1] + 10].toString();
//i.toString();
// i.toString();
// data.transforms[i] = 0;
}
console.log('data', data);
......@@ -55,8 +60,8 @@ async function getSphereMesh(ctx: RuntimeContext, centers: number[], normals: nu
triangle_normals = [ normals[faces[4*i+1]*3], normals[faces[4*i+1]*3+1], normals[faces[4*i+1]*3+2],
normals[faces[4*i+2]*3], normals[faces[4*i+2]*3+1], normals[faces[4*i+2]*3+2],
normals[faces[4*i+3]*3], normals[faces[4*i+3]*3+1], normals[faces[4*i+3]*3+2]];
triangle_indices = [0,1,2];
//console.log(triangle_vertices)
triangle_indices = [0, 1, 2];
// console.log(triangle_vertices)
addTriangle(builderState, triangle_vertices, triangle_normals, triangle_indices)
}
let a = MeshBuilder.getMesh(builderState);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment