BucketVector const& Selector::get_buckets(EntityRank entity_rank) const { static BucketVector emptyBucketVector; if (m_expr.empty()) { return emptyBucketVector; } BulkData* mesh = find_mesh(); ThrowRequireMsg(mesh != NULL, "ERROR, Selector::get_buckets not available if selector expression does not involve any mesh Parts."); return mesh->get_buckets(entity_rank, *this); }
struct model *load_obj_model(char *filename) { char dirname[1024]; char line[200]; struct model *model; struct mesh *curmesh = NULL; int fvp[20], fvt[20], fvn[20]; char *p, *s; int i, n; FILE *fp; strlcpy(dirname, filename, sizeof dirname); p = strrchr(dirname, '/'); if (!p) p = strrchr(dirname, '\\'); if (p) *p = 0; else strlcpy(dirname, ".", sizeof dirname); printf("loading obj model: %s\n", filename); fp = fopen(filename, "r"); if (!fp) { fprintf(stderr, "error: cannot load model '%s'\n", filename); return NULL; } model = malloc(sizeof(struct model)); memset(model, 0, sizeof(struct model)); model->min[0] = model->min[1] = model->min[2] = 1e10; model->max[0] = model->max[1] = model->max[2] = -1e10; model->radius = 0; while (1) { if (!fgets(line, sizeof line, fp)) break; s = strtok(line, SEP); if (!s) { continue; } else if (!strcmp(s, "v")) { char *x = strtok(NULL, SEP); char *y = strtok(NULL, SEP); char *z = strtok(NULL, SEP); add_position(model, atof(x), atof(y), atof(z)); } else if (!strcmp(s, "vt")) { char *u = strtok(NULL, SEP); char *v = strtok(NULL, SEP); add_texcoord(model, atof(u), atof(v)); } else if (!strcmp(s, "vn")) { char *x = strtok(NULL, SEP); char *y = strtok(NULL, SEP); char *z = strtok(NULL, SEP); add_normal(model, atof(x), atof(y), atof(z)); } else if (!strcmp(s, "f")) { n = 0; s = strtok(NULL, SEP); while (s) { if (*s) { splitfv(s, fvp+n, fvt+n, fvn+n); n++; } s = strtok(NULL, SEP); } for (i = 1; i < n - 1; i++) { add_triangle(curmesh, fvp[0], fvt[0], fvn[0], fvp[i], fvt[i], fvn[i], fvp[i+1], fvt[i+1], fvn[i+1]); } } else if (!strcmp(s, "mtllib")) { s = strtok(NULL, SEP); model->material = load_material(dirname, s); } else if (!strcmp(s, "usemtl")) { s = strtok(NULL, SEP); curmesh = find_mesh(model, s); } } model->radius = sqrtf(model->radius); fclose(fp); return model; }