cnr-isti-vclab / PyMeshLab

The open source mesh processing python library
GNU General Public License v3.0
780 stars 63 forks source link

.ply export with faces in meshlab, but not using pymeshlab #53

Closed mfdeveloper closed 3 years ago

mfdeveloper commented 3 years ago

Related issue: #28

SO: Windows 10 Pyymeshlab version: 0.1.9

Hello @alemuntoni !

First of all, thank you so much for this binding!! It's awesome use Meshlab with Python 😃

So, sadly I've got a similar problem reported by @KeithT in issue #28. I'm using pymeshlab: 0.1.9 installed with pip.

To reproduce that, follow the steps below:

Using Meshlab 2020.12 Desktop

  1. Import the file point-cloud.ply with a Point Cloud vertices. You should see a model like the picture below:

imagem

  1. Apply the filters: (exactly like describe by @KeithT )

RESULT: You will see a 3D model with faces like the picture below:

imagem

Using outdated meshlabserver.exe

  1. Use the command below:
meshlabserver.exe -i point-cloud.ply -o ./terrain.ply -m vc vn -s filter-script.mlx

RESULT: You will see a 3D model like the picture above

Using pymeshlab

Loading the .mlx script

import pymeshlab

meshset = pymeshlab.MeshSet()
meshset.load_new_mesh('list-vertex.ply')
meshset.load_filter_script('filter-script.mlx')
meshset.apply_filter_script()
meshset.save_current_mesh('files/complex_terrain/terrain.ply', save_vertex_color=True, save_vertex_normal=True, save_face_color=True, binary=False)  # I tried with `binary=True` too, but the exported .ply is the same

OR Using the apply_filter methods

meshset.apply_filter('point_cloud_simplification', samplenum=1000000, radius=radius_percentage, bestsampleflag=True, bestsamplepool=10, exactnumflag=False)
meshset.apply_filter('compute_normals_for_point_sets', k=10, smoothiter=0, flipflag=False, viewpos=point)
meshset.apply_filter('surface_reconstruction_screened_poisson', visiblelayer=False, fulldepth=5, depth=8, cgdepth=0, scale=1.0, samplespernode=1.5, pointweight=4, iters=8, confidence=False, preclean=False)
meshset.apply_filter('delete_current_mesh')

RESULT: The exported .ply not contains any faces like the picture below:

imagem

I think that the Surface Reconstruction: Screened Poisson filter wasn't applyied. But, this happens only using pymeshlab

Can you help me? The files .ply and .mlx are in attached .zip file

Thanks a lot for your attention

point-cloud-test.zip

alemuntoni commented 3 years ago

It seems to me that the issue is the same of #51. The filter "Compuete normals for points sets" has different behaviour run with double precision (default on python). Therefore, you should check parameters on MeshLab 2020.12d instead of MeshLab 2020.12. To get not inverted normals on 2020.12d I set the neighbour number parameter to 5 (instead of the default value 10).

mfdeveloper commented 3 years ago

Hello @alemuntoni !! So soorry for my late response. I could test again this library just a few days ago 😅

Thank you so much for your support. I did what you suggested, and used the k: 5 to the filter compute_normals_for_point_sets and IT WORKS NOW!! I'm using the version 0.20 of this library.

Moreover, I installed the version 2020.12d of Meshlab Desktop software, and re-generate the .mlx file. Even with k:5, the surface_reconstruction_poisson wasn't applyied correctly because I was using outdated structure of the script file.

Thanks a lot for your advice 😃