5 #define INNER_SPACING 0.35
6 #define OUTER_SPACING 1.5
8 #include "sn_network.h"
10 static double x_offset = OUTER_SPACING;
11 static int next_vertex_number = 0;
13 static int tex_show_stage (sn_stage_t *s)
15 int lines[s->comparators_num];
16 int right[s->comparators_num];
20 for (i = 0; i < s->comparators_num; i++)
26 for (i = 0; i < s->comparators_num; i++)
29 sn_comparator_t *c = s->comparators + i;
34 min_num = next_vertex_number;
37 max_num = next_vertex_number;
40 for (j = 0; j < lines_used; j++)
41 if (SN_COMP_LEFT (c) > right[j])
45 right[j] = SN_COMP_RIGHT (c);
49 printf ("\\node[vertex] (v%i) at (%.2f,%i) {};\n"
50 "\\node[vertex] (v%i) at (%.2f,%i) {};\n"
51 "\\path[comp] (v%i) -- (v%i);\n"
53 min_num, x_offset + (j * INNER_SPACING), c->min,
54 max_num, x_offset + (j * INNER_SPACING), c->max,
58 x_offset = x_offset + ((lines_used - 1) * INNER_SPACING) + OUTER_SPACING;
61 } /* int tex_show_stage */
63 int main (int argc, char **argv)
72 fh = fopen (argv[1], "r");
76 printf ("fh == NULL!\n");
80 n = sn_network_read (fh);
84 printf ("n == NULL!\n");
88 printf ("\\begin{tikzpicture}[scale=%.2f,auto]\n", SCALE);
90 for (i = 0; i < SN_NETWORK_STAGE_NUM (n); i++)
91 tex_show_stage (SN_NETWORK_STAGE_GET (n, i));
93 for (i = 0; i < SN_NETWORK_INPUT_NUM (n); i++)
94 printf ("\\path[edge] (0,%i) -- (%.2f,%i);\n",
97 printf ("\\end{tikzpicture}\n");
102 /* vim: set shiftwidth=2 softtabstop=2 : */