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

/\* Dump \*/
#if (clock = 0)
 /\* Use this to dump the image data \*/
 #debug "---Image data---\n"

 /\* Convert a vector to a string \*/
 #macro VStr(V)
 concat("<", str(V.x, 12, 9), ", ", str(V.y, 12, 9), ", ", str(V.z, 12, 9), ">")
 #end

 // Vertices
 #ifndef (OmitVertices)
 #local LastVert = 0;
 #ifndef (OmitFaces)
 #for (F, 0, NumFaces - 1, 1)
 #for (V, 0, 2, 1)
 #ifdef (Faces[F][V])
 #if (Faces[F][V] > LastVert)
 #declare LastVert = Faces[F][V];
 #end
 #end
 #end
 #end
 #end
 #ifndef (OmitEdges)
 #for (E, 0, NumEdges - 1, 1)
 #for (V, 0, 1, 1)
 #ifdef (Edges[E][V])
 #if (Edges[E][V] > LastVert)
 #declare LastVert = Edges[E][V];
 #end
 #end
 #end
 #end
 #end

 #if (LastVert = NumVertices - 1)
 #debug concat("NumVertices = ", str(NumVertices, 1, 0), "\n")
 #elseif (LastVert >= NumVertices)
 #debug concat("NumVertices = ", str(NumVertices, 1, 0), " (+ ", str(LastVert - NumVertices + 1, 1, 0), ")\n")
 #else
 #debug concat("NumVertices = ", str(NumVertices, 1, 0), " (- ", str(-LastVert + NumVertices - 1, 1, 0), ")\n")
 #end
 #for (V, 0, LastVert, 1)
 #if (V = NumVertices)
 #debug "-----------------------------------------------------------------------------\n"
 #end
 #ifdef (Vertices[V])
 #debug concat("Vertices[", str(V, 3, 0), "] = ", VStr(Vertices[V]), ", Radius = ", str(vlength(Vertices[V]), 11, 9), "\n")
 #else
 #debug concat("Vertices[", str(V, 3, 0), "] undefined\n")
 #end
 #end
 #ifdef (Circumradius)
 #debug concat("Circumradius = ", str(Circumradius, 6, 9), "\n\n")
 #else
 #warning "Circumradius not declared"
 #end
 #end

 // Edges
 #ifndef (OmitEdges)
 #debug concat("NumEdges = ", str(NumEdges, 1, 0), "\n")
 #for (E, 0, NumEdges - 1, 1)
 #debug concat("Edges[", str(E, 3, 0), "] = {")
 #local Ok = true;
 #ifdef (Edges[E][0])
 #debug str(Edges[E][0], 3, 0)
 #else
 #debug "---"
 #declare Ok = false;
 #end
 #debug ", "
 #ifdef (Edges[E][1])
 #debug str(Edges[E][1], 3, 0)
 #else
 #debug "---"
 #declare Ok = false;
 #end
 #if (Ok)
 #ifndef (Vertices[Edges[E][0]])
 #declare Ok = false;
 #end
 #ifndef (Vertices[Edges[E][1]])
 #declare Ok = false;
 #end
 #end
 #if (Ok)
 #debug concat("}, length = ", str(vlength(Vertices[Edges[E][1]] - Vertices[Edges[E][0]]), 9, 12), "\n")
 #else
 #debug "}\n"
 #end
 #end
 #end

 // Full faces
 #ifndef (OmitFaces)
 #ifdef (FullFaces)
 #debug concat("\nNumFullFaces = ", str(NumFullFaces, 1, 0), "\n")
 #for (F, 0, NumFullFaces - 1, 1)
 #debug concat("FullFaces[", str(F, 3, 0), "] = {")
 #for (I, 0, FullFaceSizes[F] - 1, 1)
 #if (I > 0)
 #debug ","
 #end
 #ifdef (FullFaces[F][I])
 #debug str(FullFaces[F][I], 4, 0)
 #else
 #debug "----"
 #end
 #end
 #debug "}"
 #local Ok = true;
 #ifndef (OmitVertices)
 #local Centre = <0, 0, 0>;
 #local NumSides = FullFaceSizes[F];
 #for (V, 0, NumSides - 1, 1)
 #ifdef (FullFaces[F][V])
 #ifdef (Vertices[FullFaces[F][V]])
 #declare Centre = Centre + Vertices[FullFaces[F][V]];
 #else
 #declare Ok = false;
 #end
 #else
 #declare Ok = false;
 #end
 #end
 #if (Ok)
 #debug concat(", Inradius = ",
 str(vlength(Centre) / NumSides, 12, 9))
 #else
 #debug "\n"
 #end
 #end
 #debug "\n"
 #end
 #end
 #end

 // Faces
 #ifndef (OmitFaces)
 #debug concat("\nNumFaces = ", str(NumFaces, 1, 0), "\n")
 #for (F, 0, NumFaces - 1, 1)
 #local Ok = true;
 #debug concat("Faces[", str(F, 3, 0), "] = {")
 #for (V, 0, 2, 1)
 #if (V > 0)
 #debug ", "
 #end
 #ifndef (Faces[F][V])
 #declare Ok = false;
 #debug "---"
 #else
 #debug str(Faces[F][V], 3, 0)
 #ifndef (Vertices[Faces[F][V]])
 #declare Ok = false;
 #end
 #end
 #end
 #if (Ok)
 #local Side1 = vlength(Vertices[Faces[F][0]] - Vertices[Faces[F][1]]);
 #local Side2 = vlength(Vertices[Faces[F][1]] - Vertices[Faces[F][2]]);
 #local Side3 = vlength(Vertices[Faces[F][2]] - Vertices[Faces[F][0]]);
 #local S = (Side1 + Side2 + Side3) / 2;
 #declare Heron = sqrt(S \* (S - Side1) \* (S - Side2) \* (S - Side3));
 #debug concat("}, area = ", str(Heron, 12, 9))
 #else
 #debug "}\n"
 #end
 #ifdef(FaceTextureIndex)
 #debug concat(", Texture = ", str(FaceTextureIndex[F], 2, 0), "\n")
 #else
 #debug "\n"
 #end
 #end
 #end
#end // if clock = 0

```