static int writePC33(bor_pc_t *pc, int fd) { FILE *fout; bor_pc_it_t pcit; bor_vec3_t *v; fout = fdopen(fd, "w"); if (!fout) return -1; // first print dimensions fprintf(fout, "3\n"); // then write number of points fprintf(fout, "%d\n", (int)borPCLen(pc)); // and write all points borPCItInit(&pcit, (bor_pc_t *)pc); while (!borPCItEnd(&pcit)){ v = (bor_vec3_t *)borPCItGet(&pcit); fprintf(fout, "%g %g %g\n", borVec3X(v), borVec3Y(v), borVec3Z(v)); borPCItNext(&pcit); } fclose(fout); return 0; }
static const bor_vec_t *input_signal(void *data) { const bor_vec_t *v; if (borPCItEnd(&pcit)){ borPCPermutate(pc); borPCItInit(&pcit, pc); } v = borPCItGet(&pcit); borPCItNext(&pcit); return v; }
static int pcContains(bor_pc_t *pc, const bor_vec3_t *v) { bor_pc_it_t it; const bor_vec3_t *w; borPCItInit(&it, pc); while (!borPCItEnd(&it)){ w = (bor_vec3_t *)borPCItGet(&it); if (borVec3Eq(w, v)) return 1; borPCItNext(&it); } return 0; }