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