Class PMesh
- Since:
- 1.4.0
- Author:
- Michael Carleton
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprocessing.core.PShape
getMesh()
Returns a PShape object representing the smoothed mesh, with vertices moved to their smoothed positions.float
smooth
(boolean excludeBoundaryVertices) Performs one pass of simple laplacian smoothing on the mesh.float
smoothTaubin
(double λ, double µ, boolean excludeBoundaryVertices) Performs a single pass of Taubin smoothing.float
smoothWeighted
(boolean excludeBoundaryVertices) Performs one pass of weighted laplacian smoothing on the mesh.
-
Constructor Details
-
PMesh
public PMesh(processing.core.PShape mesh)
-
-
Method Details
-
smooth
public float smooth(boolean excludeBoundaryVertices) Performs one pass of simple laplacian smoothing on the mesh.During simple laplacian smoothing, vertices are moved to the barycenter center of their neighbors (equally-weighted), generally resulting in more isotropic mesh.
- Parameters:
excludeBoundaryVertices
- a boolean value indicating whether or not to exclude the boundary vertices from being smoothed. Generally this should be set to true, otherwise the mesh will shrink as it is smoothed.- Returns:
- the average displacement distance of the smoothed vertices
-
smoothWeighted
public float smoothWeighted(boolean excludeBoundaryVertices) Performs one pass of weighted laplacian smoothing on the mesh.This slightly more complex approximation of the Laplacian uses weights proportional to the inverse distance between the vertices, such that a vertex is "pulled" more towards its farther-away neighbours.
- Parameters:
excludeBoundaryVertices
- a boolean value indicating whether or not to exclude the boundary vertices from being smoothed. Generally this should be set to true, otherwise the mesh will shrink as it is smoothed.- Returns:
- the displacement distance of the most displaced vertex
-
smoothTaubin
public float smoothTaubin(double λ, double µ, boolean excludeBoundaryVertices) Performs a single pass of Taubin smoothing. Each Taubin pass peforms two laplacian smoothing passes on the mesh (shrinking then inflating) in an effort to preserve the volume of the mesh.In geometric terms, Taubin smoothing diffuses the mesh inwards and outwards to attenuate details while keeping the surface in roughly the same position. Although this approach is not guaranteed to preserve mesh volume, it does a good job if the parameters λ and µ are well chosen. On the down side, Taubin smoothing requires more iterations to achieve a level of smoothing comparable to other methods.
A good starting point for λ and µ is a µ negative value that is mildly larger than λ: i.e.
λ=0.2
,µ=-0.201
.- Parameters:
\u03bb
- Controls the amount of inward diffusion / shrinkage. Should be positive.µ
- Controls the amount of outward diffusion / inflation. Should be negative, with an absolute value greater than lambda.excludeBoundaryVertices
- A boolean value indicating whether or not to exclude the boundary vertices from being smoothed, preserving their original location and the area of the mesh.- Returns:
- the displacement distance of the most displaced vertex during the shrinkage.
-
getMesh
public processing.core.PShape getMesh()Returns a PShape object representing the smoothed mesh, with vertices moved to their smoothed positions.- Returns:
- a PShape object representing the smoothed mesh
-