Changeset 5846 for trunk/Ohana/src/opihi/cmd.astro/objload.c
- Timestamp:
- Dec 27, 2005, 5:06:32 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.astro/objload.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/objload.c
r3693 r5846 5 5 int objload (int argc, char **argv) { 6 6 7 int i, nstar, N, Nout, n, Type, type, NSTAR, Nline, status; 8 double *X, *Y; 7 int i, N, Objtype, type, Nline, status; 9 8 FILE *f; 10 9 char *buffer, *line; 11 int Ximage, Nimage; 10 int Ximage, Nimage, Noverlay, NOVERLAY; 11 KiiOverlay *overlay; 12 12 13 13 Nimage = -1; … … 19 19 if (!GetImage (&Ximage, &Nimage)) return (FALSE); 20 20 21 Type = 0;21 Objtype = 0; 22 22 if ((N = get_argument (argc, argv, "-t"))) { 23 23 remove_argument (N, &argc, argv); 24 Type = atof (argv[N]);24 Objtype = atof (argv[N]); 25 25 remove_argument (N, &argc, argv); 26 26 } 27 27 28 28 if (argc != 3) { 29 fprintf (stderr, "USAGE: load (overlay) <filename>\n");29 fprintf (stderr, "USAGE: objload (overlay) <filename>\n"); 30 30 return (FALSE); 31 31 } 32 33 if (!SelectOverlay (argv[1], &n)) return (FALSE);34 32 35 33 f = fopen (argv[2], "r"); … … 43 41 scan_line (f, line); 44 42 45 nstar = 0;46 NSTAR = 1000;47 ALLOCATE (X, double, NSTAR);48 ALLOCATE (Y, double, NSTAR);49 43 ALLOCATE (buffer, char, CHAR_LINE*NBLOCK); 50 44 45 Noverlay = 0; 46 NOVERLAY = 1000; 47 ALLOCATE (overlay, KiiOverlay, Noverlay); 48 51 49 /* read in data from obj file */ 52 50 while ((Nline = fread (buffer, CHAR_LINE, NBLOCK, f)) > 0) { 53 51 for (i = 0; i < Nline; i++) { 54 52 /* we are now using all entries on the *.obj line */ 55 status = sscanf (&buffer[i*CHAR_LINE], "%d %lf %lf", &type, &X[nstar], &Y[nstar]); 56 if (Type && (Type != type)) continue; 57 nstar ++; 58 if (nstar == NSTAR) { 59 NSTAR += 1000; 60 REALLOCATE (X, double, NSTAR); 61 REALLOCATE (Y, double, NSTAR); 62 } 53 status = sscanf (&buffer[i*CHAR_LINE], "%d %f %f", &type, &overlay[Noverlay].x, &overlay[Noverlay].y); 54 if (Objtype && (Objtype != type)) continue; 55 overlay[Noverlay].type = KII_OVERLAY_BOX; 56 overlay[Noverlay].dx = 5.0; 57 overlay[Noverlay].dy = 5.0; 58 Noverlay ++; 59 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000); 63 60 } 64 61 } … … 66 63 free (buffer); 67 64 68 SendGraphCommand (Ximage, 4, "LOAD"); 69 SendGraphCommand (Ximage, 16, "OVER %9d ", n); 70 71 /** NOTE: modify to use NBYTE **/ 72 ALLOCATE (buffer, char, 66000); 73 bzero (buffer, 65536); 74 for (Nout = i = 0; i < nstar; i++, Nout++) { 75 snprintf (&buffer[Nout*128], 129, "%15s %20.10f %20.10f %20.10f %20.10f ", "BOX", X[i], Y[i], 5.0, 5.0); 76 if (Nout == 512) { 77 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nout); 78 write (Ximage, buffer, Nout*128); 79 bzero (buffer, 65536); 80 Nout = -1; 81 } 82 } 65 KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]); 83 66 84 if (Nout) { 85 SendGraphCommand (Ximage, 16, "NLINES %7d ", Nout); 86 write (Ximage, buffer, Nout*128); 87 } 88 SendGraphCommand (Ximage, 16, "DONE"); 89 90 free (X); 91 free (Y); 92 67 free (overlay); 93 68 free (buffer); 94 69 free (line); 95 70 96 fprintf (stderr, "loaded %d objects\n", nstar);71 fprintf (stderr, "loaded %d objects\n", Noverlay); 97 72 return (TRUE); 98 73 }
Note:
See TracChangeset
for help on using the changeset viewer.
