Povray code-co-reg.inc

```
/\* This program is free software: you can redistribute it and/or modify it
 \* under the terms of the GNU General Public License as published by the Free
 \* Software Foundation, either version 3 of the License, or (at your option)
 \* any later version.
 \*
 \* This program is distributed in the hope that it will be useful, but WITHOUT
 \* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 \* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 \* more details.
 \*
 \* You should have received a copy of the GNU General Public License along with
 \* this program. If not, see <http://www.gnu.org/licenses/>
 \*/

/\* Cuboctahedron regiment \*/

#include "oct-sym.inc"

// Vertices
#declare NumVertices = NumOctEdges;
#declare Vertices = array[NumVertices];

#for (V, 0, NumVertices - 1, 1)
 #declare Vertices[V] = OctVertices[OctEdges[V][0]] +
 OctVertices[OctEdges[V][1]];
#end

#declare Circumradius = 2;

// Edges
#declare NumEdges = 2 \* NumOctEdges;
#declare Edges = array[NumEdges][2];

#for (F, 0, NumOctFaces - 1, 1)
 #for (E, 0, 2, 1)
 #declare Edges[3 \* F + E][0] = OctFaceEdges[F][E];
 #declare Edges[3 \* F + E][1] = OctFaceEdges[F][mod(E + 1, 3)];
 #end
#end

// Full Faces
#declare SquareFullFacesStart = 0;
#declare NumSquareFullFaces = NumCubeFullFaces;
#declare TriFullFacesStart = SquareFullFacesStart + NumSquareFullFaces;
#declare NumTriFullFaces = NumOctFaces;
#declare HexFullFacesStart = TriFullFacesStart + NumTriFullFaces;
#declare NumHexFullFaces = 4;
#declare NumFullFaces = HexFullFacesStart + NumHexFullFaces;
#declare FullFaces = array[NumFullFaces][6];
#declare FullFaceSizes = array[NumFullFaces];

// Squares
#for (F, 0, NumSquareFullFaces - 1, 1)
 #local To = SquareFullFacesStart + F;
 #for (V, 0, 3, 1)
 #declare FullFaces[To][V] = mod(CubeFaceEdges[F][V], NumCubeEdges);
 #end
 #declare FullFaceSizes[To] = 4;
#end

// Triangles
#for (F, 0, NumTriFullFaces - 1, 1)
 #local To = TriFullFacesStart + F;
 #for (V, 0, 2, 1)
 #declare FullFaces[To][V] = mod(OctFaceEdges[F][V], NumOctEdges);
 #end
 #declare FullFaceSizes[To] = 3;
#end

// Hexagons
#for (F, 0, NumHexFullFaces - 1, 1)
 #local To = HexFullFacesStart + F;
 #for (V, 0, 2, 1)
 #local Edge = mod(OctFaceEdges[F][V], NumOctEdges);
 #local Face = CubeEdges[Edge][0] + CubeEdges[Edge][1] - F;
 #for (VV, 0, 2, 1)
 #if (mod(OctFaceEdges[Face][VV], NumOctEdges) = Edge)
 #declare FullFaces[To][2 \* V ] =
 OctFaceEdges[Face][mod(VV + 1, 3)];
 #declare FullFaces[To][2 \* V + 1] =
 OctFaceEdges[Face][mod(VV + 2, 3)];
 #end
 #end
 #end
 #declare FullFaceSizes[To] = 6;
#end

// Faces
#declare NumSquareFaces = 2 \* NumSquareFullFaces;
#declare NumTriangleFaces = NumTriFullFaces;
#declare NumHexagonFaces = 4 \* NumHexFullFaces;

#declare SquareFaces = array[NumSquareFaces][3];
#declare TriangleFaces = array[NumTriangleFaces][3];
#declare HexagonFaces = array[NumHexagonFaces][3];

#include "macros.inc"

TriangulateConvex(SquareFaces, 0, SquareFullFacesStart, NumSquareFullFaces, 4)
TriangulateConvex(TriangleFaces, 0, TriFullFacesStart, NumTriFullFaces, 3)
TriangulateConvex(HexagonFaces, 0, HexFullFacesStart, NumHexFullFaces, 6)

```