| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | #include "gibbs.h" |
|---|
| 9 | #include <unistd.h> |
|---|
| 10 | #include <stdio.h> |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | int GeomviewBegin (FILE **geompipe, char *version) |
|---|
| 28 | { |
|---|
| 29 | int ierr, gv_pid, gv_pipe[2], to_gv_pipe[2]; |
|---|
| 30 | |
|---|
| 31 | pipe (gv_pipe); |
|---|
| 32 | pipe (to_gv_pipe); |
|---|
| 33 | gv_pid = fork (); |
|---|
| 34 | |
|---|
| 35 | if(gv_pid==0) |
|---|
| 36 | { |
|---|
| 37 | close (0); |
|---|
| 38 | dup (to_gv_pipe[0]); |
|---|
| 39 | close (to_gv_pipe[0]); |
|---|
| 40 | close (to_gv_pipe[1]); |
|---|
| 41 | close (1); |
|---|
| 42 | dup (gv_pipe[1]); |
|---|
| 43 | close (gv_pipe[0]); |
|---|
| 44 | close (gv_pipe[1]); |
|---|
| 45 | |
|---|
| 46 | execlp (GEOMVIEW,GEOMVIEW,"-c","(interest (pick world))","-",NULL); |
|---|
| 47 | perror (GEOMVIEW); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | close (gv_pipe[1]); |
|---|
| 52 | close (to_gv_pipe[0]); |
|---|
| 53 | *geompipe = fdopen (to_gv_pipe[1], "w"); |
|---|
| 54 | |
|---|
| 55 | if (version) |
|---|
| 56 | { |
|---|
| 57 | fprintf (*geompipe, "(echo (geomview-version) \"\n\")\n"); |
|---|
| 58 | fflush (*geompipe); |
|---|
| 59 | read (gv_pipe[0], version, 99); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | return 0; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | int GeomviewDisplayTriangleCOFF |
|---|
| 89 | (FILE *geompipe, char *name, char *label, char *appearance, |
|---|
| 90 | int npoints, visual_point *points, int ntriangles, int *vertices) |
|---|
| 91 | { |
|---|
| 92 | int i; |
|---|
| 93 | |
|---|
| 94 | fprintf (geompipe, "(geometry \"%s\" { : %s })\n", name, label); |
|---|
| 95 | fprintf (geompipe, "(read geometry { define %s \n", label); |
|---|
| 96 | fprintf (geompipe, "appearance { %s }\nCOFF\n", appearance); |
|---|
| 97 | fprintf (geompipe, "%d %d 0\n", npoints, ntriangles); |
|---|
| 98 | |
|---|
| 99 | for (i=0; i<npoints; i++) |
|---|
| 100 | fprintf (geompipe, "%g %g %g %g %g %g %g\n", points[i].x, points[i].y, |
|---|
| 101 | points[i].z, points[i].red, points[i].green, points[i].blue, |
|---|
| 102 | points[i].alpha); |
|---|
| 103 | |
|---|
| 104 | for (i=0; i<ntriangles; i++) |
|---|
| 105 | fprintf (geompipe, "3 %d %d %d\n", vertices[3*i], vertices[3*i+1], |
|---|
| 106 | vertices[3*i+2]); |
|---|
| 107 | |
|---|
| 108 | fprintf (geompipe, "})\n"); |
|---|
| 109 | fflush (geompipe); |
|---|
| 110 | |
|---|
| 111 | return 0; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | int GeomviewDisplayFacets |
|---|
| 140 | (FILE *geompipe, char *name, char *label, char *appearance, |
|---|
| 141 | int npoints, visual_point *points, int numfacets, hull_facet *facets, |
|---|
| 142 | facet_type type) |
|---|
| 143 | { |
|---|
| 144 | int i, n=0; |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | if (type == ALL_TYPES) |
|---|
| 148 | n = numfacets; |
|---|
| 149 | else |
|---|
| 150 | for (i=0; i<numfacets; i++) |
|---|
| 151 | if (facets [i].type == type) |
|---|
| 152 | n++; |
|---|
| 153 | |
|---|
| 154 | fprintf (geompipe, "(geometry \"%s\" { : %s })\n", name, label); |
|---|
| 155 | fprintf (geompipe, "(read geometry { define %s \n", label); |
|---|
| 156 | fprintf (geompipe, "appearance { %s }\nCOFF\n", appearance); |
|---|
| 157 | fprintf (geompipe, "%d %d 0\n", npoints, n); |
|---|
| 158 | |
|---|
| 159 | for (i=0; i<npoints; i++) |
|---|
| 160 | fprintf (geompipe, "%g %g %g %g %g %g %g\n", points[i].x, points[i].y, |
|---|
| 161 | points[i].z, points[i].red, points[i].green, points[i].blue, |
|---|
| 162 | points[i].alpha); |
|---|
| 163 | |
|---|
| 164 | for (i=0; i<numfacets; i++) |
|---|
| 165 | if (type == ALL_TYPES || type == facets[i].type) |
|---|
| 166 | fprintf (geompipe, "3 %d %d %d\n", facets[i].vertex[0], facets[i].vertex[1], facets[i].vertex[2]); |
|---|
| 167 | |
|---|
| 168 | fprintf (geompipe, "})\n"); |
|---|
| 169 | fflush (geompipe); |
|---|
| 170 | |
|---|
| 171 | return 0; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | int GeomviewDisplayPhaseBoundary |
|---|
| 198 | (FILE *geompipe, char *name, char *label, char *appearance, |
|---|
| 199 | int npoints, visual_point *points, phase_boundary *theboundary) |
|---|
| 200 | { |
|---|
| 201 | int i, n_edges=0, c; |
|---|
| 202 | |
|---|
| 203 | if (theboundary) |
|---|
| 204 | { |
|---|
| 205 | n_edges = theboundary->n_edges; |
|---|
| 206 | c = theboundary->compos; |
|---|
| 207 | } |
|---|
| 208 | else |
|---|
| 209 | npoints = 0; |
|---|
| 210 | |
|---|
| 211 | fprintf (geompipe, "(geometry \"%s\" { : %s })\n", name, label); |
|---|
| 212 | fprintf (geompipe, "(read geometry { define %s \n", label); |
|---|
| 213 | fprintf (geompipe, "appearance { %s }\nCOFF\n", appearance); |
|---|
| 214 | fprintf (geompipe, "%d %d 0\n", npoints, n_edges); |
|---|
| 215 | |
|---|
| 216 | #ifdef DEBUG |
|---|
| 217 | printf ("(geometry \"%s\" { : %s })\n", name, label); |
|---|
| 218 | printf ("(read geometry { define %s \n", label); |
|---|
| 219 | printf ("appearance { %s }\nCOFF\n", appearance); |
|---|
| 220 | printf ("%d %d 0\n", npoints, n_edges); |
|---|
| 221 | #endif |
|---|
| 222 | |
|---|
| 223 | for (i=0; i<npoints; i++) |
|---|
| 224 | { |
|---|
| 225 | fprintf (geompipe, "%g %g %g %g %g %g %g\n", points[i].x, points[i].y, |
|---|
| 226 | points[i].z, points[i].red, points[i].green, points[i].blue, |
|---|
| 227 | points[i].alpha); |
|---|
| 228 | #ifdef DEBUG |
|---|
| 229 | printf ("%g %g %g %g %g %g %g\n", points[i].x, points[i].y, |
|---|
| 230 | points[i].z, points[i].red, points[i].green, points[i].blue, |
|---|
| 231 | points[i].alpha); |
|---|
| 232 | #endif |
|---|
| 233 | } |
|---|
| 234 | for (i=0; i<n_edges; i++) |
|---|
| 235 | { |
|---|
| 236 | fprintf (geompipe, "3 %d %d %d\n", theboundary->edges [c*i], |
|---|
| 237 | (c>1) ? theboundary->edges [c*i+1] : theboundary->edges [c*i], |
|---|
| 238 | (c>2) ? theboundary->edges [c*i+2] : theboundary->edges [c*i]); |
|---|
| 239 | #ifdef DEBUG |
|---|
| 240 | printf ("3 %d %d %d\n", theboundary->edges [c*i], |
|---|
| 241 | (c>1) ? theboundary->edges [c*i+1] : theboundary->edges [c*i], |
|---|
| 242 | (c>2) ? theboundary->edges [c*i+2] : theboundary->edges [c*i]); |
|---|
| 243 | #endif |
|---|
| 244 | } |
|---|
| 245 | fprintf (geompipe, "})\n"); |
|---|
| 246 | #ifdef DEBUG |
|---|
| 247 | printf ("})\n"); |
|---|
| 248 | #endif |
|---|
| 249 | fflush (geompipe); |
|---|
| 250 | |
|---|
| 251 | return 0; |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | int GeomviewEnd (FILE **geompipe) |
|---|
| 266 | { |
|---|
| 267 | fprintf (*geompipe, "(exit)"); |
|---|
| 268 | fclose (*geompipe); |
|---|
| 269 | *geompipe = NULL; |
|---|
| 270 | return 0; |
|---|
| 271 | } |
|---|