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

Linux Cross Reference
Tina4/src/file/geom/geom3_wrt.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 static void point3_fprint(FILE * fp, Point3 * point, int handed)
 12 
 13 
 14 /* LEFT or RIGHT */
 15 {
 16     float   handupdate = (float)((handed == LEFT) ? -1.0 : 1.0);
 17     Vec3    p1 = {Vec3_id};
 18 
 19     p1 = point->p;
 20     p1.el[1] *= handupdate;     /* for compatibility with old tina
 21                                  * system */
 22     (void) fprintf(fp, "P %d 1 ", point->label);
 23     vec3_print(fp, p1);
 24     (void) fprintf(fp, "\n");
 25 }
 26 
 27 static void line3_fprint(FILE * fp, Line3 * line, int handed)
 28 
 29 
 30 /* LEFT or RIGHT */
 31 {
 32     float   handupdate = (float)((handed == LEFT) ? -1.0 : 1.0);
 33     Vec3    p1 = {Vec3_id};
 34     Vec3    p2 = {Vec3_id};
 35     Vec3    v = {Vec3_id};
 36 
 37     p1 = line->p1;
 38     p2 = line->p2;
 39     p1.el[1] *= handupdate;     /* for compatibility with old tina
 40                                  * system */
 41     p2.el[1] *= handupdate;
 42     v = line->v;
 43     (void) fprintf(fp, "S %d 1 %f ", line->label, line->length);
 44     vec3_print(fp, p1);
 45     vec3_print(fp, p2);
 46     vec3_print(fp, v);
 47     (void) fprintf(fp, "\n");
 48 }
 49 
 50 static void conic3_fprint(FILE * fp, Conic3 * con3, int handed)
 51 {
 52     float   handupdate = (float)((handed == LEFT) ? -1.0 : 1.0);
 53     Vec3    origin = {Vec3_id};
 54     Vec3    ex = {Vec3_id};
 55     Vec3    ey = {Vec3_id};
 56     Conic  *conic;
 57 
 58     if (con3->type != ELLIPSE)
 59         return;
 60 
 61     origin = con3->origin;
 62     ex = con3->ex;
 63     ey = con3->ey;
 64     origin.el[1] *= handupdate;
 65     ex.el[1] *= handupdate;
 66     ey.el[1] *= handupdate;
 67 
 68     conic = con3->conic;
 69 
 70     (void) fprintf(fp, "E %d ", conic->label);
 71     vec3_print(fp, origin);
 72     vec3_print(fp, ex);
 73     vec3_print(fp, ey);
 74     (void) fprintf(fp, "%f %f %f ", conic->theta, conic->alpha, conic->beta);
 75     (void) fprintf(fp, "%f %f\n", conic->t1, conic->t2);
 76 }
 77 
 78 static void plane_fprint(FILE * fp, Plane * plane, int handed)
 79 
 80 
 81 /* LEFT or RIGHT */
 82 {
 83     float   handupdate = (float)((handed == LEFT) ? -1.0 : 1.0);
 84     Vec3    p = {Vec3_id};
 85     Vec3    n = {Vec3_id};
 86 
 87     p = plane->p;
 88     n = plane->n;
 89     p.el[1] *= handupdate;      /* for compatibility with old tina
 90                                  * system */
 91     n.el[1] *= handupdate;
 92     (void) fprintf(fp, "N %d ", plane->label);
 93     vec3_print(fp, p);
 94     vec3_print(fp, n);
 95     (void) fprintf(fp, "\n");
 96 }
 97 
 98 static FILE *fp_static;
 99 static int handed_static;
100 
101 static void geom_fprintf(void *geom, int type)
102 {
103     switch (type)
104     {
105     case POINT3:
106         point3_fprint(fp_static, (Point3 *) geom, handed_static);
107         break;
108     case LINE3:
109         line3_fprint(fp_static, (Line3 *) geom, handed_static);
110         break;
111     case CONIC3:
112         conic3_fprint(fp_static, (Conic3 *) geom, handed_static);
113         break;
114     case PLANE:
115         plane_fprint(fp_static, (Plane *) geom, handed_static);
116         break;
117     default:
118         break;
119     }
120 }
121 
122 /* BUGFIX: Julian Briggs 1/11/93. Was: List   *geom3_write_fp(FILE *
123  * fp, List * geom, int handed) */
124 void    geom3_write_fp(FILE * fp, List * geom, int handed       /* LEFT or RIGHT handed
125                            coords */ )
126 {
127     fp_static = fp;
128     handed_static = handed;
129     reclist_list_apply(geom, geom_fprintf, (int) NULL, NULL);
130 }
131 
132 void    geom3_write(char *pathname, List * geom, int handed)
133 
134 
135 /* LEFT or RIGHT handed coords */
136 {
137     char    temps[256];
138     FILE   *fp;
139 
140     if ((fp = fopen(pathname, "wt")) == NULL)
141     {
142         (void) string_append(temps, "can not open file ", pathname, 0);
143         error(temps, non_fatal);
144         return;
145     }
146     geom3_write_fp(fp, geom, handed);
147     (void) fclose(fp);
148 }
149 
150 void    line3_write_geom(char *pathname, List * geom, int handed)       /* historical */
151 
152 
153 /* LEFT or RIGHT handed coords */
154 {
155     geom3_write(pathname, geom, handed);
156 }
157 

~ [ 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.