#ifndef hedge_draw_H #define hedge_draw_H /* Copyright (C) 2023 Jorge Stolfi, UNICAMP */ /* Last edited on 2024-06-23 11:54:52 by stolfi */ #include #include #include #include /* DRAWING THE MESH ELEMENTS The {dunit} parameter is a scaling factor for the details (dots, record boxes, aarrowheads, etc.). */ void hedge_draw_edge(epswr_figure_t *eps, hedge_arc_t *a, double ghdash); /* Draws the unoriented edge from {a.org} to {a.dst}, displaced laterally by {(a.bend - b.bend)/2}. Uses the current pen width and color. At least one of {a.org.show} and {a.dst.show} must be true. If either one is false, that half of the edge is omitted. If {a} is not a ghost edge (that is, if {a.left != b.left}) the edge is always drawn solid. If it is a ghost edge, it is omitted if {ghdash < 0}, drawn solid if {ghdash = 0}, and drawn dashed with dash length {ghdash} if {ghdash > 0}. In any case, the current pen color and pen width are used. */ void hedge_draw_arc_arrowhead(epswr_figure_t *eps, hedge_arc_t *a, double tim, double dunit); /* Draws an arrowhead on the edge {a}, about {tim} of the way from {a.org} to {a.dst}. Unsets the dash pattern (lines will be solid). */ void hedge_draw_vert(epswr_figure_t *eps, hedge_vert_t *v, double dunit); /* Draws the vertex {v} as a dot at {v.pos}. The drawing is suppressed if {v.show} is false. */ void hedge_draw_face_dot(epswr_figure_t *eps, hedge_face_t *f, double dunit); /* Draws a dot at the position {f.ctr}. The drawing is suppressed if {f.show} is false. */ void hedge_fill_face(epswr_figure_t *eps, hedge_face_t *f); /* Fills the face {f} with the current fill color. The command is ignored if {f.show} is false. */ /* DRAWING THE DATA STRUCTURE */ void hedge_draw_arc_record(epswr_figure_t *eps, hedge_arc_t *a, double dunit); /* Draws the box representing the {hedge_arc_t} record {a} (but not {a.twin}). The drawing is suppressed if {a.org.show} is false. */ void hedge_draw_vert_record(epswr_figure_t *eps, hedge_vert_t *v, double dunit); /* Draws the record of vertex {v}, as a circle with center {v.pos}. The drawing is suppressed if {v.show} is false. */ void hedge_draw_face_record(epswr_figure_t *eps, hedge_face_t *f, double dunit); /* Draws the record of face {f}, as a circle with center {f.ctr}. The drawing is suppressed if {f.show} is false. */ /* DATA STRUCTURE LINKS */ void hedge_draw_struct_link(epswr_figure_t *eps, r2_t *p, r2_t *q, double bend, double dunit); /* Draws a link of the hedge structure as a line from {p} to {q} that bends {bend} mm to the left of the line from {p} to {q}. The link starts with with a dot and has an arrowhead about ??? of the way. The link is darwn with the current pen parameters, including dash pattern; but the latter is reset internally to solid to paint the dot and arrowhead. */ void hedge_draw_arc_twin_link(epswr_figure_t *eps, hedge_arc_t *a, double dunit); /* Draws the link {a.twin} using {hedge_draw_struct_link}. */ void hedge_draw_arc_next_link(epswr_figure_t *eps, hedge_arc_t *a, double dunit); /* Draws the link {a.next} using {hedge_draw_struct_link}. */ void hedge_draw_arc_org_link(epswr_figure_t *eps, hedge_arc_t *a, double dunit); /* Draws the link {a.org} using {hedge_draw_struct_link}. */ void hedge_draw_arc_left_link(epswr_figure_t *eps, hedge_arc_t *a, double dunit); /* Draws the link {a.left} using {hedge_draw_struct_link}. */ void hedge_draw_vert_out_link(epswr_figure_t *eps, hedge_vert_t *v, double dunit); /* Draws the link {v.out} using {hedge_draw_struct_link}. */ void hedge_draw_face_side_link(epswr_figure_t *eps, hedge_face_t *f, double dunit); /* Draws the link {f.side} using {hedge_draw_struct_link}. */ /* LABELING THINGS */ void hedge_draw_arc_label ( epswr_figure_t *eps, hedge_arc_t *a, double tim, char *lab, double hAlign, double vAlign, double du, double dv ); /* Draws the label {lab} of an arc {a}, near the position {tim}. The ref point of the text will be displaced by {(du,dv)} from that point. The coordinates of {dsp} are interpreted in the system whose axes are the direction tangent to the edge and the left-pointing normal. */ void hedge_draw_vert_label ( epswr_figure_t *eps, hedge_vert_t *v, char *lab, double hAlign, double vAlign, double dx, double dy ); /* Draws the label {lab} of a vertex {v}, with the text's ref point displaced by {(dx,dy)} from its position. */ void hedge_draw_face_label ( epswr_figure_t *eps, hedge_face_t *f, char *lab, double hAlign, double vAlign, double dx, double dy ); /* Draws the label {lab} of a face {f}, with teh reference point displaced by {(dx,dy)} from its nominal center. */ void hedge_draw_smudge ( epswr_figure_t *eps, r3_t *ctr, double dxmin, double dxmax, double dymin, double dymax ); /* Fills with the current fill color the rectangle {[dxmin _ dxmax]×[dymin _ dymax]} relative to the point {ctr}. Ignores the {Z} coordinate of {ctr}. */ /* GENERIC DRAWING TOOLS */ void hedge_draw_label(epswr_figure_t *eps, r2_t *p, char *lab, double hAlign, double vAlign); /* Draws the label {lab} with the relative point {hAlign,vAlign} of the text at the position {p}. */ void hedge_draw_arrow ( epswr_figure_t *eps, r2_t *p, r2_t *q, double bend, double rad, double tim, double ahlwid, double ahrwid, double ahlen ); /* Draws an arrow from {p} to {q} that bends {bend} mm to the left of the line from {p} to {q}. The link starts with with a dot of radius {rad} and has an arrowhead of left and right width {ahlwid,ahrwid} and length {ahlen} about {tim} of the way. The link is drawn with the current dash pattern, but the pattern is reset internally to solid in order to draw the dot and arrowhead. */ /* MESH DRAWING */ void hedge_draw_get_plot_bounds(hedge_t *H, double *xmin_P, double *xmax_P, double *ymin_P, double *ymax_P); /* Gets the min and max vertex coordinates of the half-edge structure {H}. */ void hedge_draw_mesh(epswr_figure_t *eps, hedge_t *H, bool_t ghosts); /* Draws the mesh described by the half-edge structure {H} on {eps}, with detail scaling {H->dunit}. If {ghosts} is true, ghost edges are drawn dashed, else they are omitted. Non-ghost edges are drawn solid. If both endpoints are invisible, does not draw the edge. If only one endpoint is invisible, draws half of it. */ void hedge_draw_vert_ids(epswr_figure_t *eps, hedge_t *H, double rad); /* Draws each vertex as a circe of radius {rad} (millimeters) and writes the vertex ID inside. Note: changes pen settings, fill color, abd label font. */ void hedge_draw_edge_ids(epswr_figure_t *eps, hedge_t *H, double tim, double dsp, double hsz, double vsz); /* Draws near each base arc {e} a rectangle of width {hsz} and height {vsz} (millimeters) and writes the edge ID (not arc id) inside. The center of the box will be at {tim} of the way along {e}, diplaced an additional {dsp} mm to the left of the edge. Note: changes pen settings, fill color, abd label font. */ #endif