home *** CD-ROM | disk | FTP | other *** search
/ vis-ftp.cs.umass.edu / vis-ftp.cs.umass.edu.tar / vis-ftp.cs.umass.edu / pub / Software / ASCENDER / ascendMar8.tar / UMass / BuildingFinder / Staging / I_fileIO.c < prev    next >
C/C++ Source or Header  |  1995-04-13  |  2KB  |  64 lines

  1. #include "../header.h"
  2. #include <fcntl.h>
  3.  
  4. #define round(x,y)  ( (modf(x,&y) > 0.5) ? ceil(x) : floor(x) )
  5.  
  6.  
  7. extern c_handle image_trans;
  8. extern c_handle view_trans;
  9. int
  10. printIntersections(c_handle pane, Intersection *list, char *cornerFile)
  11. /*
  12.  * 'fname' is the name of the file that contains the projection matrix
  13.  * relavent to the image in which the intersections will be labeled.
  14.  * this is needed for the "old" system in which each corner needed
  15.  * a label.
  16.  *
  17.  */
  18. {
  19.     
  20.     Intersection *ptr;
  21.     int type;
  22.     double certainty;
  23.     double t;
  24.     double_2 *p1;
  25.     double_2 *temp;
  26.     int fd;
  27.  
  28.     FILE *fp, *fopen();
  29.  
  30.     if ( (fd = open(cornerFile,O_WRONLY | O_CREAT | O_TRUNC, 0777)) < 0) {
  31.         fprintf(stderr,"Error creating temporary file.\n");
  32.         return(-1);
  33.     }
  34.     if ( (fp = fdopen(fd,"w")) == NULL) {
  35.         fprintf(stderr,"Error opening output token file!\n");
  36.         return(-1);
  37.     }
  38.  
  39.     ptr = list;
  40.     while (ptr != NULL) {
  41.         
  42.         certainty = (ptr->leg1.contrast + ptr->leg2.contrast) / 2.0;
  43.  
  44.  
  45.                 fprintf(fp,"%d %d %f %d %f %f %f %f\n",
  46.                         (int)floor(ptr->p.d1),(int)floor(ptr->p.d2),
  47.                         ptr->height,
  48.                         (int)floor(certainty),
  49.                         ptr->leg1Dx,ptr->leg1Dy,ptr->leg2Dx,ptr->leg2Dy);
  50.  
  51.  
  52.            temp = (double_2 *) transform_point(view_trans,ptr->p.d1,
  53.                             ptr->p.d2,0);
  54.  
  55.         p1 = (double_2 *) inverse_transform_point(image_trans,temp->d1,
  56.                     temp->d2,0);
  57.         draw_fat_point(pane,p1->d1,p1->d2,3.0);
  58.  
  59.         ptr = ptr->next;
  60.     }
  61.     fclose(fp);
  62.     close(fd);
  63. }
  64.