RaumZeit / MarchingSquares.js

A JavaScript implementation of the Marching Squares algorithm featuring IsoContour and IsoBand computation
Other
152 stars 23 forks source link

1D ArrayLike data as input #26

Open naoak opened 3 years ago

naoak commented 3 years ago

Hi, MarchingSquaresJS requires 2-dimensional input data, but i have very huge 1-dimensional ArrayLike data (e.g. Float32Array). Is there any better way than converting it to 2D data? One thing I'm thinking about is to support multi-dimensional arrays like ndarray whose data source is 1D ArrayLike but can be accessed as like 2D array by get/set methods. Any thoughts? Thanks.

naoak commented 2 years ago

I've managed to achieve this. Here is sample codes. https://codesandbox.io/s/ms-matrix-proxy-wmbk6?file=/src/main.js:219-273

We were able to reduce the memory usage compared to generating a 2D array. However, the performance of index access was 20 to 400 times worse due to the use of proxies.