[Commit] tess ChangeLog,NONE,1.1 bentley.5c,1.1,1.2
Carl Worth
commit at keithp.com
Wed Jul 7 08:32:37 PDT 2004
- Previous message: [Commit] nickle ChangeLog, 1.72, 1.73 compile.c, 1.157,
1.158 execute.c, 1.91, 1.92 gram.y, 1.137, 1.138 sched.c, 1.56,
1.57 value.h, 1.106, 1.107
- Next message: [Commit] tess ChangeLog,1.1,1.2 bentley.5c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: cworth
Update of /local/src/CVS/tess
In directory home.keithp.com:/tmp/cvs-serv29666
Modified Files:
bentley.5c
Added Files:
ChangeLog
Log Message:
* bentley.5c: Move SVG printing up to the top-level to declutter
the algorithm.
--- NEW FILE: ChangeLog ---
2004-07-07 Carl Worth <cworth at isi.edu>
* bentley.5c: Move SVG printing up to the top-level to declutter
the algorithm.
Index: bentley.5c
===================================================================
RCS file: /local/src/CVS/tess/bentley.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- bentley.5c 3 Jul 2004 07:41:22 -0000 1.1
+++ bentley.5c 7 Jul 2004 15:32:35 -0000 1.2
@@ -115,6 +115,130 @@
return event_greater (*a.elt, *b.elt);
}
+void fprint_edge (file f, Edge e)
+{
+ fprintf (f, "(%2d, %2d)-(%2d, %2d)",
+ e.top.x, e.top.y,
+ e.bottom.x, e.bottom.y);
+}
+
+void fprint_edge_svg (file svg_file, Edge e)
+{
+ fprintf (svg_file, "<line x1='%d' y1='%d' x2='%d' y2='%d' />\n",
+ e.top.x, e.top.y,
+ e.bottom.x, e.bottom.y);
+}
+
+void fprint_event_queue (file f, EventPtr e)
+{
+ while (e != Sortlist::List.nil) {
+ union switch (e.elt->type) {
+ case Start:
+ fprintf (f, "Start: ");
+ break;
+ case Stop:
+ fprintf (f, "Stop: ");
+ break;
+ case Intersect:
+ fprintf (f, "Intersect: ");
+ break;
+ }
+ fprintf (f, "%g:\t", e.elt->point);
+ fprint_edge (f, *e.elt->e1.elt);
+ if (e.elt->type == EventType.Intersect) {
+ fprintf (f, " X ");
+ fprint_edge (f, *e.elt->e2.elt);
+ }
+ fprintf (f, "\n");
+ e = e.elt->next;
+ }
+}
+
+void fprint_event_queue_svg (file svg_file, EventPtr e)
+{
+ int text_y = 214;
+
+ while (e != Sortlist::List.nil) {
+ fprintf (svg_file, "<text stroke='none' fill='black' x='0' y='%d'>\n", text_y);
+ text_y += 14;
+ union switch (e.elt->type) {
+ case Start:
+ fprintf (svg_file, "Start: ");
+ break;
+ case Stop:
+ fprintf (svg_file, "Stop: ");
+ break;
+ case Intersect:
+ fprintf (svg_file, "Intersect: ");
+ break;
+ }
+ fprintf (svg_file, "%g:\t", e.elt->point);
+ fprint_edge (svg_file, *e.elt->e1.elt);
+ if (e.elt->type == EventType.Intersect) {
+ fprintf (svg_file, " X ");
+ fprint_edge (svg_file, *e.elt->e2.elt);
+ }
+ fprintf (svg_file, "\n");
+ e = e.elt->next;
+ fprintf (svg_file, "</text>\n");
+ }
+}
+
+void fprint_sweep_line (file f, EdgePtr e)
+{
+ while (e != Sortlist::List.nil) {
+ fprint_edge (f, *e.elt);
+ e = e.elt->next;
+ if (e != Sortlist::List.nil)
+ fprintf (f, ", ");
+ }
+ fprintf (f, "\n");
+}
+
+void print_sweep_line_svg (file svg_file, EdgePtr sweep_line, Edge[*] segments, EventPtr event_queue, EventPtr event, int current_y)
+{
+ fprintf (svg_file, "<?xml version='1.0' standalone='no'?>\n");
+ fprintf (svg_file, "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'\n");
+ fprintf (svg_file, " 'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd'>\n");
+ fprintf (svg_file, "<svg transform='translate(70,70)' fill='none' stroke='black' font='mono' font-size='12'>\n");
+
+ fprintf (svg_file, "<g transform='scale(30,30)' stroke-width='.05'>\n");
+ for (int i=0; i < dim(segments); i++) {
+ fprint_edge_svg (svg_file, segments[i]);
+ }
+ fprintf (svg_file, "</g>\n");
+
+ fprintf (svg_file, "<text stroke='none' fill='blue' x='0' y='200'>\n");
+ EdgePtr e = sweep_line;
+ while (e != Sortlist::List.nil) {
+ fprint_edge (svg_file, *e.elt);
+ if (e != Sortlist::List.nil)
+ fprintf (svg_file, ", ");
+ e = e.elt->next;
+ }
+ fprintf (svg_file, "</text>\n");
+
+ fprintf (svg_file, "<g transform='scale(30,30)' stroke='blue' stroke-width='.05'>\n");
+ EdgePtr e = sweep_line;
+ int edge_cnt = 0;
+ while (e != Sortlist::List.nil) {
+ fprint_edge_svg (svg_file, *e.elt);
+ fprintf (svg_file, "<text font-size='.4' fill='blue' stroke='none' x='%g' y='%g'>%d</text>\n",
+ e.elt->top.x + .1, e.elt->top.y - .1, edge_cnt++);
+ e = e.elt->next;
+ }
+ fprintf (svg_file, "<line x1='-10' y1='%d' x2='100' y2='%d' stroke-width='.05' stroke='red' />\n",
+ current_y, current_y);
+ fprintf (svg_file, "<text font-size='.4' fill='red' stroke='none' x='15' y='%g'>%d</text>\n", current_y - .1, current_y);
+
+ fprintf (svg_file, "<circle cx='%d' cy='%d' r='.15' stroke='none' fill='green'/>\n", event.elt->point.x, event.elt->point.y);
+ fprintf (svg_file, "</g>\n");
+
+ fprint_event_queue_svg (svg_file, event_queue);
+
+ fprintf (svg_file, "</svg>\n");
+}
+
Edge[*]
bentley_ottman (Edge[*] segments, &int intersection_count) {
@@ -239,136 +363,14 @@
while (event_queue != Sortlist::List.nil) {
file svg_file;
- int text_y;
-
- void fprint_edge (file f, Edge e) {
- fprintf (f, "(%2d, %2d)-(%2d, %2d)",
- e.top.x, e.top.y,
- e.bottom.x, e.bottom.y);
- }
-
- void print_edge_svg (Edge e) {
- fprintf (svg_file, "<line x1='%d' y1='%d' x2='%d' y2='%d' />\n",
- e.top.x, e.top.y,
- e.bottom.x, e.bottom.y);
- }
-
- void fprint_event_queue (file f) {
- EventPtr e = event_queue;
- while (e != Sortlist::List.nil) {
- union switch (e.elt->type) {
- case Start:
- fprintf (f, "Start: ");
- break;
- case Stop:
- fprintf (f, "Stop: ");
- break;
- case Intersect:
- fprintf (f, "Intersect: ");
- break;
- }
- fprintf (f, "%g:\t", e.elt->point);
- fprint_edge (f, *e.elt->e1.elt);
- if (e.elt->type == EventType.Intersect) {
- fprintf (f, " X ");
- fprint_edge (f, *e.elt->e2.elt);
- }
- fprintf (f, "\n");
- e = e.elt->next;
- }
- }
-
- void print_event_queue_svg () {
- EventPtr e = event_queue;
- while (e != Sortlist::List.nil) {
- fprintf (svg_file, "<text stroke='none' fill='black' x='0' y='%d'>\n", text_y);
- text_y += 14;
- union switch (e.elt->type) {
- case Start:
- fprintf (svg_file, "Start: ");
- break;
- case Stop:
- fprintf (svg_file, "Stop: ");
- break;
- case Intersect:
- fprintf (svg_file, "Intersect: ");
- break;
- }
- fprintf (svg_file, "%g:\t", e.elt->point);
- fprint_edge (svg_file, *e.elt->e1.elt);
- if (e.elt->type == EventType.Intersect) {
- fprintf (svg_file, " X ");
- fprint_edge (svg_file, *e.elt->e2.elt);
- }
- fprintf (svg_file, "\n");
- e = e.elt->next;
- fprintf (svg_file, "</text>\n");
- }
- }
-
- void fprint_sweep_line (file f) {
- EdgePtr e = sweep_line;
- while (e != Sortlist::List.nil) {
- fprint_edge (f, *e.elt);
- e = e.elt->next;
- if (e != Sortlist::List.nil)
- fprintf (f, ", ");
- }
- fprintf (f, "\n");
- }
EventPtr event = event_queue;
current_y = event.elt->point.y;
- void print_sweep_line_svg () {
- fprintf (svg_file, "<?xml version='1.0' standalone='no'?>\n");
- fprintf (svg_file, "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'\n");
- fprintf (svg_file, " 'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd'>\n");
- fprintf (svg_file, "<svg transform='translate(70,70)' fill='none' stroke='black' font='mono' font-size='12'>\n");
-
- fprintf (svg_file, "<g transform='scale(30,30)' stroke-width='.05'>\n");
- for (int i=0; i < dim(segments); i++) {
- print_edge_svg (segments[i]);
- }
- fprintf (svg_file, "</g>\n");
-
- fprintf (svg_file, "<text stroke='none' fill='blue' x='0' y='%d'>\n", text_y);
- text_y += 14;
- EdgePtr e = sweep_line;
- while (e != Sortlist::List.nil) {
- fprint_edge (svg_file, *e.elt);
- if (e != Sortlist::List.nil)
- fprintf (svg_file, ", ");
- e = e.elt->next;
- }
- fprintf (svg_file, "</text>\n");
-
- fprintf (svg_file, "<g transform='scale(30,30)' stroke='blue' stroke-width='.05'>\n");
- EdgePtr e = sweep_line;
- int edge_cnt = 0;
- while (e != Sortlist::List.nil) {
- print_edge_svg (*e.elt);
- fprintf (svg_file, "<text font-size='.1' fill='blue' stroke='none' x='%d' y='%d'>%d</text>\n",
- e.elt->top.x + 20, e.elt->top.y + 10, edge_cnt++);
- e = e.elt->next;
- }
- fprintf (svg_file, "<line x1='-100' y1='%d' x2='1000' y2='%d' stroke-width='.1' stroke='red' />\n",
- current_y, current_y);
- fprintf (svg_file, "<text font-size='1' fill='red' stroke='none' x='530' y='%d'>%d</text>\n", current_y - 2, current_y);
-
- fprintf (svg_file, "<circle cx='%d' cy='%d' r='.15' stroke='none' fill='green'/>\n", event.elt->point.x, event.elt->point.y);
- fprintf (svg_file, "</g>\n");
-
- print_event_queue_svg ();
-
- fprintf (svg_file, "</svg>\n");
- }
-
string filename;
filename = sprintf ("bentley_%03d.svg", frame_count++);
svg_file = File::open (filename, "w");
- text_y = 200;
- print_sweep_line_svg ();
+ print_sweep_line_svg (svg_file, sweep_line, segments, event_queue, event, current_y);
File::close (svg_file);
event_queue = event_queue.elt->next;
- Previous message: [Commit] nickle ChangeLog, 1.72, 1.73 compile.c, 1.157,
1.158 execute.c, 1.91, 1.92 gram.y, 1.137, 1.138 sched.c, 1.56,
1.57 value.h, 1.106, 1.107
- Next message: [Commit] tess ChangeLog,1.1,1.2 bentley.5c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commit
mailing list