ACVD Clustering module
This module takes a vtk surface mesh (vtkPolyData) surface and returns a
uniformly meshed surface also as a vtkPolyData. It is based on research by:
S. Valette, and J. M. Chassery in
Approximated Centroidal Voronoi Diagrams for Uniform Polygonal Mesh Coarsening
Much of this code was translated from the C++ source code available on the
above website. Cython was used as much of the remeshing process is of an
iterative nature. This is currently a work in progress and any bugs within
this module do not reflect the true nature of ACVD developed by S. Valette.
This code has been tested with Ubuntu 14.10 and Windows 7 64-bit using
Python 2.7. It should be compatable with newer versions of Python, but this
has not been tested (yet).
$ pip install PyACVD
# Note: if "Clustering_Cython" cannot be imported after this install,
install for a single user (below)
- or for a single user -
$ pip install PyACVD --user
- or download the source code and execute the following from the download folder: -
$ python setup.py install
from PyACVD import Tests
# Run Stanford bunny remeshing example/test
# Run non-uniform sphere remeshing example/test
from PyACVD import Clustering
# Load mesh from file. One method would be to load a *.stl file using:
filename = 'file.stl'
stlReader = vtk.vtkSTLReader()
mesh = stlReader.GetOutput()
# Create clustering object
cobj = Clustering.Cluster(target)
# Generate clusters
# Generate uniform mesh
# Get mesh
remesh = cobj.ReturnNewMesh()
# The clustered original mesh and new mesh can be viewed with:
cobj.PlotClusters() # must run cobj.GenClusters first
cobj.PlotRemesh() # must run cobj.GenMesh first
vtkPolyData mesh should not contain duplicate points (i.e. adjcent faces
should share identical points). If not already done so, clean the mesh
The number of resulting points is limited by the available memory of the
host computer. If approaching the upper limit of your available memory,
reduce the "subratio" option when generating the mesh. As it will be
pointed out below, the coarser the mesh, the less accurate the solution.
The input mesh should be composed of one surface. Unexpected behavior
may result from a multiple input meshes, though some testing has shown
that it is stable.
Holes in the input mesh may not be filled by the module and will result in
a non-manifold output.
See individual modules for available options
- Cluster sizes are highly dependent on initial cluster placement.
- Clusters one face (or point) large will generate highly non-uniform
Please submit any bugs or issues with the code on the github repository below.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.