~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/file/edges/wisp_write.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2   */
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/mathfuncs.h>
  8 #include <tina/vision.h>
  9 #include <tina/visionfuncs.h>
 10 
 11 extern Bool fclose_2(FILE * stream, const char *pathname);
 12 extern FILE *fopen_2(const char *pathname, const char *mode);
 13 
 14 static FILE *stream;
 15 static Bool first = true;
 16 static float cx, cy;
 17 static float ax, ay;
 18 
 19 static void wisp_write_edge(Edgel * edge)
 20 {
 21     if (first == true)
 22     {
 23         (void) fprintf(stream, "\nm ");
 24         first = false;
 25     } else
 26         (void) fprintf(stream, "c ");
 27 
 28     (void) fprintf(stream, "%f %f\n", (vec2_x(edge->pos) - cx) * ay, (cy - vec2_y(edge->pos)) * ax);
 29 }
 30 
 31 static void wisp_write_poly(Line2 * line)
 32 {
 33     if (first == true)
 34     {
 35         (void) fprintf(stream, "\nm %f %f\n", (vec2_x(line->p1) - cx) * ay, (cy - vec2_y(line->p1)) * ax);
 36         first = false;
 37     }
 38     (void) fprintf(stream, "c %f %f\n", (vec2_x(line->p2) - cx) * ay, (cy - vec2_y(line->p2)) * ax);
 39 }
 40 
 41 void    wisp_write_edge_string(Tstring * s)
 42 {
 43     first = true;
 44     str_apply_func(s, wisp_write_edge, NULL);
 45 }
 46 
 47 static void wisp_write_poly_string(Tstring * s)
 48 {
 49     Tstring *p;
 50     double  dummy = 0.0;
 51 
 52     first = true;
 53 
 54     /* BUG poly_string requires 2nd argument: double thres. dummy added */
 55     p = poly_string(s, dummy);
 56     str_apply_func(p, wisp_write_poly, NULL);
 57 }
 58 
 59 void    wisp_write_edges_stream(Imrect * er, Camera * camera, FILE * stream_out)
 60 {
 61     float   f;
 62 
 63     if (er)
 64     {
 65         stream = stream_out;
 66 
 67         if (camera == NULL)
 68         {
 69             f = (float) 1.0;
 70             cx = (float) (er->width / 2); /* these two lines may cause a
 71                                              roundoff bug NAT 3/5/95 */
 72             cy = (float) (er->height / 2);
 73             ax = (float) 1.0;
 74             ay = (float) 1.0;
 75         } else
 76         {
 77             f = camera->f / camera->pixel * camera->ax;
 78             cx = camera->cx;
 79             cy = camera->cy;
 80             ax = camera->ax;
 81             ay = camera->ay;
 82         }
 83 
 84         (void) fprintf(stream, "ICF %f %d\n", f, er->width / 2);
 85 
 86         er_apply_to_all_strings(er, wisp_write_poly_string, NULL);
 87     }
 88 }
 89 
 90 void    wisp_write_edges(char *pathname, Imrect * er, Camera * camera)
 91 {
 92     if (er)
 93     {
 94         FILE   *stream = fopen_2(pathname, "w");
 95 
 96         if (stream)
 97         {
 98             wisp_write_edges_stream(er, camera, stream);
 99             (void) fclose_2(stream, pathname);
100         }
101     }
102 }
103 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.