03ae4e673aab5af649a1ff13c27a58d8523352da
[meshfrac] / src / frac.h
1 #ifndef FRAC_H_
2 #define FRAC_H_
3
4 #include "cmesh.h"
5 #include "cgmath/cgmath.h"
6
7 struct frac_cell {
8         cgm_vec3 pt;
9         struct cmesh *mesh;
10         cgm_vec4 *planes;                       /* dynarr */
11 };
12
13 struct fracture {
14         struct cmesh *mesh;                     /* no ownership */
15         struct frac_cell *cells;        /* dynarr */
16 };
17
18 int frac_init(struct fracture *frac);
19 void frac_destroy(struct fracture *frac);
20
21 /* fracture does not take ownership of the mesh, and does not modify it */
22 void frac_mesh(struct fracture *frac, const struct cmesh *m);
23
24 int frac_point(struct fracture *frac, float x, float y, float z);
25 int frac_num_cells(struct fracture *frac);
26
27 /* add a bunch of random points in the bounding box of the mesh */
28 int frac_gen_points(struct fracture *frac, int num);
29
30 /* construct the voronoi cells */
31 int frac_build_cells(struct fracture *frac);
32 /* generate the polygons for the outer shell of each cell */
33 int frac_build_shell(struct fracture *frac);
34 /* generate the polygons for the inner walls of the cells */
35 int frac_build_walls(struct fracture *frac);
36
37 /* perform all the steps in order */
38 int frac_build(struct fracture *frac);
39
40
41 #endif  /* FRAC_H_ */