#include "dynarr.h"
static void destroy_cell(struct frac_cell *cell);
+static int build_cell(struct fracture *frac, int cellidx);
int frac_init(struct fracture *frac)
{
return dynarr_size(frac->cells);
}
+/* --- step 1: generate a bunch of points (or let the user add them manually) */
+
int frac_gen_points(struct fracture *frac, int num)
{
int i;
return 0;
}
+
+/* --- step 2: construct voronoi cells bounded by planes */
+
int frac_build_cells(struct fracture *frac)
{
+ int i;
+
+ for(i=0; i<dynarr_size(frac->cells); i++) {
+ if(build_cell(frac, i) == -1) {
+ return -1;
+ }
+ }
+
return -1;
}
+static int build_cell(struct fracture *frac, int cellidx)
+{
+ int i, j, num;
+ struct plane plane, *pptr;
+ struct frac_cell *cell = frac->cells + cellidx;
+
+ num = dynarr_size(frac->cells);
+ for(i=0; i<num; i++) {
+ if(i == cellidx) continue;
+ midplane(&plane, &cell->pt, &frac->cells[i].pt);
+ if(!(pptr = dynarr_push(cell->planes, &plane))) {
+ return -1;
+ }
+ cell->planes = pptr;
+ }
+
+ /* clip all planes against each other to end up with a convex cell */
+ num = dynarr_size(cell->planes);
+ for(i=0; i<num; i++) {
+ for(j=0; j<num; j++) {
+ if(i == j) continue;
+
+ clip_poly...
+ }
+ }
+}
+
int frac_build_shell(struct fracture *frac)
{
return -1;