2 metasurf - a library for implicit surface polygonization
3 Copyright (C) 2011-2015 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /* this is pulled from: https://github.com/jtsiomb/metasurf */
22 #define MSURF_GREATER 1
27 typedef float (*msurf_eval_func_t)(struct metasurface *ms, float, float, float);
28 typedef void (*msurf_vertex_func_t)(struct metasurface *ms, float, float, float);
29 typedef void (*msurf_normal_func_t)(struct metasurface *ms, float, float, float);
35 struct metasurface *msurf_create(void);
36 void msurf_free(struct metasurface *ms);
38 void msurf_set_user_data(struct metasurface *ms, void *udata);
39 void *msurf_get_user_data(struct metasurface *ms);
41 /* which is inside above or below the threshold */
42 void msurf_set_inside(struct metasurface *ms, int inside);
43 int msurf_get_inside(struct metasurface *ms);
45 /* set a scalar field evaluator function */
46 void msurf_eval_func(struct metasurface *ms, msurf_eval_func_t func);
48 /* set a generated vertex callback function */
49 void msurf_vertex_func(struct metasurface *ms, msurf_vertex_func_t func);
51 /* set a generated surface normal callback function (unused yet) */
52 void msurf_normal_func(struct metasurface *ms, msurf_normal_func_t func);
54 /* set the bounding box (default: -1, -1, -1, 1, 1, 1)
55 * keep this as tight as possible to avoid wasting grid resolution
57 void msurf_set_bounds(struct metasurface *ms, float xmin, float ymin, float zmin, float xmax, float ymax, float zmax);
58 void msurf_get_bounds(struct metasurface *ms, float *xmin, float *ymin, float *zmin, float *xmax, float *ymax, float *zmax);
60 /* resolution of the 3D evaluation grid, the bigger, the better, the slower
61 * (default: 40, 40, 40)
63 void msurf_set_resolution(struct metasurface *ms, int xres, int yres, int zres);
64 void msurf_get_resolution(struct metasurface *ms, int *xres, int *yres, int *zres);
66 /* isosurface threshold value (default: 0) */
67 void msurf_set_threshold(struct metasurface *ms, float thres);
68 float msurf_get_threshold(struct metasurface *ms);
71 /* finally call this to perform the polygonization */
72 int msurf_polygonize(struct metasurface *ms);
79 #endif /* METASURF_H_ */