Reduce the number of faces and vertices in a patch object while retaining the overall shape of the patch.
The input patch can be represented by a structure fv with the
fields faces
and vertices
, by two matrices faces and
vertices (see, e.g., the result of isosurface
), or by a
handle to a patch object patch_handle (see ‘patch’).
The number of faces and vertices in the patch is reduced by iteratively collapsing the shortest edge of the patch to its midpoint (as discussed, e.g., here: http://libigl.github.io/libigl/tutorial/tutorial.html#meshdecimation).
Currently, only patches consisting of triangles are supported. The resulting patch also consists only of triangles.
If reducepatch
is called with a handle to a valid patch
patch_handle, and without any output arguments, then the given
patch is updated immediately.
If the reduction_factor is omitted, the resulting structure reduced_fv includes approximately 50% of the faces of the original patch. If reduction_factor is a fraction between 0 (excluded) and 1 (excluded), a patch with approximately the corresponding fraction of faces is determined. If reduction_factor is an integer greater than or equal to 1, the resulting patch has approximately reduction_factor faces. Depending on the geometry of the patch, the resulting number of faces can differ from the given value of reduction_factor. This is especially true when many shared vertices are detected.
For the reduction, it is necessary that vertices of touching faces are
shared. Shared vertices are detected automatically. This detection can be
skipped by passing the optional string argument "fast"
.
With the optional string arguments "verbose"
, additional status
messages are printed to the command window.
Any string input arguments must be passed after all other arguments.
If called with one output argument, the reduced faces and vertices are
returned in a structure reduced_fv with the fields faces
and
vertices
(see the one output option of isosurface
).
If called with two output arguments, the reduced faces and vertices are returned in two separate matrices reduced_faces and reduced_vertices.
See also: isosurface, isonormals, reducevolume, patch.
The following code
[x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2); val = x.^2 + y.^2 + z.^2; fv = isosurface (x, y, z, val, 1); figure; ax1 = subplot (1, 2, 1); patch (fv, "FaceColor", "g"); view (3); axis equal; title ("Sphere with all faces"); ax2 = subplot(1, 2, 2); patch (reducepatch (fv, 72), "FaceColor", "g"); view (3); axis equal; title ("Sphere with reduced number of faces"); linkprop ([ax1, ax2], {"CameraPosition", "CameraUpVector"});
Produces the following figure
Figure 1 |
---|
Package: octave