ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/robjutil.c
(Generate patch)

Comparing ray/src/cv/robjutil.c (file contents):
Revision 2.2 by greg, Thu Apr 2 20:44:15 2020 UTC vs.
Revision 2.6 by greg, Mon Sep 9 00:54:30 2024 UTC

# Line 28 | Line 28 | main(int argc, char *argv[])
28          int             save_mats = 1;
29          int             do_tex = 0;
30          int             do_norm = 0;
31 +        int             do_triangulate = 0;
32          char            *xfm = NULL;
33          char            cbuf[256];
34          double          verteps = -1.;
# Line 86 | Line 87 | main(int argc, char *argv[])
87                  case 'r':                       /* output to Radiance file? */
88                          radout = (argv[i][0] == '+');
89                          break;
90 +                case 'T':                       /* triangulate faces? */
91 +                        do_triangulate = (argv[i][0] == '+');
92 +                        break;
93                  case 'x':                       /* apply a transform */
94                          if (xfm != NULL) {
95                                  fprintf(stderr, "%s: only one '-x' option allowed\n",
# Line 181 | Line 185 | main(int argc, char *argv[])
185          }
186          if (verbose)
187                  fputs("Checking for duplicate faces...\n", stderr);
188 <        if (findDuplicateFaces(myScene))
188 >        if (findDuplicateFaces(myScene)) {
189                  n = deleteFaces(myScene, FACE_DUPLICATE, 0);
190 <        if (n) {
191 <                sprintf(cbuf, "Removed %d duplicate faces", n);
192 <                addComment(myScene, cbuf);
190 >                if (n) {
191 >                        sprintf(cbuf, "Removed %d duplicate faces", n);
192 >                        addComment(myScene, cbuf);
193 >                }
194          }
195 +        if (do_triangulate) {
196 +                if (verbose)
197 +                        fputs("Making sure all faces are triangles...\n", stderr);
198 +                n = triangulateScene(myScene);
199 +                if (n > 0) {
200 +                        sprintf(cbuf, "Added %d faces during triangulation", n);
201 +                        addComment(myScene, cbuf);
202 +                }
203 +        }
204          if (xfm != NULL) {
205                  if (verbose)
206                          fputs("Applying transform...\n", stderr);
# Line 194 | Line 208 | main(int argc, char *argv[])
208                          fprintf(stderr, "%s: transform error\n", argv[0]);
209                          exit(1);
210                  }
197                sprintf(cbuf, "Applied transform: %s", xfm);
198                addComment(myScene, cbuf);
211          }
212          if (verbose)
213                  fputs("Writing out scene...\n", stderr);
# Line 220 | Line 232 | userr:
232          fprintf(stderr, "\t+/-t\t\t\t# keep/remove texture coordinates\n");
233          fprintf(stderr, "\t+/-n\t\t\t# keep/remove vertex normals\n");
234          fprintf(stderr, "\t-c epsilon\t\t# coalesce vertices within epsilon\n");
235 +        fprintf(stderr, "\t+T\t\t\t# turn all faces into triangles\n");
236          fprintf(stderr, "\t-x 'xf spec'\t# apply the quoted transform\n");
237          return(1);
238   }
239  
240   void
241 < eputs(char *s)                          /* put string to stderr */
241 > eputs(const char *s)                    /* put string to stderr */
242   {
243          static int  midline = 0;
244  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines