started on the fracture code
[meshfrac] / src / frac.h
diff --git a/src/frac.h b/src/frac.h
new file mode 100644 (file)
index 0000000..03ae4e6
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef FRAC_H_
+#define FRAC_H_
+
+#include "cmesh.h"
+#include "cgmath/cgmath.h"
+
+struct frac_cell {
+       cgm_vec3 pt;
+       struct cmesh *mesh;
+       cgm_vec4 *planes;                       /* dynarr */
+};
+
+struct fracture {
+       struct cmesh *mesh;                     /* no ownership */
+       struct frac_cell *cells;        /* dynarr */
+};
+
+int frac_init(struct fracture *frac);
+void frac_destroy(struct fracture *frac);
+
+/* fracture does not take ownership of the mesh, and does not modify it */
+void frac_mesh(struct fracture *frac, const struct cmesh *m);
+
+int frac_point(struct fracture *frac, float x, float y, float z);
+int frac_num_cells(struct fracture *frac);
+
+/* add a bunch of random points in the bounding box of the mesh */
+int frac_gen_points(struct fracture *frac, int num);
+
+/* construct the voronoi cells */
+int frac_build_cells(struct fracture *frac);
+/* generate the polygons for the outer shell of each cell */
+int frac_build_shell(struct fracture *frac);
+/* generate the polygons for the inner walls of the cells */
+int frac_build_walls(struct fracture *frac);
+
+/* perform all the steps in order */
+int frac_build(struct fracture *frac);
+
+
+#endif /* FRAC_H_ */