Povray code-j-tic.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/>
 \*/

/\* Augmented truncated cube \*/
#include "poly-textures.inc"

#include "oct-sym.inc"

#local FacesStatus = array[NumCubeFullFaces];
#for (F, 0, NumCubeFullFaces - 1, 1)
 #declare FacesStatus[F] = 0;
#end

#local AugmentedFaces = array[2];
#local NumAugmentings = 0;
#macro Augment(Face)
 #declare FacesStatus[Face] = 1;
 #declare AugmentedFaces[NumAugmentings] = Face;
 #declare NumAugmentings = NumAugmentings + 1;
#end

#ifdef (AugmentBase)
 Augment(0)
#end
#ifdef (AugmentPara)
 Augment(1)
#end

#declare NumPolyVertices = NumCubeVertices;
#declare PolyVertices = CubeVertices;
#declare NumPolyEdges = NumCubeEdges;
#declare PolyEdges = CubeEdges;
#declare NumPolyFaces = NumCubeFullFaces;
#declare PolyFaces = CubeFullFaces;
#declare ReserveVertices = 4 \* NumAugmentings;
#include "trunc.inc"

// Vertices
#local OldNumVertices = NumVertices;
#declare NumVertices = NumVertices + ReserveVertices;

#local MidEdgeScale = 2 - sqrt(2);
#local MidFaceScale = 1 + sqrt(2) / 2;
#for (F, 0, NumAugmentings - 1, 1)
 #local Face = AugmentedFaces[F];
 #local MP = OctVertices[Face];
 #for (V, 0, 3, 1)
 #local To = OldNumVertices + 4 \* F + V;
 #local Edge = mod(CubeFaceEdges[F][V], NumCubeEdges);
 #local MidEdge = (Vertices[2 \* Edge] + Vertices[2 \* Edge + 1]) / 2;
 #declare Vertices[To] = MidEdge \* MidEdgeScale + MP \* MidFaceScale;
 #end
#end

#declare Circumradius = sqrt(11 + 4 \* sqrt(2));
// Edges
#local OldNumEdges = NumEdges;
#declare NumEdges = NumEdges + 12 \* NumAugmentings;
#local OldEdges = Edges;

#declare Edges = array[NumEdges][2];
#for (E, 0, OldNumEdges - 1, 1)
 #declare Edges[E][0] = OldEdges[E][0];
 #declare Edges[E][1] = OldEdges[E][1];
#end
#for (A, 0, NumAugmentings - 1, 1)
 #local To = OldNumEdges + 12 \* A;
 #local Face = AugmentedFaces[A];
 #for (E, 0, 3, 1)
 #local Vert = OldNumVertices + 4 \* A;
 #declare Edges[To + 3 \* E][0] = FullFaces[Face][2 \* E];
 #declare Edges[To + 3 \* E][1] = Vert + E;
 #declare Edges[To + 3 \* E + 1][0] = FullFaces[Face][2 \* E + 1];
 #declare Edges[To + 3 \* E + 1][1] = Vert + E;
 #declare Edges[To + 3 \* E + 2][0] = Vert + E;
 #declare Edges[To + 3 \* E + 2][1] = Vert + mod(E + 1, 4);
 #end
#end

// Full Faces
#local OldNumFullFaces = NumFullFaces;
#local OldFullFaces = FullFaces;
#local OldFullFaceSizes = FullFaceSizes;
#declare NumFullFaces = NumFullFaces + 8 \* NumAugmentings;
#declare FullFaces = array[NumFullFaces][8];
#declare FullFaceSizes = array[NumFullFaces];
#declare FullFaceTextures = array[NumFullFaces];

#for (F, 0, OldNumFullFaces - 1, 1)
 #for (V, 0, OldFullFaceSizes[F] - 1, 1)
 #declare FullFaces[F][V] = OldFullFaces[F][V];
 #end
 #declare FullFaceSizes[F] = OldFullFaceSizes[F];
 #declare FullFaceTextures[F] = BaseTexture;
#end

#for (A, 0, NumAugmentings - 1, 1)
 #local Face = AugmentedFaces[A];
 #local NewVerticesBase = OldNumVertices + 4 \* A;
 // Firstly, make old face the cap of the augment
 #for (V, 0, 3, 1)
 #declare FullFaces[Face][V] = NewVerticesBase + V;
 #end
 #declare FullFaceSizes[Face] = 4;
 #declare FullFaceTextures[Face] = MedialTexture;

 // Now the eight new faces
 #local To = OldNumFullFaces + 8 \* A;
 #for (V, 0, 7, 1)
 #declare FullFaces[To + V][0] = OldFullFaces[Face][V];
 #declare FullFaces[To + V][1] = OldFullFaces[Face][mod(V + 1, 8)];
 #end
 #for (V, 0, 3, 1)
 #declare FullFaces[To + 2 \* V][2] = NewVerticesBase + V;
 #declare FullFaces[To + 2 \* V + 1][2] = NewVerticesBase + mod(V + 1, 4);
 #declare FullFaces[To + 2 \* V + 1][3] = NewVerticesBase + V;
 #declare FullFaceSizes[To + 2 \* V] = 3;
 #declare FullFaceSizes[To + 2 \* V + 1] = 4;
 #declare FullFaceTextures[To + 2 \* V] = SnubTexture;
 #declare FullFaceTextures[To + 2 \* V + 1] = RhombTexture;
 #end
#end

// Faces
#declare NumFaces = 6 \* NumCubeFullFaces + NumCubeVertices +
 8 \* NumAugmentings;
#declare Faces = array[NumFaces][3];
#declare FaceTextureIndex = array[NumFaces];

#local NextFace = 0;
#for (FF, 0, NumFullFaces - 1, 1)
 #for (F, 0, FullFaceSizes[FF] - 3, 1)
 #declare Faces[NextFace][0] = FullFaces[FF][0];
 #declare Faces[NextFace][1] = FullFaces[FF][F + 1];
 #declare Faces[NextFace][2] = FullFaces[FF][F + 2];
 #declare FaceTextureIndex[NextFace] = FullFaceTextures[FF];
 #declare NextFace = NextFace + 1;
 #end
#end

```