ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/objutil.h
(Generate patch)

Comparing ray/src/common/objutil.h (file contents):
Revision 2.2 by greg, Thu Apr 2 20:44:15 2020 UTC vs.
Revision 2.13 by greg, Fri Mar 12 03:59:25 2021 UTC

# Line 10 | Line 10
10   #ifndef _OBJUTIL_H_
11   #define _OBJUTIL_H_
12  
13 + #ifdef __cplusplus
14 + extern "C" {
15 + #endif
16 +
17   #ifndef DUP_CHECK_REVERSE
18   #define DUP_CHECK_REVERSE       1       /* eliminate flipped duplicates */
19   #endif
# Line 17 | Line 21
21   #define POPEN_SUPPORT           1       /* support "!command" i/o */
22   #endif
23                                          /* face flags */
24 < #define FACE_SELECTED           01
25 < #define FACE_DEGENERATE         02
26 < #define FACE_DUPLICATE          04
24 > #define FACE_DEGENERATE         01
25 > #define FACE_DUPLICATE          02
26 > #define FACE_SELECTED           04
27 > #define FACE_CUSTOM(n)          (FACE_SELECTED<<(n))
28 > #define FACE_RESERVED           (1<<15)
29  
30   struct Face;                            /* forward declaration */
31  
32 + typedef int             VNDX[3];        /* vertex indices (point,map,normal) */
33 +
34 + /* Structure to hold vertex indices and link back to face list */
35   typedef struct {
36          int             vid;            /* vertex id */
37          int             tid;            /* texture id */
# Line 75 | Line 84 | typedef struct {
84          int             nfaces;         /* count of faces */
85   } Scene;
86  
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81
87   /* Allocate a new scene holder */
88   Scene *         newScene(void);
89  
90   /* Add a .OBJ file to a scene */
91   Scene *         loadOBJ(Scene *sc, const char *fspec);
92  
93 < /* Duplicate a scene */
94 < Scene *         dupScene(const Scene *sc);
93 > /* Duplicate a scene, optionally selecting faces */
94 > Scene *         dupScene(const Scene *sc, int flreq, int flexc);
95  
96   /* Transform entire scene */
97 + int             xfScene(Scene *sc, int xac, char *xav[]);
98   int             xfmScene(Scene *sc, const char *xfm);
99  
100   /* Add a descriptive comment */
101   void            addComment(Scene *sc, const char *comment);
102  
103 + /* Find index for comment containing the given string (starting from n) */
104 + int             findComment(Scene *sc, const char *match, int n);
105 +
106   /* Clear comments */
107   void            clearComments(Scene *sc);
108  
# Line 151 | Line 160 | int            changeGroup(Scene *sc, const char *gname,
160   int             changeMaterial(Scene *sc, const char *mname,
161                                          int flreq, int flexc);
162  
163 < /* Grab texture coord's/normals from another object via ray tracing */
164 < #define GET_TEXTURE             01
156 < #define GET_NORMALS             02
157 < int             traceSurface(Scene *sc, int flreq, int flexc,
158 <                                const char *oct, int what);
163 > /* Add a vertex to our scene, returning index */
164 > int             addVertex(Scene *sc, double x, double y, double z);
165  
166 + /* Add a texture coordinate to our scene, returning index */
167 + int             addTexture(Scene *sc, double u, double v);
168 +
169 + /* Add a surface normal to our scene, returning index */
170 + int             addNormal(Scene *sc, double xn, double yn, double zn);
171 +
172 + /* Set current group (sc->lastgrp) to given ID */
173 + void            setGroup(Scene *sc, const char *nm);
174 +
175 + /* Set current material (sc->lastmat) to given ID */
176 + void            setMaterial(Scene *sc, const char *nm);
177 +
178 + /* Add a new face to our scene, using current group and material */
179 + Face *          addFace(Scene *sc, VNDX vid[], int nv);
180 +
181 + /* Convert all faces with > 3 vertices to triangles */
182 + int             triangulateScene(Scene *sc);
183 +
184 + /* Delete unreferenced vertices, normals, texture coords */
185 + void            deleteUnreferenced(Scene *sc);
186 +
187   /* Free a scene */
188   void            freeScene(Scene *sc);
189  
# Line 169 | Line 196 | extern int      verbose;
196   extern char     *emalloc(unsigned int n);
197   extern char     *ecalloc(unsigned int ne, unsigned int n);
198   extern char     *erealloc(char *cp, unsigned int n);
199 < extern void     efree(char *cp);
199 > extern void     efree(char *cp);
200 >
201 > #define getGroupID(sc,nm)       findName(nm, (const char **)(sc)->grpname, (sc)->ngrps)
202 > #define getMaterialID(sc,nm)    findName(nm, (const char **)(sc)->matname, (sc)->nmats)
203  
204   #define CHUNKSIZ        128     /* object allocation chunk size */
205  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines