mikepound / opencubes

A community improved version of the polycubes project!
MIT License
45 stars 23 forks source link

Javascript Online Viewer #41

Open Wagyx opened 1 year ago

Wagyx commented 1 year ago

Hello there, I have made an application so that you may load and visualize a polycube dataset in your browser.

You can load dataset from your computer in a text file format where each line is xyz111000110001... I have seen the post about the pcube format but it was too complex for me to implement fast in Javascript. So I also propose to download polycubes from 3 to 9 in the correct format as an archive (if you trust it): or individually polycubes 3, polycubes 4, polycubes 5, polycubes 6, polycubes 7, polycubes 8, polycubes 9.

Controls:

I also spend some part of my weekend working on the generation of all polycubes that fits across a 3x3x3 cube: there are 1 551 811 of them, took 20min on my computer to compute with some Python script that I have optimized a bit since it was 90min at first. Here are the dataset: zip archive (3.3MB) and txt file (50MB).

I hope you will find it useful. There are many improvements that can be brought to this viewer, let me know if you think of good ones.

Edit 03/09/2023 : All linked files have been removed.

bertie2 commented 1 year ago

that's real good, is their a repo that people can contribute to ? id be happy to implement p-cube loading in JavaScript.

as for improvements, very minor but a "random cube please" button / mode would be nice.

also I don't know if you are loading all the cubes into memory or streaming them but you will want to avoid loading them all if you want to show the bigger cubes.

finally it would be great if it could be hooked up to a file server or database so the user doesn't have to provide the cube files, I'm happy to host the cube files on one of my servers if that helps.

Wagyx commented 1 year ago

Thank you bertie2. There is no repo yet. I could add it here in its own folder if people agree. It is static, nothing fancy, using only HTML, CSS and some Javascript. You can run it locally with a python -m http.server. Any help on the pcube format is welcomed if you can convert to the xyz101101... string, I will be happy.

If you want to go to a random cube in the loaded dataset, just put the step slider to whatever big value and press the next button. It won't overflow since I am using a modulo. I can still make a button though.

Yes, I am loading the whole file to memory but I only keep the raw list of strings. There is only one geometry representing the current polycube it is recomputed when needed. My skills in Javascript are very basic so I would not know how to make the app stream the dataset right away.

I'll try to make the datasets load directly from within the app. Is there a quantification of the memory size of the datasets in the .pcube format ? and in the string format ? Is there an archive with the pcube files ?

Let's see what other people think about it.

Wagyx commented 1 year ago

Hello, I have made some modifications to the viewer. I have changed the data format from txt to binary xyz111000... and a series of datasets (n=1 to 11) are now present in the new Datasets tab in the GUI. If you click on one, it will load. You can only view a single dataset at once. Large dataset (n=11) may take a few seconds to load.

Wagyx commented 1 year ago

Hello, I have changed the data format again by compressing the binary format with gzip, the datasets are now 10% of what they were before which is great for data transfer. However, a dataset is still fully decompressed by the browser so it won't change the impact on your memory. I will try adding the n=12 dataset now. Also, I have removed the txt and zip files from my server.

JATothrim commented 1 year ago

Just looking what the cubes output looks like made my day. :+1: You should publish this as repository so that the main repository could track this as git submodule?

Wagyx commented 1 year ago

Hello everyone, I have published the viewer as a repo here.