OrcaSlicer icon indicating copy to clipboard operation
OrcaSlicer copied to clipboard

Use meshlab to fix model on Linux/Mac

Open buzzhuzz opened this issue 10 months ago • 10 comments

Description

Fixes #5013, #4923

This change introduces new back end for the "Fix model" feature: MeshLabServer.

On Linux and Mac platforms OrcaSlicer checks if "meshlabserver" could be found in path and allows broken objects to be fixed if it is.

Simple script for meshlab added to resources.

In order to make this feature work you need to have MeshLab installed and "meshlabserver" available in PATH.

Screenshots/Recordings/Graphs

https://github.com/user-attachments/assets/25aa1bb8-2a7c-404f-814a-c5b971b8e4e0

Tests

Tested on Linux host only, with native build (no appimage).

buzzhuzz avatar Jan 10 '25 04:01 buzzhuzz

It is expected that someone proficient in MeshLab and meshes manipulation will update the meshlab script within resources directory.

I also have not tested this under Mac. From old times I remember apps are distributed in bundles and it might be tricky to add bundled app binary into the path, so I expect someone on Mac would test this change so we could update documentation/notes on how to make it working under OSX.

buzzhuzz avatar Jan 10 '25 04:01 buzzhuzz

I have installed Meshlab 2023.12, and it no longer has meshlabserver. This has been replaced by PyMeshlab.

sschwetz avatar Jan 13 '25 03:01 sschwetz

Well, it looks like PyMeshLab is the way.

Originally I was going to use PyMeshLab, but switched to meshlabserver due to much easier implementation. Somhow I've missed that meshlabserver got removed in latest version.

I'm going to convert this PR to draft just by now in case someone would like to try this on linux.

I'll rework this to use PyMeshLab and update PR.

buzzhuzz avatar Jan 13 '25 03:01 buzzhuzz

@sschwetz , would you mind testing updated changes with PyMeshLab support?

Please refer to the change description regarding testing sequence. This is not final change as we need to came to solution how to simplify configuration to skip venv usage.

buzzhuzz avatar Jan 15 '25 13:01 buzzhuzz

I've added config option to set PyMeshLab location (which is recommended to be installed inside venv). Now user may create virtualenv with PyMeshLab installed in it. OrcaSlicer shall be configured to point into /bin/ directory (the one containing activate.sh script and/or python3 link) of the respective virtualenv:

Screenshot from 2025-01-27 01-42-21

buzzhuzz avatar Jan 26 '25 15:01 buzzhuzz

Currently trying this under macOS 15.2.

I've grabbed the latest OrcaSlicer from the build artifacts, created a virtualenv (python3 -m venv ~/.venv) and built pymeshlab from source (pip3 install git+https://github.com/cnr-isti-vclab/PyMeshLab) since pip3 install pymeshlab didn't work.

~~I set the path in the settings but it still doesn't seem to work (I get an error saying PyMeshLab not found). Can I provide any logs to help?~~

Edit: The error was that I wasn't using Python 3.10, I was using the Python 3.9 macOS ships. If I create my venv using Python 3.10, I can pip install pymeshlab just fine and can use the "Fix model" function. Thanks for this awesome PR!

oskardotglobal avatar Jan 26 '25 20:01 oskardotglobal

@oskardotglobal , WOW I really happy it is working on OSX. Thank you for your testing.

buzzhuzz avatar Jan 27 '25 00:01 buzzhuzz

The pipeline works on M1 mac OSX 14.5

but doesn't seem to be able to repair this stl - Not sure if there needs to be knobs to tweak for every object or if it should be universal. image

czfa_flexframe_screw.stl.zip

from https://www.printables.com/model/647794-flexible-sturdy-phone-arm-100-printed

danpf avatar Feb 16 '25 18:02 danpf

Can't we just setup the venv for the user automatically?

Since ubuntu/debian is the officially supported distro, and those two comes with python preinstalled, wouldn't it be safe to assume that python will be available in whatever env orca-slicer is run in? atleast for linux

in addition to exposing the filterscript so that the user can edit it if they feel like it

klylabs avatar Feb 16 '25 19:02 klylabs

I have mixed feelings about this approach. On one hand, it really fills the gap in terms of functionality. But on the other hand, this solution involves too much of an environment that is out of control. Also, it feels not integrated. So I think I will not incorporate this into the main branch. But I commend this PR. Thank you

SoftFever avatar Mar 30 '25 11:03 SoftFever

@buzzhuzz great work!

@SoftFever this change is rather indirectly (via python -> pymeshlab -> meshlab) calling VCGlib to do the actual mesh fixing.

Would you accept a patch to just (optionally) depend on VCGlib instead? I am probably going to write a patch for it anyway for my own purposes but an answer now would help me gauge how much effort I should put into polishing it.

EliteTK avatar Jun 29 '25 00:06 EliteTK

@buzzhuzz great work!

@SoftFever this change is rather indirectly (via python -> pymeshlab -> meshlab) calling VCGlib to do the actual mesh fixing.

Would you accept a patch to just (optionally) depend on VCGlib instead? I am probably going to write a patch for it anyway for my own purposes but an answer now would help me gauge how much effort I should put into polishing it.

Thank you for your patience, and I apologize for the late response. I'm not sure how large vcglib is. If it's a small library, it should be fine, but if it's a large one, it might not be worth it. I haven't examined the details thoroughly, but I believe the mesh repair mainly addresses manifold issues and small holes. These issues are relatively easy to fix using the current CGAL mesh algorithms. If someone is interested in taking a look, that would be great; otherwise, when I have the time and interest, I will likely implement them myself. Thank you.

SoftFever avatar Sep 15 '25 15:09 SoftFever

@SoftFever so for size, I just compiled the VCG examples, and a statically linked, non-lto, stripped example comes out at 2.2M. Although I think if you say it should be possible to do this without a dependency, then maybe that's the best idea.

Honestly right now I've just not hit upon this often enough that it caused any problems. The orcaslicer calibration prints often cause these errors to appear, but the prints come out just fine... And for anything else, I can throw it into freecad to repair the mesh. And as a result, I haven't put any time into it yet :P

EliteTK avatar Sep 15 '25 16:09 EliteTK