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

tweaked naming in ply handling

parent c3bbcaba
No related branches found
No related tags found
No related merge requests found
......@@ -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]};
// 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
export type PlyColumns = { [name: string]: PlyColumn }
\ No newline at end of file
......@@ -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>> {
......
......@@ -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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment