Index: trunk/Ohana/src/opihi/cmd.astro/objload.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/objload.c	(revision 3693)
+++ trunk/Ohana/src/opihi/cmd.astro/objload.c	(revision 5846)
@@ -5,9 +5,9 @@
 int objload (int argc, char **argv) {
   
-  int i, nstar, N, Nout, n, Type, type, NSTAR, Nline, status;
-  double *X, *Y;
+  int i, N, Objtype, type, Nline, status;
   FILE *f;
   char *buffer, *line;
-  int Ximage, Nimage;
+  int Ximage, Nimage, Noverlay, NOVERLAY;
+  KiiOverlay *overlay;
   
   Nimage = -1;
@@ -19,17 +19,15 @@
   if (!GetImage (&Ximage, &Nimage)) return (FALSE);
 
-  Type = 0;
+  Objtype = 0;
   if ((N = get_argument (argc, argv, "-t"))) {
     remove_argument (N, &argc, argv);
-    Type = atof (argv[N]);
+    Objtype = atof (argv[N]);
     remove_argument (N, &argc, argv);
   }
 
   if (argc != 3) {
-    fprintf (stderr, "USAGE: load (overlay) <filename>\n");
+    fprintf (stderr, "USAGE: objload (overlay) <filename>\n");
     return (FALSE);
   }
-
-  if (!SelectOverlay (argv[1], &n)) return (FALSE);
 
   f = fopen (argv[2], "r");
@@ -43,22 +41,21 @@
   scan_line (f, line);
 
-  nstar = 0;
-  NSTAR = 1000;
-  ALLOCATE (X, double, NSTAR);
-  ALLOCATE (Y, double, NSTAR);
   ALLOCATE (buffer, char, CHAR_LINE*NBLOCK);
 
+  Noverlay = 0;
+  NOVERLAY = 1000;
+  ALLOCATE (overlay, KiiOverlay, Noverlay);
+  
   /* read in data from obj file */
   while ((Nline = fread (buffer, CHAR_LINE, NBLOCK, f)) > 0) {
     for (i = 0; i < Nline; i++) {
       /* we are now using all entries on the *.obj line */
-      status = sscanf (&buffer[i*CHAR_LINE], "%d %lf %lf",  &type, &X[nstar], &Y[nstar]);
-      if (Type && (Type != type)) continue;
-      nstar ++;
-      if (nstar == NSTAR) {
-	NSTAR += 1000;
-	REALLOCATE (X, double, NSTAR);
-	REALLOCATE (Y, double, NSTAR);
-      }
+      status = sscanf (&buffer[i*CHAR_LINE], "%d %f %f",  &type, &overlay[Noverlay].x, &overlay[Noverlay].y);
+      if (Objtype && (Objtype != type)) continue;
+      overlay[Noverlay].type = KII_OVERLAY_BOX;
+      overlay[Noverlay].dx = 5.0;
+      overlay[Noverlay].dy = 5.0;
+      Noverlay ++;
+      CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000);
     }
   }
@@ -66,33 +63,11 @@
   free (buffer);
 
-  SendGraphCommand (Ximage, 4, "LOAD");
-  SendGraphCommand (Ximage, 16, "OVER %9d ", n);
-  
-  /** NOTE: modify to use NBYTE **/
-  ALLOCATE (buffer, char, 66000);
-  bzero (buffer, 65536);
-  for (Nout = i = 0; i < nstar; i++, Nout++) {
-    snprintf (&buffer[Nout*128], 129, "%15s %20.10f %20.10f %20.10f %20.10f ", "BOX", X[i], Y[i], 5.0, 5.0);
-    if (Nout == 512) {
-      SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nout);
-      write (Ximage, buffer, Nout*128);
-      bzero (buffer, 65536);
-      Nout = -1;
-    }
-  }
+  KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]);
 
-  if (Nout) {
-    SendGraphCommand (Ximage, 16, "NLINES  %7d ", Nout);
-    write (Ximage, buffer, Nout*128);
-  }
-  SendGraphCommand (Ximage, 16, "DONE");
-
-  free (X);
-  free (Y);
-
+  free (overlay);
   free (buffer);
   free (line);
 
-  fprintf (stderr, "loaded %d objects\n", nstar);
+  fprintf (stderr, "loaded %d objects\n", Noverlay);
   return (TRUE);
 }
