2 * Copyright (C) 2002 Jamie Zawinski <jwz@jwz.org>
3 * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
5 * Marching cubes implementation based on code from from the xscreensaver
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 VolCoord c; /* Coordinate of the point */
35 double value; /* Function value at point */
40 VolCoord c; /* Coordinate of the vertex */
41 gint tris; /* Count of associated triangles */
42 VolCoord norm; /* Vertex normal */
47 VolVertex *v[3]; /* Vertices */
48 VolCoord norm; /* Surface normal */
53 VolPoint *corner[8]; /* Corners */
54 VolVertex *edge[12]; /* Points along the edges (for caching) */
59 int xs, ys, zs; /* Dimensions of points */
60 gpointer data; /* 3-D grid of points */
63 /* Find triangles on an isosurface that pass through the cell */
64 GList *march_one_cube(VolCell *cell, double level);
66 /* Find triangles along an isosurface in a grid of points */
67 GList *marching_cubes(VolGrid *grid, double level);
69 /* Free/unref data for triangle */
70 void vol_triangle_free(VolTriangle *tri);
73 static inline VolPoint *vol_grid_get(VolGrid *grid, int x, int y, int z)
75 VolPoint (*points)[grid->ys][grid->zs] = grid->data;
76 return &points[x][y][z];
78 VolGrid *vol_grid_new(int xs, int ys, int zs);
79 void vol_grid_free(VolGrid *grid);