124# include <tclap/CmdLine.h>
372# define INFIXPOS(p) ((p)->getCount())
373# define LEVEL(p) ((p)->get_level())
374# define X(p) ((p)->get_x())
375# define Y(p) ((p)->get_y())
376# define XOFFSET(p) ((p)->get_xoffset())
377# define YOFFSET(p) ((p)->get_yoffset())
378# define TRIANGLEH(p) ((p)->get_triangle_height())
379# define RECTANGLEH(p) ((p)->get_rectangle_height())
380# define EXTERNAL(p) ((p)->get_external_node())
381# define ISEXTERNAL(p) ((p)->is_external())
382# define ISTRIANGLE(p) ((p)->is_triangle())
383# define DSTRING(p) ((p)->get_distance_string())
384# define LDISTANCE(p) ((p)->get_line_distance_data())
385# define ISDISTANCE(p) ((p)->get_line_distance_data().str.empty())
386# define ISRECTANGLE(p) ((p)->is_rectangle())
387# define STRING(p) ((p)->get_key_string())
388# define AUX(p) ((p)->get_aux_string())
389# define SHADOW(p) ((p)->get_shadow())
390# define WITHOUT(p) ((p)->get_without_node())
391# define SCRATCH(p) ((p)->get_scratch())
392# define WITHARC(p) ((p)->get_with_arc())
393# define DASHLLINK(p) ((p)->get_dash_llink())
394# define DASHRLINK(p) ((p)->get_dash_rlink())
395# define TAGLIST(p) ((p)->get_tag_list())
396# define ARCLIST(p) ((p)->get_arc_list())
397# define THREADLIST(p) ((p)->get_thread_list())
398# define SUCC(p) ((p)->get_succ())
399# define PREV(p) ((p)->get_prev())
507# define TERMINATE(n) (save_parameters(), exit(n))
509# define DYNARRAY_APPEND(array, item) (array[array.size()] = item)
511using namespace Aleph;
524 if (token_type < NORTH or token_type >
SOUTH_WEST)
574 PRINT_ERROR(
"Node position greater than number of nodes in KEY option");
646 PRINT_ERROR(
"Invalid orientation in DISTANCE option");
660 char *start_address = buffer;
667 catch (
const std::out_of_range &) {
return END_FILE; }
669 if (current_char == EOF)
672 if (not isprint(current_char))
675 if (isdigit(current_char) or current_char ==
'-')
677 if (current_char ==
'-')
681 if (not isdigit(current_char))
689 while (current_char != EOF
and isdigit(current_char));
695 if (current_char ==
'\"')
699 if (current_char ==
'\"')
704 if (current_char == EOF or current_char ==
'\n')
710 if (current_char ==
'%')
722 while (isgraph(current_char));
726 if (strcasecmp(buffer,
"START-PREFIX") == 0 or
727 strcasecmp(buffer,
"PREFIX") == 0 or
728 strcasecmp(buffer,
"START-PREORDER") == 0 or
729 strcasecmp(buffer,
"PREORDER") == 0)
732 if (strcasecmp(buffer,
"START-INFIX") == 0 or
733 strcasecmp(buffer,
"START-INORDER") == 0 or
734 strcasecmp(buffer,
"INORDER") == 0 or
735 strcasecmp(buffer,
"INFIX") == 0
739 if (strcasecmp(buffer,
"START-KEY") == 0)
742 if (strcasecmp(buffer,
"START-AUX") == 0)
745 if (strcasecmp(buffer,
"START-SHADOW") == 0 or
746 strcasecmp(buffer,
"SHADOW") == 0)
749 if (strcasecmp(buffer,
"WITHOUT-NODE") == 0)
752 if (strcasecmp(buffer,
"TAG") == 0)
755 if (strcasecmp(buffer,
"ARC") == 0)
758 if (strcasecmp(buffer,
"DASHED-ARC") == 0)
761 if (strcasecmp(buffer,
"SCRATCH") == 0)
764 if (strcasecmp(buffer,
"SPLIT") == 0)
767 if (strcasecmp(buffer,
"KEY") == 0)
770 if (strcasecmp(buffer,
"XOFFSET") == 0)
773 if (strcasecmp(buffer,
"YOFFSET") == 0)
776 if (strcasecmp(buffer,
"TRIANGLE") == 0)
779 if (strcasecmp(buffer,
"TRIANGLEH") == 0)
782 if (strcasecmp(buffer,
"WITHOUT-ARC") == 0)
785 if (strcasecmp(buffer,
"RECTANGLE") == 0)
788 if (strcasecmp(buffer,
"PARRECTANGLE") == 0)
791 if (strcasecmp(buffer,
"DISTANCE") == 0)
794 if (strcasecmp(buffer,
"THREAD") == 0)
797 if (strcasecmp(buffer,
"L") == 0)
800 if (strcasecmp(buffer,
"R") == 0)
803 if (strcasecmp(buffer,
"N") == 0)
806 if (strcasecmp(buffer,
"S") == 0)
809 if (strcasecmp(buffer,
"E") == 0)
812 if (strcasecmp(buffer,
"W") == 0)
815 if (strcasecmp(buffer,
"NE") == 0)
818 if (strcasecmp(buffer,
"NW") == 0)
821 if (strcasecmp(buffer,
"SE") == 0)
824 if (strcasecmp(buffer,
"SW") == 0)
862 const int found_index =
865 if (found_index >= 0)
887 if (found_index >= 0)
890 low_index = found_index + 1;
892 while (found_index >= 0);
904 while (
root !=
nullptr)
934 if (found_index >= 0)
943 low_index = found_index + 1;
945 while (found_index >= 0);
953 if (found_index >= 0)
962 low_index = found_index + 1;
964 while (found_index >= 0);
998 const int found_index =
1001 if (found_index >= 0)
1007 const int found_index =
1010 if (found_index >= 0)
1016 const int found_index =
1019 if (found_index >= 0)
1030 const int found_index =
1033 if (found_index >= 0)
1044 const int found_index =
1047 if (found_index >= 0)
1059 const int found_index =
1062 if (found_index >= 0)
1066 PRINT_ERROR(
"Distance line on %d th node has a left branch",
1069 PRINT_ERROR(
"Distance line on %d th node has a right branch",
1078 const int found_index =
1081 if (found_index >= 0)
1093 X(p) =
hr + position *
w;
1095 Y(p) = level *
h +
vr;
1103 while (
RLINK(prev) !=
nullptr)
1113 while (
LLINK(succ) !=
nullptr)
1126 ifstream input_stream(file_name, ios::in);
1128 if (not input_stream)
1149 switch (parsing_state)
1157 default:
PRINT_ERROR(
"Found an string in invalid mode (%ld)",
1163 switch (parsing_state)
1188 default:
AH_ERROR(
"Found an integer in invalid mode (%ld)",
1198 parsing_state =
INFIX;
1202 parsing_state =
KEYS;
1210 parsing_state =
AUX;
1282 PRINT_ERROR(
"Internal error: invalid token type (%ld)",
1287 catch (exception & e)
1299 tag_itor.
has_curr(); tag_itor.next())
1301 if (
const Tag_Data & tag_data = tag_itor.get_curr();
1302 tag_data.tag_option ==
NORTH or
1319 tag_itor.
has_curr(); tag_itor.next())
1321 if (
const Tag_Data & tag_data = tag_itor.get_curr();
1322 tag_data.tag_option ==
EAST or
1339 tag_itor.
has_curr(); tag_itor.next())
1341 if (
const Tag_Data & tag_data = tag_itor.get_curr();
1342 tag_data.tag_option ==
WEST or
1352 const size_t & level)
1357 for (
auto it = deepest_nodes.
get_it(); it.has_curr(); it.next())
1365 tag_itor.
has_curr(); tag_itor.next())
1407 const float max_triangle_height =
1410 v_size += max_triangle_height;
1444 root = preorder_to_bst<EepicNode<long>>
1449 AH_ERROR(
"Sizes of traversals differ");
1460 AH_ERROR(
"Number of keys is different from tree size");
1470 AH_ERROR(
"Number of auxiliary keys is different from tree size");
1591 catch (exception & e)
1604 <<
"% This LaTeX picture is a binary tree automatically" << endl
1605 <<
"% generated by btreepic program" << endl
1607 <<
"% Copyright (C) 2007, 2006, 2005, 2004, 2003, 2002" << endl
1608 <<
"% UNIVERSITY of LOS ANDES (ULA)" << endl
1609 <<
"% Merida - REPUBLICAf1727 BOLIVARIANA DE VENEZUELA" << endl
1610 <<
"% Center of Studies in Microelectronics & Distributed Systems"
1611 <<
" (CEMISID)" << endl
1612 <<
"% ULA Computer Science Department" << endl
1614 <<
"% Leandro Leon - lrleon@ula.ve" << endl
1616 <<
"% You must use curves, epic and eepic latex packages" << endl
1617 <<
"% in your LaTeX application" << endl
1619 <<
"% curves Copyright by I.L. Maclaine-cross" << endl
1620 <<
"% epic Copyright by Sunil Podar" << endl
1621 <<
"% eepic Copyright by Conrad Kwok" << endl
1622 <<
"% LaTeX is a collection of TeX macros created by Leslie Lamport"
1624 <<
"% TeX was created by Donald Knuth" << endl
1626 <<
"% command line: " << endl
1632 <<
"% Creation date: " << ctime(&t) << endl
1636 output <<
"%%%%%%%%%%%%%%%% LATEX Header generated with -a option" << endl
1637 <<
"\\documentclass[11pt]{article}" << endl
1638 << (
landscape ?
"\\usepackage[landscape]{geometry}" :
"") << endl
1641 <<
"\\usepackage{epic}" << endl
1642 <<
"\\usepackage{eepic}" << endl
1643 <<
"\\usepackage{amssymb}" << endl
1645 <<
"\\begin{document}" << endl
1646 <<
"\\begin{center}" << endl;
1649 <<
"% Resolution is " <<
resolution <<
"mm" << endl
1650 <<
"% Change resolution with -l option" << endl
1651 <<
"\\setlength{\\unitlength}{" <<
resolution <<
"mm}" << endl
1652 <<
"\\filltype{" <<
fill_type <<
"}" << endl
1655 <<
"\\begin{picture}(" <<
h_size <<
"," <<
v_size <<
")"
1663 <<
"\\end{picture}" << endl;
1667 <<
"\\end{center}" << endl
1668 <<
"\\end{document}" << endl;
1676 long double x =
X(p);
1677 long double y =
Y(p);
1682 <<
"% Node at infix position " <<
INFIXPOS(p)
1683 <<
" with key " <<
STRING(p);
1688 <<
"% External node" << endl
1689 <<
"\\path(" << x -
hr <<
"," <<
YPIC(
y) <<
")("
1690 << x +
hr <<
"," <<
YPIC(
y) <<
")" << endl;
1693 <<
"% Triangle" << endl
1694 <<
"\\path(" << x <<
"," <<
YPIC(
y) <<
")("
1697 << x <<
"," <<
YPIC(
y) <<
")";
1700 long double x1 =
X(p) -
hr;
1701 long double x2 =
X(p) +
hr;
1710 <<
"% Partial Rectangle" << endl
1711 <<
"\\path(" << x1 <<
"," <<
YPIC(
y1) <<
")("
1712 << x2 <<
"," <<
YPIC(
y1) <<
")("
1713 << x2 <<
"," <<
YPIC(y2) <<
")("
1714 << x1 <<
"," <<
YPIC(y2) <<
")("
1715 << x1 <<
"," <<
YPIC(
y1) <<
")";
1721 <<
"\\dashline{" <<
dash_len <<
"}("
1722 << x1 <<
"," <<
YPIC(
y1) <<
")("
1723 << x1 <<
"," <<
YPIC(y2) <<
")("
1724 << x2 <<
"," <<
YPIC(y2) <<
")("
1725 << x2 <<
"," <<
YPIC(
y1) <<
")" << endl
1726 <<
"\\path(" << x1 <<
"," <<
YPIC(
y1) <<
")("
1727 << x2 <<
"," <<
YPIC(y2) <<
")" << endl
1728 <<
"\\path(" << x2 <<
"," <<
YPIC(
y1) <<
")("
1729 << x1 <<
"," <<
YPIC(y2) <<
")";
1737 <<
"% Rectangle" << endl
1738 <<
"\\path(" << x1 <<
"," <<
YPIC(
y1) <<
")("
1739 << x2 <<
"," <<
YPIC(
y1) <<
")("
1740 << x2 <<
"," <<
YPIC(y2) <<
")("
1741 << x1 <<
"," <<
YPIC(y2) <<
")("
1742 << x1 <<
"," <<
YPIC(
y1) <<
")";
1747 <<
"% Elippse" << endl
1748 <<
"\\put(" << x <<
"," <<
YPIC(
y) <<
")"
1749 << (
SHADOW(p) ?
"{\\ellipse*{" :
"{\\ellipse{") <<
hd
1750 <<
"}{" <<
vd <<
"}}";
1753 <<
"% Elippse" << endl
1754 <<
"\\put(" << x <<
"," <<
YPIC(
y) <<
"){\\ellipse*{" <<
hd
1755 <<
"}{" <<
vd <<
"}}";
1761 <<
"% Distance line";
1765 long double line_len = 0;
1776 xd = ldd.
is_left() ? -(
w / 2 + xof) : (
w / 2 + xof);
1782 long double xl = x + xd;
1784 long double dy =
sin_45 * gap_len;
1785 long double yf1 =
y + line_len;
1786 long double yf2 =
y + yof + 2 * line_len;
1788 <<
"\\path(" << xl <<
"," <<
YPIC(
y - yplus) <<
")("
1789 << xl <<
"," <<
YPIC(
y + line_len) <<
")" << endl
1790 <<
"\\path(" << xl <<
"," <<
YPIC(yf1 + yof) <<
")("
1791 << xl <<
"," <<
YPIC(yf2 + yplus) <<
")" << endl
1792 <<
"\\path(" << xl - gap_len / 2 <<
"," <<
YPIC(
y) <<
")("
1793 << xl + gap_len / 2 <<
"," <<
YPIC(
y) <<
")" << endl
1794 <<
"\\path(" << xl - gap_len / 2 <<
"," <<
YPIC(yf2 + yplus)
1796 <<
"\\path(" << xl - gap_len / 2 <<
"," <<
YPIC(yf2) <<
")("
1797 << xl + gap_len / 2 <<
"," <<
YPIC(yf2) <<
")" << endl
1798 <<
"\\path(" << xl - gap_len / 2 <<
"," <<
YPIC(
y + dy) <<
")("
1799 << xl + gap_len / 2 <<
"," <<
YPIC(
y - dy) <<
")" << endl
1800 <<
"\\path(" << xl - gap_len / 2 <<
"," <<
YPIC(yf2 + dy) <<
")("
1801 << xl + gap_len / 2 <<
"," <<
YPIC(yf2 - dy) <<
")";
1804 long double str_offset = ldd.
is_left() ?
1809 "String of line distance", ldd.
str);
1818 long double dy_rectangle = 0;
1845 <<
"\\path(" << x -
hr <<
"," <<
YPIC(
y) <<
")("
1846 << x +
hr <<
"," <<
YPIC(
y) <<
")";
1852 "Auxiliar string= " +
AUX(p),
AUX(p));
1857 if (not
TAGLIST(p).is_empty())
1870 tag_data = itor.get_curr();
1875 comment =
"North tag: ";
1876 tx = x - x_font_size / 2 + tag_data.
x_offset;
1881 comment =
"South tag: ";
1882 tx = x - x_font_size / 2 + tag_data.
x_offset;
1883 ty =
y +
r + y_font_size / 2 + tag_data.
y_offset;
1886 comment =
"East tag: ";
1888 ty =
y + y_font_size / 2 + tag_data.
y_offset;
1891 comment =
"West tag: ";
1892 tx = x -
r - x_font_size + tag_data.
x_offset -
1894 ty =
y + y_font_size / 2 + tag_data.
y_offset;
1897 comment =
"Northeast tag: ";
1898 tx = x + dr + x_font_size / 2 + tag_data.
x_offset;
1899 ty =
y - dr + y_font_size / 2 + tag_data.
y_offset;
1902 comment =
"Northwest tag: ";
1903 tx = x - dr - x_font_size / 2 + tag_data.
x_offset -
1905 ty =
y - dr + y_font_size / 2 + tag_data.
y_offset;
1908 comment =
"Southeast tag: ";
1909 tx = x + dr + x_font_size / 2 + tag_data.
x_offset;
1910 ty =
y + dr + y_font_size / 2 + tag_data.
y_offset;
1913 comment =
"Southwest tag: ";
1914 tx = x - dr - x_font_size / 2 + tag_data.
x_offset -
1916 ty =
y + dr + y_font_size / 2 + tag_data.
y_offset;
1919 PRINT_ERROR(
"Internal error: unexpected tag option");
1930 <<
"% Scratching" << endl
1931 <<
"\\path(" << x - dr <<
"," <<
YPIC(
y - dr) <<
")"
1932 <<
"(" << x + dr <<
"," <<
YPIC(
y + dr) <<
")"
1933 <<
"\\path(" << x + dr <<
"," <<
YPIC(
y - dr) <<
")"
1934 <<
"(" << x - dr <<
"," <<
YPIC(
y + dr) <<
")";
1944 Arc_Desc arc_desc = itor.get_curr();
1962 long double src_x, src_y, tgt_x, tgt_y;
1996 <<
"% Additional arc to infix node "
2008 long double lx =
X(
l);
2009 long double ly =
Y(
l);
2013 <<
"% Arc to left infix node " <<
INFIXPOS(
l)
2014 <<
" with key " <<
STRING(
l) << endl;
2025 long double px =
X(prev);
2026 long double py =
Y(prev);
2030 <<
"% Thread to predecessor infix node " <<
INFIXPOS(prev)
2031 <<
" with key " <<
STRING(prev) << endl;
2033 output <<
"\\curve(" << x - dx <<
"," <<
YPIC(
y + dy) <<
","
2034 << px + dx <<
"," <<
YPIC(
y +
h) <<
","
2035 << px + dx <<
"," <<
YPIC(py + dy) <<
")";
2037 output <<
"\\spline(" << x - dx <<
"," <<
YPIC(
y + dy) <<
")("
2038 << px <<
"," <<
YPIC(
y +
h) <<
")("
2039 << px + dx <<
"," <<
YPIC(py + dy) <<
")";
2045 long double rx =
X(
r);
2046 long double ry =
Y(
r);
2050 <<
"% Arc to right infix node " <<
INFIXPOS(
r)
2051 <<
" with key " <<
STRING(
r) << endl;
2062 long double px =
X(succ);
2063 long double py =
Y(succ);
2067 <<
"% Thread to successor infix node " <<
INFIXPOS(succ)
2068 <<
" with key " <<
STRING(succ) << endl;
2070 output <<
"\\curve(" << x + dx <<
"," <<
YPIC(
y + dy) <<
","
2071 << px - dx <<
"," <<
YPIC(
y +
h) <<
","
2072 << px - dx <<
"," <<
YPIC(py + dy) <<
")";
2074 output <<
"\\spline(" << x + dx <<
"," <<
YPIC(
y + dy) <<
")("
2075 << px <<
"," <<
YPIC(
y +
h) <<
")("
2076 << px - dx <<
"," <<
YPIC(py + dy) <<
")";
2087 PRINT_ERROR(
"Number of split points is greater than total of nodes");
2093 PRINT_ERROR(
"Split position (%d) out of range", pos);
2097 const long double x =
X(src);
2098 const long double line_space = 1.0 /
resolution;
2099 const long double line_len =
v_size - 4 * line_space +
vd / 2.0;
2103 <<
"% Split line at node " <<
INFIXPOS(src)
2104 <<
" with key " <<
STRING(src) << endl
2105 <<
"\\dashline{" <<
dash_len <<
"}(" << x <<
","
2106 <<
YPIC(line_space) <<
")"
2107 <<
"(" << x <<
"," <<
YPIC(line_space + line_len) <<
")";
2111 if (
const int upper_len = split_data.
upper_string.size(); upper_len > 0)
2113 const long double upper_size =
2115 const long double dx = upper_size / 2.0;
2117 <<
"\\put(" << x - dx <<
"," <<
YPIC(line_space) <<
")"
2122 if (
const int lower_len = split_data.
lower_string.size(); lower_len > 0)
2124 const long double lower_size =
2126 const long double dx = lower_size / 2.0;
2129 <<
"\\put(" << x - dx <<
","
2139 "ALEPH drawer for binary trees\n"
2140 "Copyright (C) 2007 UNIVERSITY of LOS ANDES (ULA)\n"
2141 "Merida - REPUBLICA BOLIVARIANA DE VENEZUELA\n"
2142 "Center of Studies in Microelectronics & Distributed Systems (CEMISID)\n"
2143 "ULA Computer Science Department\n"
2144 "This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
2145 "or FITNESS FOR A PARTICULAR PURPOSE\n"
2150 "ALEPH drawer for binary trees\n"
2151 "Copyright (C) 2007, 2006, 2005, 2004, 2003, 2002 University of Los Andes (ULA)\n"
2152 "Merida - REPUBLICA BOLIVARIANA DE VENEZUELA\n"
2153 "Center of Studies in Microelectronics & Distributed Systems (CEMISID)\n"
2154 "ULA Computer Science Department\n"
2155 "This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
2156 "or FITNESS FOR A PARTICULAR PURPOSE\n"
2160 "Aleph drawer for binary trees. License & Copyright Note\n"
2161 "Copyright (C) 2007, 2006, 2005, 2004, 2003, 2002\n"
2162 "UNIVERSITY of LOS ANDES (ULA)\n"
2163 "Merida - VENEZUELA\n"
2164 "Center of Studies in Microelectronics & Distributed Systems (CEMISID)\n"
2165 "ULA Computer Science Department\n"
2166 "This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
2167 "or FITNESS FOR A PARTICULAR PURPOSE\n"
2169 " PERMISSION TO USE, COPY, MODIFY AND DISTRIBUTE THIS SOFTWARE AND ITS \n"
2170 " DOCUMENTATION IS HEREBY GRANTED, PROVIDED THAT BOTH THE COPYRIGHT \n"
2171 " NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES OF THE \n"
2172 " SOFTWARE, DERIVATIVE WORKS OR MODIFIED VERSIONS, AND ANY PORTIONS \n"
2173 " THEREOF, AND THAT BOTH NOTICES APPEAR IN SUPPORTING DOCUMENTATION. \n"
2175 " This program is distributed in the hope that it will be useful,\n"
2176 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
2177 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n"
2179 " ULA requests users of this software to return to \n"
2180 " Proyecto Aleph - CEMISID Software\n"
2181 " Nucleo Universitario La Hechicera. Ed Ingenieria\n"
2182 " 3er piso, ala Este \n"
2183 " Universidad de Los Andes \n"
2184 " Merida 5101 - REPUBLICA BOLIVARIANA DE VENEZUELA \n"
2186 " or to lrleon@ula.ve \n"
2188 " any improvements or extensions that they make and grant Universidad \n"
2189 " de Los Andes (ULA) the full rights to redistribute these changes. \n"
2191 " This program was granted by: \n"
2192 " - Consejo de Desarrollo Cientifico, Humanistico, Tecnico de la ULA\n"
2200 <<
"Horizontal radius -x = " <<
hr << endl
2201 <<
"Vertical radius -y = " <<
vr << endl
2202 <<
"Horizontal diameter = " <<
hd << endl
2203 <<
"Vertical diameter = " <<
vd << endl
2204 <<
"Horizontal separation -w = " <<
w << endl
2205 <<
"Vertical separation -h = " <<
h << endl
2206 <<
"Resolution in mm -l = " <<
resolution << endl
2207 <<
"Horizontal size -z = " <<
h_size << endl
2208 <<
"Vertical size -u = " <<
v_size << endl
2209 <<
"Horizontal offset for key -X = " <<
x_offset << endl
2210 <<
"Vertical offset for key -Y = " <<
y_offset << endl
2211 <<
"Horizontal offset for aux tag -W = " <<
x_aux_offset << endl
2212 <<
"Vertical offset for aux tag -H = " <<
y_aux_offset << endl
2222 "btreepic -- Binary tree visualizer (LaTeX/eepic output)\n"
2224 "Reads a textual binary tree description (.Tree file) and emits LaTeX\n"
2225 "code using eepic drawing primitives, suitable for inclusion in\n"
2226 "publication-quality documents.\n"
2229 " btreepic -f <input.Tree> [-o <output.eepic>] [options]\n"
2230 " btreepic -i <input.Tree> [-o <output.eepic>] [options]\n"
2233 " -f, --file <file> Input .Tree file\n"
2234 " -i, --input-file <file> Input .Tree file (alias for -f)\n"
2237 " -o, --output <file> Output file (default: input name + .eepic)\n"
2238 " -r, --radius <double> Circle fit radius\n"
2239 " -w, --width <double> Horizontal node separation\n"
2240 " -h, --height <double> Vertical node separation\n"
2241 " -k, --with-key Print node keys\n"
2242 " -K, --tiny-keys Print node keys in tiny font (output: .eepicaux)\n"
2243 " -a, --latex Wrap output in a full LaTeX header\n"
2244 " -p, --landscape LaTeX landscape mode (implies -a)\n"
2245 " -t, --fit Fit tree in a rectangle\n"
2246 " -A, --arrows Draw arcs with arrows\n"
2247 " -D, --threaded Draw threaded pointers as dashed lines\n"
2248 " -e, --external-nodes Draw external (null) nodes\n"
2249 " -F, --vertical-flip Flip tree along the y axis\n"
2250 " -R, --print Print current parameters and exit\n"
2251 " -V, --version Print version and exit\n"
2252 " -C, --license Print license and exit\n"
2253 " --help Print full help and exit\n"
2256 " btreepic -f mytree.Tree -o mytree.eepic -k -a\n"
2258 "Run 'btreepic --help' for the complete list of options.\n";
2270 TCLAP::ValueArg<double> radiusArg(
"r",
"radius",
"fit radius for circles",
false, 0.0,
"double");
2271 TCLAP::ValueArg<double> widthArg(
"w",
"width",
"horizontal separation",
false,
w,
"double");
2272 TCLAP::ValueArg<double> heightArg(
"h",
"height",
"vertical separation",
false,
h,
"double");
2273 TCLAP::ValueArg<double> hRadiusArg(
"x",
"h-radius",
"horizontal radius (ellipse)",
false,
hr,
"double");
2274 TCLAP::ValueArg<double> vRadiusArg(
"y",
"v-radius",
"vertical radius (ellipse)",
false,
vr,
"double");
2275 TCLAP::ValueArg<double> resolArg(
"l",
"resol",
"resolution in mm",
false,
resolution,
"double");
2276 TCLAP::SwitchArg latexArg(
"a",
"latex",
"add latex header",
false);
2277 TCLAP::SwitchArg landscapeArg(
"p",
"landscape",
"latex landscape mode",
false);
2278 TCLAP::SwitchArg withKeyArg(
"k",
"with-key",
"printing keys",
false);
2279 TCLAP::SwitchArg tinyKeysArg(
"K",
"tiny-keys",
"printing keys with tiny font",
false);
2280 TCLAP::SwitchArg fitArg(
"t",
"fit",
"fit in rectangle",
false);
2281 TCLAP::ValueArg<double> horizontalArg(
"z",
"horizontal",
"specify horizontal width for fitting",
false,
h_size,
2283 TCLAP::ValueArg<double> verticalArg(
"u",
"vertical",
"specify vertical height for fitting",
false,
v_size,
2285 TCLAP::SwitchArg minRadiusArg(
"n",
"min-radius",
"radious is minimum",
false);
2286 TCLAP::SwitchArg withoutNodeArg(
"N",
"without-node",
"no draw node; only arcs",
false);
2287 TCLAP::ValueArg<double> keyXOffsetArg(
"X",
"key-x-offset",
"horizontal offset for keys",
false,
x_offset,
2289 TCLAP::ValueArg<double> keyYOffsetArg(
"Y",
"key-y-offset",
"vertical offset for keys",
false,
y_offset,
"double");
2290 TCLAP::ValueArg<double> auxYOffsetArg(
"H",
"aux-y-offset",
"vertical offset for auxiliary string",
false,
2292 TCLAP::ValueArg<double> auxXOffsetArg(
"W",
"aux-x-offset",
"horizontal offset for auxiliary string",
false,
2294 TCLAP::ValueArg<string> inputFileArg(
"i",
"input-file",
"input file",
false,
"",
"string");
2295 TCLAP::ValueArg<string> inputFileAliasArg(
"f",
"file",
"input file (alias)",
false,
"",
"string");
2296 TCLAP::ValueArg<string> outputFileArg(
"o",
"output",
"output file",
false,
"",
"string");
2297 TCLAP::SwitchArg licenseArg(
"C",
"license",
"print license",
false);
2298 TCLAP::ValueArg<double> xPictureOffsetArg(
"O",
"x-picture-offset",
"horizontal global picture offset",
false,
2300 TCLAP::ValueArg<double> yPictureOffsetArg(
"P",
"y-picture-offset",
"vertical global picture offset",
false,
2302 TCLAP::SwitchArg printArg(
"R",
"print",
"print current parameters",
false);
2303 TCLAP::SwitchArg verboseArg(
"v",
"verbose",
"verbose mode",
false);
2304 TCLAP::SwitchArg unsilentArg(
"s",
"unsilent",
"unsilent mode - print tokens",
false);
2305 TCLAP::SwitchArg versionArg(
"V",
"version",
"Print version information and then exit",
false);
2306 TCLAP::SwitchArg blackFillArg(
"B",
"black-fill",
"Fill black ellipses",
false);
2307 TCLAP::SwitchArg shadeFillArg(
"S",
"shade-fill",
"Fill shade ellipses",
false);
2308 TCLAP::SwitchArg threadedArg(
"D",
"threaded",
"draw dotted threads instead nullptr pointers",
false);
2309 TCLAP::SwitchArg threadedNoDashArg(
"T",
"threaded-no-dash",
"draw contiguous threads instead nullptr pointers",
2311 TCLAP::SwitchArg externalNodesArg(
"e",
"external-nodes",
"draw external nodes",
false);
2312 TCLAP::ValueArg<double> arrowLenArg(
"L",
"arrow-len",
"arrow lenght",
false,
arrow_lenght,
"double");
2313 TCLAP::ValueArg<double> arrowWidthArg(
"I",
"arrow-width",
"arrow width",
false,
arrow_width,
"double");
2314 TCLAP::SwitchArg arrowsArg(
"A",
"arrows",
"draw arcs with arrows",
false);
2315 TCLAP::SwitchArg verticalFlipArg(
"F",
"vertical-flip",
"Flip tree respect y axe",
false);
2316 TCLAP::SwitchArg helpArg(
"",
"help",
"Print this help message",
false);
2321 cmd.add(hRadiusArg);
2322 cmd.add(vRadiusArg);
2325 cmd.add(landscapeArg);
2326 cmd.add(withKeyArg);
2327 cmd.add(tinyKeysArg);
2329 cmd.add(horizontalArg);
2330 cmd.add(verticalArg);
2331 cmd.add(minRadiusArg);
2332 cmd.add(withoutNodeArg);
2333 cmd.add(keyXOffsetArg);
2334 cmd.add(keyYOffsetArg);
2335 cmd.add(auxYOffsetArg);
2336 cmd.add(auxXOffsetArg);
2337 cmd.add(inputFileArg);
2338 cmd.add(inputFileAliasArg);
2339 cmd.add(outputFileArg);
2340 cmd.add(licenseArg);
2341 cmd.add(xPictureOffsetArg);
2342 cmd.add(yPictureOffsetArg);
2344 cmd.add(verboseArg);
2345 cmd.add(unsilentArg);
2346 cmd.add(versionArg);
2347 cmd.add(blackFillArg);
2348 cmd.add(shadeFillArg);
2349 cmd.add(threadedArg);
2350 cmd.add(threadedNoDashArg);
2351 cmd.add(externalNodesArg);
2352 cmd.add(arrowLenArg);
2353 cmd.add(arrowWidthArg);
2355 cmd.add(verticalFlipArg);
2358 cmd.parse(argc, argv);
2360 if (helpArg.getValue())
2362 cmd.getOutput()->usage(
cmd);
2366 if (versionArg.getValue())
2372 if (licenseArg.getValue())
2378 if (radiusArg.isSet())
2380 hr =
vr = radiusArg.getValue();
2383 if (widthArg.isSet())
w = widthArg.getValue();
2384 if (heightArg.isSet())
h = heightArg.getValue();
2385 if (hRadiusArg.isSet())
2387 hr = hRadiusArg.getValue();
2390 if (vRadiusArg.isSet())
2392 vr = vRadiusArg.getValue();
2395 if (resolArg.isSet())
2398 if (
resolution > 10) cout <<
"Warning: resolution too big" << endl;
2401 if (landscapeArg.getValue())
2407 if (tinyKeysArg.getValue())
tiny_keys =
true;
2408 if (fitArg.getValue())
fit_mode =
true;
2409 if (horizontalArg.isSet())
h_size = horizontalArg.getValue();
2410 if (verticalArg.isSet())
v_size = verticalArg.getValue();
2411 if (minRadiusArg.getValue())
2416 if (withoutNodeArg.getValue())
draw_nodes =
false;
2417 if (keyXOffsetArg.isSet())
x_offset = keyXOffsetArg.getValue();
2418 if (keyYOffsetArg.isSet())
y_offset = keyYOffsetArg.getValue();
2419 if (auxYOffsetArg.isSet())
y_aux_offset = auxYOffsetArg.getValue();
2420 if (auxXOffsetArg.isSet())
x_aux_offset = auxXOffsetArg.getValue();
2423 else if (inputFileAliasArg.isSet())
input_file_name = inputFileAliasArg.getValue();
2427 if (xPictureOffsetArg.isSet())
x_picture_offset = xPictureOffsetArg.getValue();
2428 if (yPictureOffsetArg.isSet())
y_picture_offset = yPictureOffsetArg.getValue();
2430 if (printArg.getValue())
2439 if (blackFillArg.getValue())
fill_type =
"black";
2440 if (shadeFillArg.getValue())
fill_type =
"shade";
2447 if (arrowLenArg.isSet())
2452 if (arrowWidthArg.isSet())
2459 if (verticalFlipArg.getValue())
flip_y =
true;
2461 catch (TCLAP::ArgException & e)
2463 cerr <<
"error: " << e.error() <<
" for arg " << e.argId() << endl;
#define AH_ERROR(...)
Print an error message (always enabled).
Core header for the Aleph-w library.
WeightedDigraph::Node Node
DynArray< Thread_Data > target_thread_dynarray
void assign_pos_and_level(EepicNode< long > *p, const int level, const int position)
void thread_tree(EepicNode< long > *p)
const char * parameters_file_name
void assign_rectangle(EepicNode< long > *p, int, const int position)
void assign_tag(EepicNode< long > *p, int, const int position)
bool west_offset(EepicNode< long > *root)
Token_Type get_token(ifstream &input_stream)
Node * select(Node *root, const int &i)
void load_tag_option(ifstream &input_stream)
void file_to_dynarrays(const char *file_name)
DynArray< long > key_pos_dynarray
DynArray< long > shadow_dynarray
void assign_xoffset(EepicNode< long > *p, int, const int position)
bool south_offset(EepicNode< long > *root, const size_t &level)
void load_thread_option(ifstream &input_stream)
DynArray< long > pos_parrectangle_dynarray
void assign_distance(EepicNode< long > *p, int, const int position)
void assign_external_nodes(EepicNode< long > *p)
DynArray< long > pos_xoffset_dynarray
DynArray< long > tag_pos_dynarray
void load_parrectangle_option(ifstream &input_stream)
void adjust_size_by_tags(EepicNode< long > *root, const size_t &height)
void assign_key(EepicNode< long > *p, int, const int position)
void generate_split_lines(ofstream &output, EepicNode< long > *root)
DynArray< long > infix_dynarray
void assign_aux(EepicNode< long > *p, int, const int position)
void generate_epilogue(ofstream &output)
DynArray< long > without_node_dynarray
static constexpr char license_text[]
DynArray< long > pos_distance_dynarray
void assign_arcs(EepicNode< long > *root, EepicNode< long > *p)
void load_arc_option(ifstream &input_stream, const Token_Type &token_type)
long double x_picture_offset
DynArray< long double > xoffset_dynarray
void load_offset_option(ifstream &input_stream, DynArray< long > &positions, DynArray< long double > &offsets)
const char * argp_program_version
DynArray< Line_Distance_Data > distance_dynarray
DynArray< long double > height_parrectangle_dynarray
DynArray< string > key_print_dynarray
DynArray< Arc_Data > target_arc_dynarray
void assign_yoffset(EepicNode< long > *p, int, const int position)
void assign_triangle(EepicNode< long > *p, int, const int position)
DynArray< long double > height_rectangle_dynarray
void compute_picture_size(EepicNode< long > *p)
DynArray< long > pos_rectangle_dynarray
void assign_without_node(EepicNode< long > *p, int, const int position)
void load_split_option(ifstream &input_stream)
DynArray< long double > height_triangle_dynarray
void load_distance_option(ifstream &input_stream)
void assign_shadow(EepicNode< long > *p, int, const int position)
EepicNode< long > * build_tree()
DynArray< long > scratch_dynarray
DynArray< string > aux_print_dynarray
void reassign_key(EepicNode< long > *p, int, const int position)
DynArray< long > prefix_dynarray
DynArray< string > key_string_dynarray
void assign_without_arc(EepicNode< long > *p, int, const int position)
DynArray< long > without_arc_dynarray
void load_rectangle_option(ifstream &input_stream)
void assign_parrectangle(EepicNode< long > *p, int, const int position)
#define DYNARRAY_APPEND(array, item)
DynArray< long double > yoffset_dynarray
DynArray< long > pos_yoffset_dynarray
DynArray< long > pos_triangle_dynarray
void set_picture_size(EepicNode< long > *p)
DynArray< Tag_Data > tag_data_dynarray
void assign_scratch(EepicNode< long > *p, int, const int position)
long double y_picture_offset
void generate_prologue(ofstream &output)
void load_triangle_option(ifstream &input_stream)
bool north_offset(EepicNode< long > *p)
DynArray< long > source_arc_dynarray
DynArray< long > source_thread_dynarray
void load_triangleh_option(ifstream &input_stream)
int max_num_nodes_rectangle
void generate_tree(ofstream &output, EepicNode< long > *p)
DynArray< Split_Data > split_string_dynarray
void load_key_option(ifstream &input_stream)
DynArray< long > split_dynarray
bool east_offset(EepicNode< long > *root)
bool has_curr() const noexcept
Return true if the iterator has current item.
void cut(const size_t new_dim=0)
Cut the array to a new dimension; that is, it reduces the dimension of array and frees the remaining ...
size_t size() const noexcept
Return the current dimension of array.
Dynamic doubly linked list with O(1) size and bidirectional access.
DynDlist< Tag_Data > tag_list
Line_Distance_Data & get_line_distance_data()
bool & get_external_node()
DynDlist< Thread_Desc > thread_list
long double & get_yoffset()
long double & get_xoffset()
string & get_key_string()
Line_Distance_Data line_distance_data
DynDlist< Arc_Desc > & get_arc_list()
long double triangle_height
long double rectangle_height
bool is_rectangle() const
bool & get_without_node()
string & get_aux_string()
DynDlist< Arc_Desc > arc_list
EepicNode< long > *& get_prev()
DynDlist< Tag_Data > & get_tag_list()
long double & get_triangle_height()
DynDlist< Thread_Desc > & get_thread_list()
long double & get_rectangle_height()
EepicNode< long > *& get_succ()
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
bool tiny_keys
Global flag to enable tiny font size for keys/labels.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y1_function > > y1(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
DynDlist< Node * > compute_nodes_in_level(Node *root, const int &level)
Count the number of nodes in a specific tree level.
Node * find_min(Node *root) noexcept
Return the minimum key contained in a binary search tree.
int inOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively inorder a binary tree.
#define DECLARE_BINNODE(Name, height, Control_Data)
Specify tree node for a binary tree.
size_t computeHeightRec(Node *root) noexcept
Compute the height of root
Node * find_max(Node *root) noexcept
Return the maximum key contained in a binary search tree.
Main namespace for Aleph-w library functions.
long search_max(T *a, const long l, const long r, const Compare &cmp=Compare())
Returns the maximum element of the array a between l and r.
void init_token_scanning()
Initialize token scanning by recording current position.
void close_token_scanning(const char *buffer, char *&start_addr, const char *end_addr)
Finalize token scanning by null-terminating and saving the token.
int read_char_from_stream(std::ifstream &input_stream)
Read a single character from an input stream with position tracking.
void print_parse_error_and_exit(const std::string &str)
Print a parse error message and terminate the program.
and
Check uniqueness with explicit hash + equality functors.
std::string token_instance
The most recently scanned token.
void put_char_in_buffer(char *&start_addr, const char *end_addr, int c)
Append a character to a buffer with bounds checking.
std::string command_line_to_string(int argc, char *argv[])
Convert command line arguments to a single string.
void skip_white_spaces(std::ifstream &input_stream)
Skip whitespace characters in the input stream.
constexpr size_t Buffer_Size
Default buffer size for token parsing.
std::string load_string(std::ifstream &input_stream)
Load a string from the input stream.
long load_number(std::ifstream &input_stream)
Load an integer number from the input stream.
Comprehensive parsing utilities for text processing and compiler construction.
#define PRINT_ERROR(...)
Macro for printing detailed parse errors.
EepicNode< long > * target_node
Tag_Data(const string &str, Tag_Option option)
EepicNode< long > * target_node
Utility functions for binary tree operations.
Basic binary tree node definitions.
Lazy and scalable dynamic array implementation.
Dynamic doubly linked list implementation.
Comprehensive sorting algorithms and search utilities for Aleph-w.
Tree picture generation utilities.
void intersection_ellipse_line(long double lx0, long double ly0, long double lx1, long double ly1, long double a, long double b, long double &dx, long double &dy)
const char *const font_wrapper
void put_string(std::ofstream &output, const long double &x, const long double &y, const std::string &comment, const std::string &str)
long double string_width(const std::string &str)
void draw_arc(std::ofstream &output, long double src_x, long double src_y, long double tgt_x, long double tgt_y, bool is_dashed, bool with_arrow, bool thick=true)
long double font_height()
long double YPIC(long double y)
long double center_string(const std::string &str, long double window_size)