int main(int argc, char* argv[]) { char* fname = NULL; int ij = 0; int compact = 0; NODETYPE nt = NT_DD; gridnodes* gn = NULL; poly* pl = NULL; parse_commandline(argc, argv, &fname, &compact, &ij, &nt); if (nt == NT_DD) { /* * read DD grid nodes */ gridnodes* gndd = gridnodes_read(fname, NT_DD); gridnodes_validate(gndd); /* * get corner grid nodes from DD grid nodes */ gn = gridnodes_transform(gndd, NT_COR); gridnodes_destroy(gndd); } else { gn = gridnodes_read(fname, NT_COR); gridnodes_validate(gn); } /* * build boundary polygon */ if (!ij) pl = poly_formbound(gridnodes_getnce1(gn), gridnodes_getnce2(gn), gridnodes_getx(gn), gridnodes_gety(gn)); else pl = poly_formboundij(gridnodes_getnce1(gn), gridnodes_getnce2(gn), gridnodes_getx(gn)); if (compact) poly_compact(pl, 1.0e-10); poly_write(pl, stdout); poly_destroy(pl); gridnodes_destroy(gn); return 0; }
static void gridmap_subdivide(gridmap* gm, subgrid* sg) { subgrid* sg1 = NULL; subgrid* sg2 = NULL; subgrid_divide(sg, &sg1, &sg2); if (sg1 != NULL) { sg->half1 = sg1; ++(gm->nleaves); gridmap_subdivide(gm, sg1); } if (sg2 != NULL) { gridmap_subdivide(gm, sg2); sg->half2 = sg2; ++(gm->nleaves); } poly_compact(sg->bound, EPS_COMPACT); }