Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3mf export and import #1521

Merged

Conversation

lvk88
Copy link
Contributor

@lvk88 lvk88 commented Aug 16, 2024

This PR addresses issue #1032 adds the possibility to export and import meshes in 3MF format to and from meshlab. This is a minimum working solution.
Features:

  • Imports separate meshes from the 3MF as separate meshes into the open document
  • It is able to read color and texture data from the 3MF file and use them in the imported mesh
  • When importing colors, the entire triangle is colored with the p1 property found in the 3mf file (see 3MF spec here). The most complete solution should be face wedge coloring, but I couldn't get it working unfortunately
  • When importing textures, face wedge textures are used
  • Exporting single meshes into 3MF file works. Exporting multiple meshes does not work.

I tested the solution on Ubuntu 22.04. with GCC12 and Windows with MSVC 2019.

All files from the 3MF example repo under the core folder can be opened (https://github.com/3MFConsortium/3mf-samples/tree/master/examples/core)

Colored and textured files from the 3MF example repo (https://github.com/3MFConsortium/3mf-samples/tree/master/examples/material) can be opened, except those with multiprop prefix. These files also crash the built in 3D viewer of windows.

@alemuntoni
Copy link
Member

Thank you very much @lvk88!! I'll look into this in the next few weeks (I can't test it on macos right now).

@alemuntoni
Copy link
Member

The 3mf importer works as expected on mac x86_64, but not on arm64 :( I'll try to check why, but on my mac I am having troubles even on compiling lib3mf :(

@alemuntoni
Copy link
Member

@lvk88 is there any reason why you used lib3mf 2.2.0 (which is 3 years old)? Could it be possible to update to 2.3.2?

@lvk88
Copy link
Contributor Author

lvk88 commented Sep 6, 2024

Hey @alemuntoni ,

The 3mf importer works as expected on mac x86_64, but not on arm64 :(

Oh no 😢 . I can try to fix that, I just need to get an arm Mac from somewhere. I'll see what I can do. What exactly doesn't work? It doesn't compile, it doesn't link, or it compiles links and crashes? If it doesn't compile, could you tell me the compiler and its version that you are using on Mac? If we are lucky I can reproduce the issue with the same compiler but on x86 without having to find a Mac.

is there any reason why you used lib3mf 2.2.0 (which is 3 years old)? Could it be possible to update to 2.3.2?

The reason is that when I started working on the feature last year, 2.3.2 was not out yet. Since then, the new release came out. I will check if the whole thing still works with the newer version and get back to you in the next days.

@alemuntoni
Copy link
Member

It doesn't compile, it doesn't link, or it compiles links and crashes?

It's kind of strange. On github actions runner it seems to build correctly, but then the app bundle is damaged (I did not checked why yet). Then I tried to build it on my mac but I get build errors caused by old cmake code that has been removed on newer versions.

The reason is that when I started working on the feature last year, 2.3.2 was not out yet. Since then, the new release came out. I will check if the whole thing still works with the newer version and get back to you in the next days.

Ok, then I think that upgrading to the new version should be the first thing to do. Then I can try to make it working on mac, if there are still some errors.

@alemuntoni
Copy link
Member

Let me know if you have time to upgrade it and make it working at least on linux and windows, otherwise I think I could try to do it next week! Thanks again!!!

@lvk88
Copy link
Contributor Author

lvk88 commented Sep 6, 2024

I think I will be able to do the upgrading on the weekend, should not be a big issue. Even though my first try with commit 56951e0 seems to have failed 😃

@lvk88 lvk88 force-pushed the meshlab-1032-add-3mf-export-and-import branch from a39fbda to 56951e0 Compare September 6, 2024 18:53
@lvk88
Copy link
Contributor Author

lvk88 commented Sep 7, 2024

I updated lib3mf to 2.3.2 and tested on Ubuntu and Windows with the example files from the 3mf repos. Still seems to work. I didn't test very extensively, though. @alemuntoni let me know if it helps with the Mac issue

@alemuntoni
Copy link
Member

The latest version of lib3mf builds fine on my mac m1, thanks @lvk88!!
I was still getting the error on macos m1 ("MeshLab is damaged and can't be opened"), and I just found that it was caused by the app bundle not being signed (PRs do not get access to github actions secrets).
I guess I'll always hate Apple and its non-transparency policy on not let the user know what's actually happening.

Anyway, thank you very much for this PR!! :)

@alemuntoni alemuntoni merged commit 1e1e815 into cnr-isti-vclab:devel Sep 9, 2024
8 checks passed
@lvk88
Copy link
Contributor Author

lvk88 commented Sep 9, 2024

Awesome, I'm glad that it all worked out 🎉

I guess I'll always hate Apple and its non-transparency policy on not let the user know what's actually happening.

Oh, haha, I share your frustration.

Thanks for the review and merging 😄

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.

2 participants