Povray code-j-tut.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 "tet-sym.inc"

#local FacesStatus = array[NumTetFaces];
#for (F, 0, NumTetFaces - 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 = NumTetVertices;
#declare PolyVertices = TetVertices;
#declare NumPolyEdges = NumTetEdges;
#declare PolyEdges = TetEdges;
#declare NumPolyFaces = NumTetFaces;
#declare PolyFaces = TetFaces;
#declare ReserveVertices = 3 \* NumAugmentings;
#include "trunc.inc"

// Vertices
#local OldNumVertices = NumVertices;
#declare NumVertices = NumVertices + ReserveVertices;
#local MidEdgeScale = 2 / 3;
#local MidFaceScale = 5 / 18;
#for (F, 0, NumAugmentings - 1, 1)
 #local Face = AugmentedFaces[F];
 #local MP = <0, 0, 0>;
 #for (V, 0, 5, 1)
 #declare MP = MP + Vertices[FullFaces[Face][V]];
 #end
 #for (V, 0, 2, 1)
 #local To = OldNumVertices + 3 \* F + V;
 #local Vertex1 = Vertices[FullFaces[Face][2 \* V]];
 #local Vertex2 = Vertices[FullFaces[Face][2 \* V + 1]];
 #local MidEdge = (Vertex1 + Vertex2) / 2;
 #declare Vertices[To] = MidEdge \* MidEdgeScale + MP \* MidFaceScale;
 #end
#end

#declare Circumradius = sqrt(19 / 2);
// Edges
#local OldNumEdges = NumEdges;
#declare NumEdges = NumEdges + 9 \* 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 + 9 \* A;
 #local Face = AugmentedFaces[A];
 #for (E, 0, 2, 1)
 #local Vert = OldNumVertices + 3 \* 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, 3);
 #end
#end

// Full Faces
#local OldNumFullFaces = NumFullFaces;
#local OldFullFaces = FullFaces;
#local OldFullFaceSizes = FullFaceSizes;
#declare NumFullFaces = NumFullFaces + 6 \* NumAugmentings;
#declare FullFaces = array[NumFullFaces][6];
#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 + 3 \* A;
 // Firstly, make old face the cap of the augment
 #for (V, 0, 2, 1)
 #declare FullFaces[Face][V] = NewVerticesBase + V;
 #end
 #declare FullFaceSizes[Face] = 3;
 #declare FullFaceTextures[Face] = MedialTexture;

 // Now the eight new faces
 #local To = OldNumFullFaces + 6 \* A;
 #for (V, 0, 5, 1)
 #declare FullFaces[To + V][0] = OldFullFaces[Face][V];
 #declare FullFaces[To + V][1] = OldFullFaces[Face][mod(V + 1, 6)];
 #end
 #for (V, 0, 2, 1)
 #declare FullFaces[To + 2 \* V][2] = NewVerticesBase + V;
 #declare FullFaces[To + 2 \* V + 1][2] = NewVerticesBase + mod(V + 1, 3);
 #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 = 4 \* NumTetFaces + NumTetVertices +
 6 \* 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

```