rmslivers

Removes thin parts of a polyshape narrower than a given width.

Category: Mathematics > Computational Geometry

Syntax

pshape = rmslivers(pshape, tol)

Cleans parts of the shape that are thinner than about tol.

Description

Slivers appear as artefacts of Boolean operations or buffering: very thin spikes, or strips that join two pieces. rmslivers removes them while leaving the main body almost unchanged. A larger tol removes thicker features, so choose it small relative to the features that matter.

Input arguments

pshape
A polyshape object.
tol
Non-negative width threshold, in coordinate units.

Output arguments

pshape
The cleaned polyshape. Slivers that disappear may reduce NumRegions.

Example

Dropping a thin strip

A = polyshape([0 2 2 0], [0 0 2 2]);
B = addboundary(A, [5 5.02 5.02 5], [0 0 2 2]);
C = rmslivers(B, 0.05);
[area(B) area(C)]
C.NumRegions
Output
ans = 1×2

    4.0400    4.0000
ans = 1

See also

polybuffer rmboundary issimplified polyshape