How to extract Poisson Disk Samples? #150
-
Howdy, I've been trying to perform a Poisson disk sampling of a mesh, and after trying to implement my own one for a while, I'd love to see how well the pymeshlab version works! Ideally I could get the points in space (or indices of nearest vertices), so that I can do further processing. I have an stl I've been using for testing, just a sphere, but haven't been able to get the data out in a dictionary or through a vertex quality array. How can I get to the samples? Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Actually, I just figured it out! In case it helps anyone else out, here's what I did:
trimesh is a really neat library with some helpful features basic features for mesh processing, I may be trying to phase it out in favor of entirely meshlab solutions though, as meshlab is quite a bit faster. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Here is a demo script for
#!/usr/bin/python3
import pymeshlab as ml
import numpy as np
import sys
ms = ml.MeshSet()
#Load an input mesh given as argument, or create a sphere
if len(sys.argv) > 1:
filename=sys.argv[1]
print("Loading mesh:", filename)
ms.load_new_mesh(filename)
else:
ms.apply_filter('sphere', subdiv = 4)
m = ms.current_mesh()
print("Input mesh:", m.vertex_number(), 'vertex', m.face_number(), 'faces' )
#Apply poisson_disk_sampling filter
#ml.print_filter_parameter_list('poisson_disk_sampling') #Filter help
ms.apply_filter('poisson_disk_sampling', samplenum = 1000, exactnumflag=True)
#Print output of the filter
m = ms.current_mesh()
samples=m.vertex_matrix()
print("Samples:\n", samples)
#Export last mesh in the MeshSet
print("Output mesh: output.ply", m.vertex_number(), 'vertex', m.face_number(), 'faces' )
ms.save_current_mesh("output.ply") Output of the script:
|
Beta Was this translation helpful? Give feedback.
Here is a demo script for
poisson_disk_sampling
. Please note that: