Skip to content

Conversation

rhulha
Copy link
Contributor

@rhulha rhulha commented Jan 26, 2022

Hello all,

I am trying to add binary STL format to Draco.
STL is an incredibly simple single mesh 3D file format and it would be a perfect addition to Draco due to its popularity and large file size.
Some basic tests seem to work great.
Please let me know if I am going into the right direction.

This fixes: #773

Copy link
Collaborator

@ondys ondys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. STL support would be great! There are a few concerns I had that I would like to see addressed before we merge this though.

Copy link
Contributor

@tomfinegan tomfinegan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I added a single comment to those left by @ondys, but please fix the copyright year in the file comment headers throughout your PR. It's boring, but it's necessary.

Also, some simple decode and encode tests would be a great addition to this PR before we accept it. In depth coverage of every STL feature and every line of code in this PR is not required, but some basic tests are needed. The tests for the other decoders/encoders in the draco/io directory should serve as a guide-- basically, simple succeed/fail tests that can be used to confirm basic feature correctness will be sufficient.

@tomfinegan
Copy link
Contributor

And one last note: Please update your branch when you have the time to do so: I've made some changes to the Github CI integration for Draco, and this PR needs to be updated to pick up the correct test config.

Thanks again!

@rhulha
Copy link
Contributor Author

rhulha commented Feb 14, 2022

I haven't forgotten about this task, just need some more time.

@rhulha
Copy link
Contributor Author

rhulha commented Feb 26, 2022

And one last note: Please update your branch when you have the time to do so: I've made some changes to the Github CI integration for Draco, and this PR needs to be updated to pick up the correct test config.

Thanks again!

Done

rhulha and others added 4 commits February 26, 2022 17:27
Added ASCII STL detection and proper error message.
Made StlEncoder methods return Status instead of bool.
Added better error messages using Status.
Added better header writing (using setw).
Added STL testdata created from the existing testdata using Blender.
…he input mesh: normalize(cross(p2-p1, p3-p1))
@rhulha
Copy link
Contributor Author

rhulha commented Mar 1, 2022

Is the pull request good now? Anything else I can do?

Moved ASCII STL detection code to DecodeFromBuffer.
Removed normal attribute usage in stl_encoder, normals are now always calculated.
Used Vector3f instead of ugly manual vector math code.
@rhulha
Copy link
Contributor Author

rhulha commented Mar 1, 2022

Another day, another commit... :-)
I feel like we are getting really close now!

@rhulha
Copy link
Contributor Author

rhulha commented Mar 2, 2022

On a side note I want to say thank you for being so patient with and supportive of me. Much appreciated! This is a great project!

Copy link
Collaborator

@ondys ondys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, code looks good to me. One remaining thing would be to add a very simple unit test for the _encoder and _decoder. I see that you added test files but I don't see the unit tests themselves. E.g. you can check unit tests ply_encoder_test.cc + ply_decoder_test.cc for examples how to do it + cmake\draco_tests.cmake to actually build them / integrate them. Note that a very simple test that verifies that model is loaded / saved should be sufficient for now.

@rhulha
Copy link
Contributor Author

rhulha commented Mar 3, 2022

Done and done! :-)

Copy link
Collaborator

@ondys ondys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good. We will try to merge in the near future. Thanks for the PR!

@tomfinegan tomfinegan merged commit befe2d8 into google:master Mar 25, 2022
@myselfhimself
Copy link
Contributor

Hello, I am looking for documentation on STL I/O <-> Draco support.
It is not mentioned in the google/draco README.md at least.
Is STL supported by the npm module as well?

@myselfhimself
Copy link
Contributor

It would also be nice to have a general idea of compression ratio between binary STL -> Draco, and ASCII STL -> Draco.
The target application is long-term STLs archiving for auditive 3d printing prosthesis companies.

@myselfhimself
Copy link
Contributor

myselfhimself commented Dec 18, 2022

Hello, I was able to build the draco binaries for Linux with the BUILDING instructions.

I then used the command:

./draco_encoder -i SteBlandineiMaterialiseShortName.stl # The inputfile is a binary STL weighing 31MB

Here is a simple compression "ratio" overview (compressed file size / original file size):
draco: 2.8MB with ./draco_encoder -i SteBlandineiMaterialiseShortName.stl => 9.0%
draco with no quantization and max compression level: 4.4MB with ./draco_encoder -i SteBlandineiMaterialiseShortName.stl -o SteBlandineiMaterialiseShortName-compressionlevel10NoQuantization.stl.drc -cl 10 -qp 0 => 14.2%
7zip: 8.8MB with 7z a steBlandine.7z SteBlandineiMaterialiseShortName.stl => 28.4%
zip: 12MB with zip steBlandine.zip SteBlandineiMaterialiseShortName.stl => 38.7%
tar.gz: 12MB with tar czvf steBlandine.tar.gz SteBlandineiMaterialiseShortName.stl (I am unsure if .tar.gz is the right extension for those letters) => 38.7%

I have noticed that the original STL file and the encoded+decoded STL file are both binary, have the overall same file size (31MB), but they differ using the diff tool (even when quantization was disabled (with -qp 0) at encoding time).

How can we be sure that there is no information / mesh loss in the STL->draco->STL encoding/decoding pipeline?

@myselfhimself
Copy link
Contributor

myselfhimself commented Dec 18, 2022

Overview of my build_dir for curious people, the building process was fast and simple, with no dependencies to install on my end, thank you:

~/Productions/draco-1.5.5/build_dir$ ls -lhart
total 140M
drwxrwxr-x 12 hey hey 4,0K déc.  18 23:25 ..
drwxrwxr-x  2 hey hey 4,0K déc.  18 23:25 draco
-rw-rw-r--  1 hey hey  155 déc.  18 23:25 draco.pc
-rw-r--r--  1 hey hey 1,4K déc.  18 23:25 draco-config-version.cmake
-rw-rw-r--  1 hey hey  943 déc.  18 23:25 draco-config.cmake
-rw-rw-r--  1 hey hey  18K déc.  18 23:25 CMakeCache.txt
-rw-rw-r--  1 hey hey 184K déc.  18 23:25 Makefile
-rw-rw-r--  1 hey hey 2,2K déc.  18 23:25 draco-targets.cmake
-rw-rw-r--  1 hey hey 153K déc.  18 23:25 cmake_install.cmake
-rw-rw-r--  1 hey hey 4,1M déc.  18 23:28 libdraco.a
-rwxrwxr-x  1 hey hey 1,7M déc.  18 23:29 draco_encoder-1.5.5
lrwxrwxrwx  1 hey hey   19 déc.  18 23:29 draco_encoder -> draco_encoder-1.5.5
-rwxrwxr-x  1 hey hey 990K déc.  18 23:29 draco_decoder-1.5.5
lrwxrwxrwx  1 hey hey   19 déc.  18 23:29 draco_decoder -> draco_decoder-1.5.5
drwxrwxr-x 37 hey hey 4,0K déc.  18 23:29 CMakeFiles
-rw-rw-r--  1 hey hey  31M déc.  18 23:33 SteBlandineiMaterialiseShortName.stl
-rw-rw-r--  1 hey hey  31M déc.  18 23:34 steBlandineUncompressed.stl
-rw-rw-r--  1 hey hey 8,8M déc.  18 23:39 steBlandine.7z
-rw-rw-r--  1 hey hey  12M déc.  18 23:41 steBlandine.zip
-rw-rw-r--  1 hey hey 2,8M déc.  18 23:42 SteBlandineiMaterialiseShortName.stl.drc
-rw-rw-r--  1 hey hey  12M déc.  18 23:45 steBlandine.tar.gz
-rw-rw-r--  1 hey hey 2,8M déc.  19 00:08 SteBlandineiMaterialiseShortName-compressionlevel10.stl.drc
-rw-rw-r--  1 hey hey 4,4M déc.  19 00:10 SteBlandineiMaterialiseShortName-compressionlevel10NoQuantization.stl.drc
drwxrwxr-x  4 hey hey 4,0K déc.  19 00:13 .
-rw-rw-r--  1 hey hey  31M déc.  19 00:13 steBlandineUncompressedNoQuantization.stl

@myselfhimself
Copy link
Contributor

(seeking for lossless encoding)

The default quantization looks weird in Meshlab (sort of Z layers as if we were FDM-3d printing):
image

While without quantization, the model seems smooth and intact:
image

Are there other parameters to use, in addition to -qp 0 to attain a lossless Draco encoding?

myselfhimself added a commit to myselfhimself/draco that referenced this pull request Dec 18, 2022
@myselfhimself
Copy link
Contributor

I opened a new PR just for mentioning working STL support in README. Should there be other places where to mention it?
BTW @rhulha (and Draco team) really thank you for your awesome work

The npm Draco support for STL question is still lingering also.

@myselfhimself
Copy link
Contributor

  • Ensure that 0-quantization-encoded STL->Draco->STL files are lossless despite STL binary difference
  • Ensure that NPM *asm Draco encoding/decoding project supports STL
  • Follow README STL support PR integration.
  • blog about that, it is quite nice...

@myselfhimself
Copy link
Contributor

Reminder for later on STL files (before Draco i/o, after Draco i/o) lossless comparison (with Meshlab or Cloudcompare):
https://www.researchgate.net/post/How_to_compare_two_stl_files

@rhulha
Copy link
Contributor Author

rhulha commented Dec 21, 2022

Draco is a lossy compression method, you can't compare STL before and after...

@myselfhimself
Copy link
Contributor

not even with quantization=0?

@myselfhimself
Copy link
Contributor

@rhulha No, obviously Draco is not lossless if need be: https://github.com/google/draco/search?q=lossless&type=code #878 #933
The latter issue especially mentions 0 quantizations & sequential encoding (instead of edgebreaker) to be perfectly lossless (with no loose geometry removal).
The "issue" is data ordering which differs from input files in the encoding->decoding pipeline. So Draco could be used now for STL archiving...

ondys added a commit that referenced this pull request Feb 1, 2023
Co-authored-by: Ondrej Stava <ondys@users.noreply.github.com>
danielgronlund pushed a commit to danielgronlund/draco that referenced this pull request Aug 22, 2024
Includes support for binary STL and some basic tests.
danielgronlund pushed a commit to danielgronlund/draco that referenced this pull request Aug 22, 2024
…#959)

Co-authored-by: Ondrej Stava <ondys@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add stl file format support to Draco.
4 participants