holes
Returns the holes of a polyshape as an array of polyshape objects.
Category: Mathematics > Computational Geometry
Syntax
H = holes(pshape)
One polyshape per hole boundary.
H = holes(pshape, I)
Only the holes selected by the index I.
Description
The holes are returned as ordinary filled shapes, so you can ask for their area or centroid, or fill them. This is the inverse of making holes with subtract. To drop the holes from the shape, use rmholes.
Input arguments
pshape- A
polyshapeobject.
Output arguments
H- Array of
polyshapeobjects, each describing a hole as a solid polygon. If there are no holes it is an empty polyshape.
Example
Extract a hole
P = polyshape([0 4 4 0], [0 0 3 3]);
H = polyshape([1 2 2 1], [1 1 2 2]);
D = subtract(P, H);
h = holes(D);
disp(area(h))
disp(h.Vertices)
Output
1
1 1
2 1
2 2
1 2