Texturize polycubes

Anton Antonov
​MathematicaForPrediction at WordPress​
​MathematicaForPrediction at GitHub​
January 2020

Introduction

This notebook shows how to texturize the polycube objects described in the Community post "[WSC19] Enumerating Polycubes".
The functions randomCubes, randomPolycube and renderPolycube used below are defined in the notebook
"EnumeratingPolycubesFinal.nb"
in the GitHub repository "Enumerating Polycubes" referenced in that post.
The polygon textures are created and placed with Wolfram Functions Repository function TexturizePolygons. See the related Community post "3D ornaments (by texturized polygons)".

Definitions

This function takes polycube graphics, extracts the polygons in it, and puts textures on them:
In[]:=
Clear[TexturizePolycube];​​Options[TexturizePolycube]=Options[ResourceFunction["TexturizePolygons"]];​​TexturizePolycube[gr_Graphics3D,opts:OptionsPattern[]]:=TexturizePolycube[gr,Automatic,opts];​​TexturizePolycube[gr_Graphics3D,spec_,opts:OptionsPattern[]]:=​​Block[{polys},​​polys=RegionBoundary@*CanonicalizePolyhedron/@Cases[gr〚1〛,_Cuboid,2];​​polys=Join@@Map[PolygonDecomposition,polys];​​ResourceFunction["TexturizePolygons"][polys,spec,opts]​​];

Experiments

Below are shown different experiments with the functions randomCubes and randomPolycube.

randomCubes

In[]:=
SeedRandom[211];​​pcs=Table[renderPolycube[randomCubes[3]],4];​​Grid[Table[TexturizePolycube[pc,sp,ColorFunction->"DarkRainbow"],{sp,{Automatic,Random}},{pc,pcs}],DividersAll]
Out[]=

randomPolycube

In[]:=
SeedRandom[891];​​pcs=Table[renderPolycube[randomPolycube[RandomInteger[{3,10}]]],12];
In[]:=
SeedRandom[232];​​Multicolumn[TexturizePolycube/@pcs,4,DividersAll]
Out[]=