diff --git a/src/mol-io/reader/ply/parse_data/data-model.ts b/src/mol-io/reader/ply/parse_data/data-model.ts index d66ba1d36120ec6856ce8ed91804845244333959..99cd4d7f2047344cb94a8eb55020c68188c2c0c1 100644 --- a/src/mol-io/reader/ply/parse_data/data-model.ts +++ b/src/mol-io/reader/ply/parse_data/data-model.ts @@ -11,14 +11,14 @@ export { PlyColumn } export interface PlyFile { readonly name?: string, - readonly PLY_File: ply_form + readonly PLY_File: PlyData } -export function PlyFile(PLY_File: ply_form, name?: string): PlyFile { +export function PlyFile(PLY_File: PlyData, name?: string): PlyFile { return { name, PLY_File }; } -export interface ply_form { +export interface PlyData { readonly vertexCount: number, readonly faceCount: number, readonly propertyCount: number, @@ -31,8 +31,18 @@ export interface ply_form { 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 } \ No newline at end of file +// TODO note, removed `faces: [...faces]` pattern as that copies the data which I assume was not intentional (alex) +export function PlyData(vertexCount: number, faceCount: number, propertyCount: number, initialHead: string[], propertyNames: string[], properties: number[], vertices: number[], colors: number[], normals: number[], faces: number[]): PlyData { + return { + vertexCount, + faceCount, + propertyCount, + initialHead, + propertyNames, + properties, + vertices, + colors, + normals, + faces + }; +} \ No newline at end of file diff --git a/src/mol-io/reader/ply/parse_data/ply_parser.ts b/src/mol-io/reader/ply/parse_data/ply_parser.ts index 1a88b09bed69b6f873fa26739b783d0bbc7cc023..e1c04a6bbc54b7217947fb0351f2eba818e22fa5 100644 --- a/src/mol-io/reader/ply/parse_data/ply_parser.ts +++ b/src/mol-io/reader/ply/parse_data/ply_parser.ts @@ -284,14 +284,14 @@ function init(state: State) { // only for first two lines to get the format and return 1; } -async function handleRecords(state: State): Promise<Data.ply_form> { +async function handleRecords(state: State): Promise<Data.PlyData> { if (!init(state)) { console.log('ERROR: parsing file (PLY) failed!') throw new Error('arsing file (PLY) failed!'); } await readRecordsChunks(state) - return Data.PlyStructure(state.vertexCount, state.faceCount, state.propertyCount, state.initialHead, state.propertyNames, state.properties, state.vertices, state.colors, state.normals, state.faces) + return Data.PlyData(state.vertexCount, state.faceCount, state.propertyCount, state.initialHead, state.propertyNames, state.properties, state.vertices, state.colors, state.normals, state.faces) } async function parseInternal(data: string, ctx: RuntimeContext, opts: PlyOptions): Promise<ReaderResult<Data.PlyFile>> { diff --git a/src/mol-model-formats/shape/ply.ts b/src/mol-model-formats/shape/ply.ts index 686c7d6b0533398ec5ba3c69cb163de565d3cbec..fe32a05cdba9f9aa192863c59594011ca49e2244 100644 --- a/src/mol-model-formats/shape/ply.ts +++ b/src/mol-model-formats/shape/ply.ts @@ -9,7 +9,7 @@ import { RuntimeContext, Task } from 'mol-task'; import { addTriangle } from 'mol-geo/geometry/mesh/builder/triangle'; import { ShapeProvider } from 'mol-model/shape/provider'; import { Color } from 'mol-util/color'; -import { ply_form, PlyFile } from 'mol-io/reader/ply/parse_data/data-model'; +import { PlyData, PlyFile } from 'mol-io/reader/ply/parse_data/data-model'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { Shape } from 'mol-model/shape'; @@ -22,7 +22,7 @@ interface PlyShapeData { labels: string[], } -function collectData_for_Shape(parsedData: ply_form): PlyShapeData { +function collectData_for_Shape(parsedData: PlyData): PlyShapeData { // parsedData.data.PLY_File. to access So.format.Ply console.log('parsedData', parsedData) const { vertices, colors, faces, normals } = parsedData @@ -69,7 +69,7 @@ async function getPlyMesh(ctx: RuntimeContext, centers: number[], normals: numbe return a } -async function getShape(ctx: RuntimeContext, parsedData: ply_form, props: {}, shape?: Shape<Mesh>) { +async function getShape(ctx: RuntimeContext, parsedData: PlyData, props: {}, shape?: Shape<Mesh>) { const data = collectData_for_Shape(parsedData) await ctx.update('async creation of shape from myData') const { centers, normals, faces, colors, labels } = data @@ -89,7 +89,7 @@ export const PlyShapeParams = { export type PlyShapeParams = typeof PlyShapeParams export function shapeFromPly(source: PlyFile, params?: {}) { - return Task.create<ShapeProvider<ply_form, Mesh, PlyShapeParams>>('Parse Shape Data', async ctx => { + return Task.create<ShapeProvider<PlyData, Mesh, PlyShapeParams>>('Parse Shape Data', async ctx => { console.log('source', source) return { label: 'Mesh',