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

Comparing ray/src/ot/obj2mesh.c (file contents):
Revision 2.1 by greg, Tue Mar 11 17:08:55 2003 UTC vs.
Revision 2.6 by schorsch, Sun Jun 8 12:03:10 2003 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
6   */
7  
8   #include "copyright.h"
9 + #include "platform.h"
10   #include "standard.h"
11   #include "cvmesh.h"
12   #include "otypes.h"
# Line 31 | Line 32 | main(argc, argv)               /* compile a .OBJ file into a mesh *
32   int  argc;
33   char  *argv[];
34   {
35 <        int  i;
35 >        int  nmatf = 0;
36 >        char  *matinp[32];
37 >        int  i, j;
38  
39          progname = argv[0];
40          ofun[OBJ_FACE].funp = o_face;
# Line 44 | Line 47 | char  *argv[];
47                  case 'r':                               /* resolution limit */
48                          resolu = atoi(argv[++i]);
49                          break;
50 +                case 'a':                               /* material file */
51 +                        matinp[nmatf++] = argv[++i];
52 +                        break;
53                  case 'w':                               /* supress warnings */
54                          nowarn = 1;
55                          break;
# Line 54 | Line 60 | char  *argv[];
60                  }
61                                          /* initialize mesh */
62          cvinit(i==argc-2 ? argv[i+1] : "<stdout>");
63 <
64 <        if (i == argc)                  /* read .OBJ file into triangles */
63 >                                        /* load material input */
64 >        for (j = 0; j < nmatf; j++)
65 >                readobj(matinp[j]);
66 >                                        /* read .OBJ file into triangles */
67 >        if (i == argc)
68                  wfreadobj(NULL);
69          else
70                  wfreadobj(argv[i]);
# Line 65 | Line 74 | char  *argv[];
74          if (i == argc-2)                /* open output file */
75                  if (freopen(argv[i+1], "w", stdout) == NULL)
76                          error(SYSTEM, "cannot open output file");
77 < #ifdef MSDOS
69 <        setmode(fileno(stdout), O_BINARY);
70 < #endif
77 >        SET_FILE_BINARY(stdout);
78          newheader("RADIANCE", stdout);  /* new binary file header */
79          printargs(i<argc ? i+1 : argc, argv, stdout);
80          fputformat(MESHFMT, stdout);
# Line 76 | Line 83 | char  *argv[];
83          mincusize = ourmesh->mcube.cusize / resolu - FTINY;
84  
85          for (i = 0; i < nobjects; i++)  /* add triangles to octree */
86 <                addface(&ourmesh->mcube, i);
86 >                if (objptr(i)->otype == OBJ_FACE)
87 >                        addface(&ourmesh->mcube, i);
88  
89                                          /* optimize octree */
90          ourmesh->mcube.cutree = combine(ourmesh->mcube.cutree);
# Line 88 | Line 96 | char  *argv[];
96  
97          writemesh(ourmesh, stdout);     /* write mesh to output */
98          
99 < printmeshstats(ourmesh, stderr);
99 >        /* printmeshstats(ourmesh, stderr); */
100  
101          quit(0);
102   }
# Line 138 | Line 146 | addface(cu, obj)                       /* add a face to a cube */
146   register CUBE  *cu;
147   OBJECT  obj;
148   {
141        CUBE  cukid;
142        OCTREE  ot;
143        OBJECT  oset[MAXSET+1];
144        register int  i, j;
149  
150          if (o_face(objptr(obj), cu) == O_MISS)
151                  return;
152  
153          if (istree(cu->cutree)) {
154 <                                                /* do children */
154 >                CUBE  cukid;                    /* do children */
155 >                int  i, j;
156                  cukid.cusize = cu->cusize * 0.5;
157                  for (i = 0; i < 8; i++) {
158                          cukid.cutree = octkid(cu->cutree, i);
# Line 162 | Line 167 | OBJECT obj;
167                  return;
168          }
169          if (isempty(cu->cutree)) {
170 <                                                /* singular set */
170 >                OBJECT  oset[2];                /* singular set */
171                  oset[0] = 1; oset[1] = obj;
172                  cu->cutree = fullnode(oset);
173                  return;
174          }
175                                          /* add to full node */
176 +        add2full(cu, obj);
177 + }
178 +
179 +
180 + add2full(cu, obj)                       /* add object to full node */
181 + register CUBE  *cu;
182 + OBJECT  obj;
183 + {
184 +        OCTREE  ot;
185 +        OBJECT  oset[MAXSET+1];
186 +        CUBE  cukid;
187 +        register int  i, j;
188 +
189          objset(oset, cu->cutree);
190          cukid.cusize = cu->cusize * 0.5;
191  
192          if (oset[0] < objlim || cukid.cusize < mincusize) {
193                                                  /* add to set */
194                  if (oset[0] >= MAXSET) {
195 <                        sprintf(errmsg, "set overflow in addface (%s)",
195 >                        sprintf(errmsg, "set overflow in addobject (%s)",
196                                          objptr(obj)->oname);
197                          error(INTERNAL, errmsg);
198                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines