Function Repository Resource:

PerforatePolygons

Make a hole in the middle of a polygon

Contributed by: Wolfram Research
 ResourceFunction["PerforatePolygons"][gr] creates a hole in the middle of each polygon in the 3D graphics gr. ResourceFunction["PerforatePolygons"][gr,r] create a hole of size r, where r is the ratio of the hole size to the polygon size. ResourceFunction["PerforatePolygons"][gr,"type"] decomposes into polygons of the specified "type" before creating holes.

Details

The default hole ratio is one half.
Each holed polygon is formed by a number of polygons equivalent to the number of sides of the original polygon.
ResourceFunction["PerforatePolygons"] works with primitives that are decomposable in polygons like Polyhedron.
ResourceFunction["PerforatePolygons"] works best when each surface in gr is a planar convex polygon.
Possible "type" specifications include:
 "Simple" simple polygons "Convex" convex polygons "Triangle" triangles

Examples

Basic Examples (4)

A set of polygons:

 In[1]:=
 Out[1]=

Random polygons:

 In[2]:=
 Out[2]=

A polyhedron:

 In[3]:=
 Out[3]=
 In[4]:=
 Out[4]=

Another polyhedron:

 In[5]:=
 Out[5]=

Make smaller holes:

 In[6]:=
 Out[6]=

Scope (14)

With offsets:

 In[7]:=
 Out[7]=

With Scaled:

 In[8]:=
 Out[8]=

With ImageScaled:

 In[9]:=
 Out[9]=

A square with a hole with another square inside:

 In[10]:=
 Out[10]=

Sometimes different triangulations can be produced:

 In[11]:=
 Out[11]=

PolygonDecomposition can be used:

 In[12]:=
 Out[12]=

Starting with a polygon with holes:

 In[13]:=
 Out[13]=

Using entities:

 In[14]:=
 Out[14]=

A Bohemian dome surface modifying the ratio of perforation:

 In[15]:=
 In[16]:=
 Out[16]=

PerforatePolygons works with other primitives:

 In[17]:=
 Out[17]=

Convert into a region:

 In[18]:=
 Out[18]=

Using VertexTextureCoordinates:

 In[19]:=
 In[20]:=
 Out[20]=

With VertexColors:

 In[21]:=
 Out[21]=

Disconnected polyhedra:

 In[22]:=
 Out[22]=

A polyhedron with a void:

 In[23]:=
 Out[23]=

A non-convex polyhedron:

 In[24]:=
 Out[24]=

A polyhedron with scaled coordinates:

 In[25]:=
 In[26]:=
 Out[26]=

A polyhedron with VertexNormals:

 In[27]:=
 In[28]:=
 Out[28]=

Applications (3)

A holed hexagonal grid:

 In[29]:=
 In[30]:=
 Out[30]=

Perforate a prism:

 In[31]:=
 Out[31]=

Outline the prism:

 In[32]:=
 Out[32]=

Convert polygons to tubes and vertices to spheres:

 In[33]:=
 In[34]:=
 Out[34]=

Nest perforations:

 In[35]:=
 Out[35]=

Possible Issues (1)

In 3D, if the vertices are not in a plane, the polygon triangulation can be unpredictable:

 In[36]:=
 Out[36]=

Neat Examples (3)

Beethoven missing his ninth:

 In[37]:=
 Out[37]=

A random winding polygon (this may take several minutes):

 In[38]:=
 In[39]:=
 Out[40]=

Decomposing random polygons and perforating twice:

 In[41]:=
 Out[41]=

Enrique Zeleny

Version History

• 2.0.0 – 02 November 2021
• 1.1.0 – 04 February 2021
• 1.0.0 – 01 October 2020