Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!rutgers!rochester!pt.cs.cmu.edu!vap.vi.ri.cmu.edu!pkh From: pkh@vap.vi.ri.cmu.edu (Ping Kang Hsiung) Newsgroups: comp.graphics Subject: nff filter for redundant polygon vertices Message-ID: <3865@pt.cs.cmu.edu> Date: 14 Dec 88 02:30:04 GMT Organization: Carnegie-Mellon University, CS/RI Lines: 243 I am posting the source code since among the people who requested for the source code, two of them are not reach-able from my system. Fortunately it's not a big program. Sorry for the inconvenience. *** /* * program: nfff.c * * a filter for NFF (Neutral File Format) * nfff [infile] * input: infile.nff or stdin * output: stdout * * input items other than polygons are copied to output directly. * for polygons that have 2 or more identical vertices, the redundant * vertices are filtered out and the "p " lines of * the polygons are adjusted properly. * * the vertices degeneration cases occur in data produced by some * automatic nff generation program when the resolution/prec. of * generation exceeds that of the floating point format. * * definition of NFF: see nff.def * bugs: * (1) handles polygons only. break if there are other obj. types * (2) MAX_VERT may cause trouble * * Fri Dec 2 16:41:27 EST 1988 * pkh@vap * * bugs fixed: * */ #include #include /* #include "/usr/pkh/include/all.h" */ /* #include "/usr/pkh/include/def3d.h" */ /* from "def3d.h" */ typedef struct pt3d_struct { float x, y, z; } pt3d, *pt3d_t; #define FPRINT3d(fp, pt, newline) do { \ if (newline) \ fprintf(fp, "%g %g %g\n", pt.x, pt.y, pt.z); \ else \ fprintf(fp, "%g %g %g", pt.x, pt.y, pt.z); \ } while (0) #define FSCAN3d(fp, pt) do { \ fscanf(fp,"%f %f %f", &(pt.x), &(pt.y), &(pt.z)); \ } while(0) #define ASSIGN3d(p0, p1) do {p0.x=p1.x; p0.y=p1.y; p0.z=p1.z;} while(0) #define EQ3d(p0, p1) ((p0.x==p1.x)&&(p0.y==p1.y)&& (p0.z==p1.z)) /* from "all.h" */ int debug; #define POW2(y) (1<