Category : Printer + Display Graphics
Archive   : PLYDAT.ZIP
Filename : TEAPOT.C

 
Output of file : TEAPOT.C contained in archive : PLYDAT.ZIP

/* Generate Polyray data file for the UTAH Teapot */
#include

/* STEPS specifies how many tiles each surface patch should be broken
into when displayed. */

#define U_Steps 3
#define V_Steps 3
#define Quality 1
#define Flatness 0.01

FILE *datfile;

typedef short patchdef[4][4]; /* Surface patch definition */
typedef double vertex[3]; /* Three dimensional point */

/* Three dimensional points are stored in arrays of type VERTEX.
The following definitions are used to access the individual
coodinates of a point. */

#define X 0
#define Y 1
#define Z 2

/* Surface patch definitions. Each patch is a four by four array of three
dimensional points. To save space, the patches are stored as indices
into a table of vertices defined below. */

static patchdef patches[] = {

/* Rim */

{{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15, 16}
},
{
{4, 17, 18, 19},
{8, 20, 21, 22},
{12, 23, 24, 25},
{16, 26, 27, 28}
},
{
{19, 29, 30, 31},
{22, 32, 33, 34},
{25, 35, 36, 37},
{28, 38, 39, 40}
},
{
{31, 41, 42, 1},
{34, 43, 44, 5},
{37, 45, 46, 9},
{40, 47, 48, 13}
},

/* Body */

{
{13, 14, 15, 16},
{49, 50, 51, 52},
{53, 54, 55, 56},
{57, 58, 59, 60}
},

{
{16, 26, 27, 28},
{52, 61, 62, 63},
{56, 64, 65, 66},
{60, 67, 68, 69}
},

{
{28, 38, 39, 40},
{63, 70, 71, 72},
{66, 73, 74, 75},
{69, 76, 77, 78}
},

{
{40, 47, 48, 13},
{72, 79, 80, 49},
{75, 81, 82, 53},
{78, 83, 84, 57}
},

{
{57, 58, 59, 60},
{85, 86, 87, 88},
{89, 90, 91, 92},
{93, 94, 95, 96}
},

{
{60, 67, 68, 69},
{88, 97, 98, 99},
{92, 100, 101, 102},
{96, 103, 104, 105}
},

{
{69, 76, 77, 78},
{99, 106, 107, 108},
{102, 109, 110, 111},
{105, 112, 113, 114}
},

{
{78, 83, 84, 57},
{108, 115, 116, 85},
{111, 117, 118, 89},
{114, 119, 120, 93}
},

/* Handle */

{
{121, 122, 123, 124},
{125, 126, 127, 128},
{129, 130, 131, 132},
{133, 134, 135, 136}
},

{
{124, 137, 138, 121},
{128, 139, 140, 125},
{132, 141, 142, 129},
{136, 143, 144, 133}
},

{
{133, 134, 135, 136},
{145, 146, 147, 148},
{149, 150, 151, 152},
{69, 153, 154, 155}
},

{
{136, 143, 144, 133},
{148, 156, 157, 145},
{152, 158, 159, 149},
{155, 160, 161, 69}
},

/* Spout */

{
{162, 163, 164, 165},
{166, 167, 168, 169},
{170, 171, 172, 173},
{174, 175, 176, 177}
},

{
{165, 178, 179, 162},
{169, 180, 181, 166},
{173, 182, 183, 170},
{177, 184, 185, 174}
},

{
{174, 175, 176, 177},
{186, 187, 188, 189},
{190, 191, 192, 193},
{194, 195, 197, 197}
},

{
{177, 184, 185, 174},
{189, 198, 199, 186},
{193, 200, 201, 190},
{197, 202, 203, 194}
},

/* Lid */

{
{204, 204, 204, 204},
{207, 208, 209, 210},
{211, 211, 211, 211},
{212, 213, 214, 215}
},

{
{204, 204, 204, 204},
{210, 217, 218, 219},
{211, 211, 211, 211},
{215, 220, 221, 222}
},

{
{204, 204, 204, 204},
{219, 224, 225, 226},
{211, 211, 211, 211},
{222, 227, 228, 229}
},

{
{204, 204, 204, 204},
{226, 230, 231, 207},
{211, 211, 211, 211},
{229, 232, 233, 212}
},

{
{212, 213, 214, 215},
{234, 235, 236, 237},
{238, 239, 240, 241},
{242, 243, 244, 245}
},

{
{215, 220, 221, 222},
{237, 246, 247, 248},
{241, 249, 250, 251},
{245, 252, 253, 254}
},

{
{222, 227, 228, 229},
{248, 255, 256, 257},
{251, 258, 259, 260},
{254, 261, 262, 263}
},

{
{229, 232, 233, 212},
{257, 264, 265, 234},
{260, 266, 267, 238},
{263, 268, 269, 242}
},

/* Bottom */

{
{270, 270, 270, 270},
{279, 280, 281, 282},
{275, 276, 277, 278},
{271, 272, 273, 274}
},

{
{270, 270, 270, 270},
{282, 289, 290, 291},
{278, 286, 287, 288},
{274, 283, 284, 285}
},

{
{270, 270, 270, 270},
{291, 298, 299, 300},
{288, 295, 296, 297},
{285, 292, 293, 294}
},

{
{270, 270, 270, 270},
{300, 305, 306, 279},
{297, 303, 304, 275},
{294, 301, 302, 271}
}
};

#define npatches ((sizeof patches) / (16 * sizeof(short)))

/* Vertex table. Vertices in this table are addressed by the indices in
the patch table above. Note that index 0 is never used. */

static vertex vertices[] = {

{ 0, 0, 0 }, /* 0: Throwaway */

{ 1.4, 0, 2.4 }, /* 1 */
{ 1.4, -0.784, 2.4 }, /* 2 */
{ 0.784, -1.4, 2.4 }, /* 3 */
{ 0, -1.4, 2.4 }, /* 4 */
{ 1.3375, 0, 2.53125 }, /* 5 */

{ 1.3375, -0.749, 2.53125 }, /* 6 */
{ 0.749, -1.3375, 2.53125 }, /* 7 */
{ 0, -1.3375, 2.53125 }, /* 8 */
{ 1.4375, 0, 2.53125 }, /* 9 */
{ 1.4375, -0.805, 2.53125 }, /* 10 */

{ 0.805, -1.4375, 2.53125 }, /* 11 */
{ 0, -1.4375, 2.53125 }, /* 12 */
{ 1.5, 0, 2.4 }, /* 13 */
{ 1.5, -0.84, 2.4 }, /* 14 */
{ 0.84, -1.5, 2.4 }, /* 15 */

{ 0, -1.5, 2.4 }, /* 16 */
{ -0.784, -1.4, 2.4 }, /* 17 */
{ -1.4, -0.784, 2.4 }, /* 18 */
{ -1.4, 0, 2.4 }, /* 19 */
{ -0.749, -1.3375, 2.53125 }, /* 20 */

{ -1.3375, -0.749, 2.53125 }, /* 21 */
{ -1.3375, 0, 2.53125 }, /* 22 */
{ -0.805, -1.4375, 2.53125 }, /* 23 */
{ -1.4375, -0.805, 2.53125 }, /* 24 */
{ -1.4375, 0, 2.53125 }, /* 25 */

{ -0.84, -1.5, 2.4 }, /* 26 */
{ -1.5, -0.84, 2.4 }, /* 27 */
{ -1.5, 0, 2.4 }, /* 28 */
{ -1.4, 0.784, 2.4 }, /* 29 */
{ -0.784, 1.4, 2.4 }, /* 30 */

{ 0, 1.4, 2.4 }, /* 31 */
{ -1.3375, 0.749, 2.53125 }, /* 32 */
{ -0.749, 1.3375, 2.53125 }, /* 33 */
{ 0, 1.3375, 2.53125 }, /* 34 */
{ -1.4375, 0.805, 2.53125 }, /* 35 */

{ -0.805, 1.4375, 2.53125 }, /* 36 */
{ 0, 1.4375, 2.53125 }, /* 37 */
{ -1.5, 0.84, 2.4 }, /* 38 */
{ -0.84, 1.5, 2.4 }, /* 39 */
{ 0, 1.5, 2.4 }, /* 40 */

{ 0.784, 1.4, 2.4 }, /* 41 */
{ 1.4, 0.784, 2.4 }, /* 42 */
{ 0.749, 1.3375, 2.53125 }, /* 43 */
{ 1.3375, 0.749, 2.53125 }, /* 44 */
{ 0.805, 1.4375, 2.53125 }, /* 45 */

{ 1.4375, 0.805, 2.53125 }, /* 46 */
{ 0.84, 1.5, 2.4 }, /* 47 */
{ 1.5, 0.84, 2.4 }, /* 48 */
{ 1.75, 0, 1.875 }, /* 49 */
{ 1.75, -0.98, 1.875 }, /* 50 */

{ 0.98, -1.75, 1.875 }, /* 51 */
{ 0, -1.75, 1.875 }, /* 52 */
{ 2, 0, 1.35 }, /* 53 */
{ 2, -1.12, 1.35 }, /* 54 */
{ 1.12, -2, 1.35 }, /* 55 */

{ 0, -2, 1.35 }, /* 56 */
{ 2, 0, 0.9 }, /* 57 */
{ 2, -1.12, 0.9 }, /* 58 */
{ 1.12, -2, 0.9 }, /* 59 */
{ 0, -2, 0.9 }, /* 60 */

{ -0.98, -1.75, 1.875 }, /* 61 */
{ -1.75, -0.98, 1.875 }, /* 62 */
{ -1.75, 0, 1.875 }, /* 63 */
{ -1.12, -2, 1.35 }, /* 64 */
{ -2, -1.12, 1.35 }, /* 65 */

{ -2, 0, 1.35 }, /* 66 */
{ -1.12, -2, 0.9 }, /* 67 */
{ -2, -1.12, 0.9 }, /* 68 */
{ -2, 0, 0.9 }, /* 69 */
{ -1.75, 0.98, 1.875 }, /* 70 */

{ -0.98, 1.75, 1.875 }, /* 71 */
{ 0, 1.75, 1.875 }, /* 72 */
{ -2, 1.12, 1.35 }, /* 73 */
{ -1.12, 2, 1.35 }, /* 74 */
{ 0, 2, 1.35 }, /* 75 */

{ -2, 1.12, 0.9 }, /* 76 */
{ -1.12, 2, 0.9 }, /* 77 */
{ 0, 2, 0.9 }, /* 78 */
{ 0.98, 1.75, 1.875 }, /* 79 */
{ 1.75, 0.98, 1.875 }, /* 80 */

{ 1.12, 2, 1.35 }, /* 81 */
{ 2, 1.12, 1.35 }, /* 82 */
{ 1.12, 2, 0.9 }, /* 83 */
{ 2, 1.12, 0.9 }, /* 84 */
{ 2, 0, 0.45 }, /* 85 */

{ 2, -1.12, 0.45 }, /* 86 */
{ 1.12, -2, 0.45 }, /* 87 */
{ 0, -2, 0.45 }, /* 88 */
{ 1.5, 0, 0.225 }, /* 89 */
{ 1.5, -0.84, 0.225 }, /* 90 */

{ 0.84, -1.5, 0.225 }, /* 91 */
{ 0, -1.5, 0.225 }, /* 92 */
{ 1.5, 0, 0.15 }, /* 93 */
{ 1.5, -0.84, 0.15 }, /* 94 */
{ 0.84, -1.5, 0.15 }, /* 95 */

{ 0, -1.5, 0.15 }, /* 96 */
{ -1.12, -2, 0.45 }, /* 97 */
{ -2, -1.12, 0.45 }, /* 98 */
{ -2, 0, 0.45 }, /* 99 */
{ -0.84, -1.5, 0.225 }, /* 100 */

{ -1.5, -0.84, 0.225 }, /* 101 */
{ -1.5, 0, 0.225 }, /* 102 */
{ -0.84, -1.5, 0.15 }, /* 103 */
{ -1.5, -0.84, 0.15 }, /* 104 */
{ -1.5, 0, 0.15 }, /* 105 */

{ -2, 1.12, 0.45 }, /* 106 */
{ -1.12, 2, 0.45 }, /* 107 */
{ 0, 2, 0.45 }, /* 108 */
{ -1.5, 0.84, 0.225 }, /* 109 */
{ -0.84, 1.5, 0.225 }, /* 110 */

{ 0, 1.5, 0.225 }, /* 111 */
{ -1.5, 0.84, 0.15 }, /* 112 */
{ -0.84, 1.5, 0.15 }, /* 113 */
{ 0, 1.5, 0.15 }, /* 114 */
{ 1.12, 2, 0.45 }, /* 115 */

{ 2, 1.2, 0.45 }, /* 116 */
{ 0.84, 1.5, 0.225 }, /* 117 */
{ 1.5, 0.84, 0.225 }, /* 118 */
{ 0.84, 1.5, 0.15 }, /* 119 */
{ 1.5, 0.84, 0.15 }, /* 120 */

{ -1.6, 0, 2.025 }, /* 121 */
{ -1.6, -0.3, 2.025 }, /* 122 */
{ -1.5, -0.3, 2.25 }, /* 123 */
{ -1.5, 0, 2.25 }, /* 124 */
{ -2.3, 0, 2.025 }, /* 125 */

{ -2.3, -0.3, 2.025 }, /* 126 */
{ -2.5, -0.3, 2.25 }, /* 127 */
{ -2.5, 0, 2.25 }, /* 128 */
{ -2.7, 0, 2.025 }, /* 129 */
{ -2.7, -0.3, 2.025 }, /* 130 */

{ -3, -0.3, 2.25 }, /* 131 */
{ -3, 0, 2.25 }, /* 132 */
{ -2.7, 0, 1.8 }, /* 133 */
{ -2.7, -0.3, 1.8 }, /* 134 */
{ -3, -0.3, 1.8 }, /* 135 */

{ -3, 0, 1.8 }, /* 136 */
{ -1.5, 0.3, 2.25 }, /* 137 */
{ -1.6, 0.3, 2.025 }, /* 138 */
{ -2.5, 0.3, 2.25 }, /* 139 */
{ -2.3, 0.3, 2.025 }, /* 140 */

{ -3, 0.3, 2.25 }, /* 141 */
{ -2.7, 0.3, 2.025 }, /* 142 */
{ -3, 0.3, 1.8 }, /* 143 */
{ -2.7, 0.3, 1.8 }, /* 144 */
{ -2.7, 0, 1.575 }, /* 145 */

{ -2.7, -0.3, 1.575 }, /* 146 */
{ -3, -0.3, 1.35 }, /* 147 */
{ -3, 0, 1.35 }, /* 148 */
{ -2.5, 0, 1.125 }, /* 149 */
{ -2.5, -0.3, 1.125 }, /* 150 */

{ -2.65, -0.3, 0.9375 }, /* 151 */
{ -2.65, 0, 0.9375 }, /* 152 */
{ -2, -0.3, 0.9 }, /* 153 */
{ -1.9, -0.3, 0.6 }, /* 154 */
{ -1.9, 0, 0.6 }, /* 155 */

{ -3, 0.3, 1.35 }, /* 156 */
{ -2.7, 0.3, 1.575 }, /* 157 */
{ -2.65, 0.3, 0.9375 }, /* 158 */
{ -2.5, 0.3, 1.125 }, /* 159 */
{ -1.9, 0.3, 0.6 }, /* 160 */

{ -2, 0.3, 0.9 }, /* 161 */
{ 1.7, 0, 1.425 }, /* 162 */
{ 1.7, -0.66, 1.425 }, /* 163 */
{ 1.7, -0.66, 0.6 }, /* 164 */
{ 1.7, 0, 0.6 }, /* 165 */

{ 2.6, 0, 1.425 }, /* 166 */
{ 2.6, -0.66, 1.425 }, /* 167 */
{ 3.1, -0.66, 0.825 }, /* 168 */
{ 3.1, 0, 0.825 }, /* 169 */
{ 2.3, 0, 2.1 }, /* 170 */

{ 2.3, -0.25, 2.1 }, /* 171 */
{ 2.4, -0.25, 2.025 }, /* 172 */
{ 2.4, 0, 2.025 }, /* 173 */
{ 2.7, 0, 2.4 }, /* 174 */
{ 2.7, -0.25, 2.4 }, /* 175 */

{ 3.3, -0.25, 2.4 }, /* 176 */
{ 3.3, 0, 2.4 }, /* 177 */
{ 1.7, 0.66, 0.6 }, /* 178 */
{ 1.7, 0.66, 1.425 }, /* 179 */
{ 3.1, 0.66, 0.825 }, /* 180 */

{ 2.6, 0.66, 1.425 }, /* 181 */
{ 2.4, 0.25, 2.025 }, /* 182 */
{ 2.3, 0.25, 2.1 }, /* 183 */
{ 3.3, 0.25, 2.4 }, /* 184 */
{ 2.7, 0.25, 2.4 }, /* 185 */

{ 2.8, 0, 2.475 }, /* 186 */
{ 2.8, -0.25, 2.475 }, /* 187 */
{ 3.525, -0.25, 2.49375 }, /* 188 */
{ 3.525, 0, 2.49375 }, /* 189 */
{ 2.9, 0, 2.475 }, /* 190 */

{ 2.9, -0.15, 2.475 }, /* 191 */
{ 3.45, -0.15, 2.5125 }, /* 192 */
{ 3.45, 0, 2.5125 }, /* 193 */
{ 2.8, 0, 2.4 }, /* 194 */
{ 2.8, -0.15, 2.4 }, /* 195 */

{ 3.2, -0.15, 2.4 }, /* 196 */
{ 3.2, 0, 2.4 }, /* 197 */
{ 3.525, 0.25, 2.49375 }, /* 198 */
{ 2.8, 0.25, 2.475 }, /* 199 */
{ 3.45, 0.15, 2.5125 }, /* 200 */

{ 2.9, 0.15, 2.475 }, /* 201 */
{ 3.2, 0.15, 2.4 }, /* 202 */
{ 2.8, 0.15, 2.4 }, /* 203 */
{ 0, 0, 3.15 }, /* 204 */
{ 0, -0.002, 3.15 }, /* 205 */

{ 0.002, 0, 3.15 }, /* 206 */
{ 0.8, 0, 3.15 }, /* 207 */
{ 0.8, -0.45, 3.15 }, /* 208 */
{ 0.45, -0.8, 3.15 }, /* 209 */
{ 0, -0.8, 3.15 }, /* 210 */

{ 0, 0, 2.85 }, /* 211 */
{ 0.2, 0, 2.7 }, /* 212 */
{ 0.2, -0.112, 2.7 }, /* 213 */
{ 0.112, -0.2, 2.7 }, /* 214 */
{ 0, -0.2, 2.7 }, /* 215 */

{ -0.002, 0, 3.15 }, /* 216 */
{ -0.45, -0.8, 3.15 }, /* 217 */
{ -0.8, -0.45, 3.15 }, /* 218 */
{ -0.8, 0, 3.15 }, /* 219 */
{ -0.112, -0.2, 2.7 }, /* 220 */

{ -0.2, -0.112, 2.7 }, /* 221 */
{ -0.2, 0, 2.7 }, /* 222 */
{ 0, 0.002, 3.15 }, /* 223 */
{ -0.8, 0.45, 3.15 }, /* 224 */
{ -0.45, 0.8, 3.15 }, /* 225 */

{ 0, 0.8, 3.15 }, /* 226 */
{ -0.2, 0.112, 2.7 }, /* 227 */
{ -0.112, 0.2, 2.7 }, /* 228 */
{ 0, 0.2, 2.7 }, /* 229 */
{ 0.45, 0.8, 3.15 }, /* 230 */

{ 0.8, 0.45, 3.15 }, /* 231 */
{ 0.112, 0.2, 2.7 }, /* 232 */
{ 0.2, 0.112, 2.7 }, /* 233 */
{ 0.4, 0, 2.55 }, /* 234 */
{ 0.4, -0.224, 2.55 }, /* 235 */

{ 0.224, -0.4, 2.55 }, /* 236 */
{ 0, -0.4, 2.55 }, /* 237 */
{ 1.3, 0, 2.55 }, /* 238 */
{ 1.3, -0.728, 2.55 }, /* 239 */
{ 0.728, -1.3, 2.55 }, /* 240 */

{ 0, -1.3, 2.55 }, /* 241 */
{ 1.3, 0, 2.4 }, /* 242 */
{ 1.3, -0.728, 2.4 }, /* 243 */
{ 0.728, -1.3, 2.4 }, /* 244 */
{ 0, -1.3, 2.4 }, /* 245 */

{ -0.224, -0.4, 2.55 }, /* 246 */
{ -0.4, -0.224, 2.55 }, /* 247 */
{ -0.4, 0, 2.55 }, /* 248 */
{ -0.728, -1.3, 2.55 }, /* 249 */
{ -1.3, -0.728, 2.55 }, /* 250 */

{ -1.3, 0, 2.55 }, /* 251 */
{ -0.728, -1.3, 2.4 }, /* 252 */
{ -1.3, -0.728, 2.4 }, /* 253 */
{ -1.3, 0, 2.4 }, /* 254 */
{ -0.4, 0.224, 2.55 }, /* 255 */

{ -0.224, 0.4, 2.55 }, /* 256 */
{ 0, 0.4, 2.55 }, /* 257 */
{ -1.3, 0.728, 2.55 }, /* 258 */
{ -0.728, 1.3, 2.55 }, /* 259 */
{ 0, 1.3, 2.55 }, /* 260 */

{ -1.3, 0.728, 2.4 }, /* 261 */
{ -0.728, 1.3, 2.4 }, /* 262 */
{ 0, 1.3, 2.4 }, /* 263 */
{ 0.224, 0.4, 2.55 }, /* 264 */
{ 0.4, 0.224, 2.55 }, /* 265 */

{ 0.728, 1.3, 2.55 }, /* 266 */
{ 1.3, 0.728, 2.55 }, /* 267 */
{ 0.728, 1.3, 2.4 }, /* 268 */
{ 1.3, 0.728, 2.4 }, /* 269 */
{ 0, 0, 0 }, /* 270 */

{ 1.5, 0, 0.15 }, /* 271 */
{ 1.5, 0.84, 0.15 }, /* 272 */
{ 0.84, 1.5, 0.15 }, /* 273 */
{ 0, 1.5, 0.15 }, /* 274 */
{ 1.5, 0, 0.075 }, /* 275 */

{ 1.5, 0.84, 0.075 }, /* 276 */
{ 0.84, 1.5, 0.075 }, /* 277 */
{ 0, 1.5, 0.075 }, /* 278 */
{ 1.425, 0, 0 }, /* 279 */
{ 1.425, 0.798, 0 }, /* 280 */

{ 0.798, 1.425, 0 }, /* 281 */
{ 0, 1.425, 0 }, /* 282 */
{ -0.84, 1.5, 0.15 }, /* 283 */
{ -1.5, 0.84, 0.15 }, /* 284 */
{ -1.5, 0, 0.15 }, /* 285 */

{ -0.84, 1.5, 0.075 }, /* 286 */
{ -1.5, 0.84, 0.075 }, /* 287 */
{ -1.5, 0, 0.075 }, /* 288 */
{ -0.798, 1.425, 0 }, /* 289 */
{ -1.425, 0.798, 0 }, /* 290 */

{ -1.425, 0, 0 }, /* 291 */
{ -1.5, -0.84, 0.15 }, /* 292 */
{ -0.84, -1.5, 0.15 }, /* 293 */
{ 0, -1.5, 0.15 }, /* 294 */
{ -1.5, -0.84, 0.075 }, /* 295 */

{ -0.84, -1.5, 0.075 }, /* 296 */
{ 0, -1.5, 0.075 }, /* 297 */
{ -1.425, -0.798, 0 }, /* 298 */
{ -0.798, -1.425, 0 }, /* 299 */
{ 0, -1.425, 0 }, /* 300 */

{ 0.84, -1.5, 0.15 }, /* 301 */
{ 1.5, -0.84, 0.15 }, /* 302 */
{ 0.84, -1.5, 0.075 }, /* 303 */
{ 1.5, -0.84, 0.075 }, /* 304 */
{ 0.798, -1.425, 0 }, /* 305 */

{ 1.425, -0.798, 0 } /* 306 */
};

#define nvert ((sizeof vertices) / (3 * sizeof(double)))

static void
display_patch(patch)
patchdef patch;
{
int i, j;
fprintf(datfile, "object {\n");
fprintf(datfile, " bezier %d, %g, %d, %d,\n",
Quality, Flatness, U_Steps, V_Steps);
for (i=0;i<4;i++) {
fprintf(datfile, " ");
for (j=0;j<4;j++) {
fprintf(datfile, "<%g, %g, %g>",
vertices[patch[i][j]][X],
vertices[patch[i][j]][Z],
vertices[patch[i][j]][Y]);
if (j<3) fprintf(datfile, ", ");
}
if (i<3)
fprintf(datfile, ",\n");
else
fprintf(datfile, "\n");
}
fprintf(datfile, " }\n");
}

void
main()
{
int i;

if ((datfile = fopen("teapot.inc", "wt")) != NULL) {
fprintf(datfile, "define teapot\n");
fprintf(datfile, "object {\n");
for (i = 0; i < npatches; i++) {
switch (i) {
case 0:
fprintf(datfile, "# Rim\n");
break;
case 4:
fprintf(datfile, "# Body\n");
break;
case 12:
fprintf(datfile, "# Handle\n");
break;
case 16:
fprintf(datfile, "# Spout\n");
break;
case 20:
fprintf(datfile, "# Lid\n");
break;
case 28:
fprintf(datfile, "# Bottom\n");
break;
}
if (i==0)
fprintf(datfile, " ");
else
fprintf(datfile, " + ");
display_patch(patches[i]);
}
fprintf(datfile, " bounds object {\n");
fprintf(datfile, " box <-3.4683, -2.02, 0>,\n");
fprintf(datfile, " <3.03, 2.02, 3.1815> }\n");
fprintf(datfile, " }\n");
}
}