projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.19.tar.gz
[xscreensaver]
/
hacks
/
glx
/
polyhedra.c
diff --git
a/hacks/glx/polyhedra.c
b/hacks/glx/polyhedra.c
index aed4d743c06a8a30e3295ee9fae3869eff4b26c3..26f66d3a5338d232eba795ff55695ba0786b8146 100644
(file)
--- a/
hacks/glx/polyhedra.c
+++ b/
hacks/glx/polyhedra.c
@@
-43,14
+43,17
@@
*****************************************************************************
*/
*****************************************************************************
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
-#include <math.h>
#include <stdlib.h>
#include <errno.h>
#include <stdlib.h>
#include <errno.h>
-#include "config.h"
#include "polyhedra.h"
extern const char *progname;
#include "polyhedra.h"
extern const char *progname;
@@
-88,23
+91,23
@@
extern const char *progname;
} while(0)
#define Malloc(lvalue,n,type) do {\
} while(0)
#define Malloc(lvalue,n,type) do {\
- if (!(lvalue = (type*)
malloc((n) *
sizeof(type)))) \
-
Err("out of memory"
);\
+ if (!(lvalue = (type*)
calloc((n),
sizeof(type)))) \
+
abort(
);\
} while(0)
#define Realloc(lvalue,n,type) do {\
if (!(lvalue = (type*) realloc(lvalue, (n) * sizeof(type)))) \
} while(0)
#define Realloc(lvalue,n,type) do {\
if (!(lvalue = (type*) realloc(lvalue, (n) * sizeof(type)))) \
-
Err("out of memory"
);\
+
abort(
);\
} while(0)
#define Calloc(lvalue,n,type) do {\
if (!(lvalue = (type*) calloc(n, sizeof(type))))\
} while(0)
#define Calloc(lvalue,n,type) do {\
if (!(lvalue = (type*) calloc(n, sizeof(type))))\
-
Err("out of memory"
);\
+
abort(
);\
} while(0)
#define Matalloc(lvalue,n,m,type) do {\
if (!(lvalue = (type**) matalloc(n, (m) * sizeof(type))))\
} while(0)
#define Matalloc(lvalue,n,m,type) do {\
if (!(lvalue = (type**) matalloc(n, (m) * sizeof(type))))\
-
Err("out of memory"
);\
+
abort(
);\
} while(0)
#define Sprintfrac(lvalue,x) do {\
} while(0)
#define Sprintfrac(lvalue,x) do {\
@@
-188,7
+191,7
@@
static void *matalloc(int rows, int row_size);
static Fraction frax;
static Fraction frax;
-static struct {
+static
const
struct {
char *Wythoff, *name, *dual, *group, *class, *dual_class;
short Coxeter, Wenninger;
} uniform[] = {
char *Wythoff, *name, *dual, *group, *class, *dual_class;
short Coxeter, Wenninger;
} uniform[] = {
@@
-197,6
+200,16
@@
static struct {
* Dihedral Schwarz Triangles (D5 only)
***************************************************************************/
* Dihedral Schwarz Triangles (D5 only)
***************************************************************************/
+ /* {"3|2 5/2", "xyz",
+ "xyz",
+ "xyz",
+ "",
+ "",
+ 0, 0},
+*/
+
+
+
/* (2 2 5) (D1/5) */
/* 1 */ {"2 5|2", "Pentagonal Prism",
"Pentagonal Dipyramid",
/* (2 2 5) (D1/5) */
/* 1 */ {"2 5|2", "Pentagonal Prism",
"Pentagonal Dipyramid",
@@
-444,7
+457,7
@@
static struct {
"Catalan Solid",
30, 14},
"Catalan Solid",
30, 14},
- /* 33 */ {"2 3 5|", "Truncated Icosidodec
hed
on",
+ /* 33 */ {"2 3 5|", "Truncated Icosidodec
ahedr
on",
"Disdyakistriacontahedron",
"Icosahedral (I[1])",
"Archimedian Solid",
"Disdyakistriacontahedron",
"Icosahedral (I[1])",
"Archimedian Solid",
@@
-976,7
+989,7
@@
mod (int i, int j)
static void
frac(double x)
{
static void
frac(double x)
{
- static Fraction zero = {0,1}, inf = {1,0};
+ static
const
Fraction zero = {0,1}, inf = {1,0};
Fraction r0, r;
long f;
double s = x;
Fraction r0, r;
long f;
double s = x;
@@
-1421,7
+1434,7
@@
guessname(Polyhedron *P)
return dihedral(P, "Dihedron", "Hosohedron");
}
} else {/* other nontabulated */
return dihedral(P, "Dihedron", "Hosohedron");
}
} else {/* other nontabulated */
- static char *pre[] = {"Tetr", "Oct", "Icos"};
+ static c
onst c
har *pre[] = {"Tetr", "Oct", "Icos"};
Malloc(P->name, 50, char);
Malloc(P->dual_name, 50, char);
sprintf(P->name, "%sahedral ", pre[P->K - 3]);
Malloc(P->name, 50, char);
Malloc(P->dual_name, 50, char);
sprintf(P->name, "%sahedral ", pre[P->K - 3]);
@@
-1737,7
+1750,7
@@
faces(Polyhedron *P)
int j;
for (j = 0; j < P->M; j++) {
int i0, J;
int j;
for (j = 0; j < P->M; j++) {
int i0, J;
- int pap;/* papillon edge type */
+ int pap
=0
;/* papillon edge type */
if (P->incid[j][i] != -1)
continue;
P->incid[j][i] = newF;
if (P->incid[j][i] != -1)
continue;
P->incid[j][i] = newF;
@@
-1916,7
+1929,7
@@
rotate(Vector vertex, Vector axis, double angle)
scale(sin(angle), cross(axis, vertex)));
}
scale(sin(angle), cross(axis, vertex)));
}
-Vector x, y, z;
+
static
Vector x, y, z;
/*
* rotate the standard frame
/*
* rotate the standard frame
@@
-1924,7
+1937,7
@@
Vector x, y, z;
static void
rotframe(double azimuth, double elevation, double angle)
{
static void
rotframe(double azimuth, double elevation, double angle)
{
- static Vector X = {1,0,0}, Y = {0,1,0}, Z = {0,0,1};
+ static
const
Vector X = {1,0,0}, Y = {0,1,0}, Z = {0,0,1};
Vector axis;
axis = rotate(rotate (X, Y, elevation), Z, azimuth);
Vector axis;
axis = rotate(rotate (X, Y, elevation), Z, azimuth);
@@
-2027,7
+2040,7
@@
construct_polyhedron (Polyhedron *P, Vector *v, int V, Vector *f, int F,
char *name, char *dual, char *class, char *star,
double azimuth, double elevation, double freeze)
{
char *name, char *dual, char *class, char *star,
double azimuth, double elevation, double freeze)
{
- int i, j, k
, l, ll, ii, *hit
, facelets;
+ int i, j, k
=0, l, ll, ii, *hit=0
, facelets;
polyhedron *result;
Vector *temp;
polyhedron *result;
Vector *temp;
@@
-2260,7
+2273,7
@@
construct_polyhedron (Polyhedron *P, Vector *v, int V, Vector *f, int F,
facelets++;
} else if (P->even != -1) {
facelets++;
} else if (P->even != -1) {
- if (hit[i]) {
+ if (hit
&& hit
[i]) {
push_face3 (result, P->incid[3][i], P->incid[0][i], ii);
push_face3 (result, P->incid[1][i], P->incid[2][i], ii);
} else {
push_face3 (result, P->incid[3][i], P->incid[0][i], ii);
push_face3 (result, P->incid[1][i], P->incid[2][i], ii);
} else {
@@
-2415,10
+2428,10
@@
construct_polyhedra (polyhedron ***polyhedra_ret)
int count = 0;
polyhedron **result;
int count = 0;
polyhedron **result;
- Malloc (result, last_uniform * 2 +
1
, polyhedron*);
+ Malloc (result, last_uniform * 2 +
3
, polyhedron*);
while (index < last_uniform) {
while (index < last_uniform) {
-
static
char sym[4];
+ char sym[4];
Polyhedron *P;
sprintf(sym, "#%d", index + 1);
Polyhedron *P;
sprintf(sym, "#%d", index + 1);
@@
-2440,5
+2453,6
@@
construct_polyhedra (polyhedron ***polyhedra_ret)
}
*polyhedra_ret = result;
}
*polyhedra_ret = result;
+ count++; /* leave room for teapot */
return count;
}
return count;
}