00001
00002
00004
00005
00006
00007 #define TMP_EQL_TMP TODO1
00008 #define COMMONTMPSTARTLEVEL TODO
00009 #define PHASEDIR {TODO REPLACE (PHASE,DIR) phase ## PHASE ## _ ## DIR}
00010 #define SET_TEA (X) TMP_EQUAL_ALT = X
00011
00012
00013
00014 #define ISCHANGED changed = 1;
00015 #define NOTCHANGED changed = 0;
00016 #define SETCROSS nr_crossings = cross;
00017 #define CALCCROSS cross = graph_crossings ();
00018 #define RENAME_ALT have_alternative = alt;
00019 #define NOCROSSING (nr_crossings == 0)
00020 #define INCREMENTMAXDEPTH maxdepth + 1
00021 #define NOPHASE1 phase1_allowed = 0;
00022 #define SOMETIMELIMIT (G_timelimit > 0)
00023 #define INCREMENT_ITERATIONS nr_bary_iterations+
00024 #define OVERLIMIT_ITERATIONS (nr_bary_iterations >= max_baryiterations)
00025 #define UNDERLIMIT_ITERATIONS (nr_bary_iterations < min_baryiterations)
00026 #define TMP_EQUAL_ALT tmp_startlevel = alt_startlevel
00027 #define RESET_TEMP tmp_startlevel = 0
00028 #define ALT_EQUAL_TMP alt_startlevel = tmp_startlevel
00029 #define P2_EQL_TMP phase2_startlevel = tmp_startlevel
00030 #define TMP_EQL_P2 tmp_startlevel = phase2_startlevel
00031 #define TMP_EQL_MAX tmp_startlevel = maxdepth
00032 #define TMP_GE_MAX tmp_startlevel > maxdepth
00033 #define TMP_LE_ZRO tmp_startlevel < 0
00034 #define NOALTERNATIVE alt = 0; #define HAVEALTERNATIVE alt = 1;
00035 #define SAMECROSSINGSEXPR (cross == nr_crossings)
00036 #define LESSCROSSINGSEXPR (cross < nr_crossings)
00037 #define MORECROSSINGS if (cross > nr_crossings)
00038 #define CHECKALT if (have_alternative)
00039 #define RESTORELAYER copy_layers (tmp_layer, layer);
00040 #define BACKUPLAYER copy_layers (layer, tmp_layer);
00041 #define SKIP_BARYPHASE2 if (skip_baryphase2) return;
00042
00043
00044
00045
00046 #define P2_EQ_TMP_ALT phase2_startlevel = TMP_EQUAL_ALT
00047 #define LESSCROSSINGS if LESSCROSSINGSEXPR
00048 #define BLOCKCOPYING1 RESTORELAYER TMP_EQUAL_ALT;
00049 #define BLOCK1 BACKUPLAYER SETCROSS ALT_EQUAL_TMP;
00050 #define CROSSINGSBLOCK1 LESSCROSSINGS { ISCHANGED BLOCK1 }
00051 #define BLOCKCOPYING1B { BLOCKCOPYING1 }
00052 #define CROSSINGSBLOCK2 if (LESSCROSSINGSEXPR || UNDERLIMIT_ITERATIONS) { ISCHANGED BLOCK1 }
00053 #define CHECKALTBLOCK { \
00054 RESTORELAYER PHASEDIR(1,up); CALCCROSSING2 \
00055 else MORECROSSINGS BLOCKCOPYING1B \
00056 else HAVEALTERNATIVE \
00057 }
00058
00059 #define COMMONBLOCK_BLOCK \
00060 INCREMENT_ITERATIONS; \
00061 if OVERLIMIT_ITERATIONS {gs_wait_message ('t'); break; } \
00062 if SOMETIMELIMIT if (test_timelimit (60)) { gs_wait_message ('t'); break; } \
00063 NOTCHANGED P2_EQL_TMP; PHASEDIR(2,down);TMP_EQL_TMP;
00064
00065
00066 #define CALCCROSSING1 CALCCROSS NOALTERNATIVE
00067 #define CALCCROSSING2 CALCCROSS CROSSINGSBLOCK1
00068 #define EXITWHENZEROCROSS if NOCROSSING return;
00069
00070
00071 #define CHANGEDLOOP_POST SET_TEA(INCREMENTMAXDEPTH); ISCHANGED
00072
00073
00074
00075 #define SIMILARBLOCK1 \
00076 COMMON3_OPEN \
00077 PHASEDIR(2,down); COMMONTMPSTARTLEVEL \
00078 TMP_EQL_TMP; if (TMP_GE_MAX) RESET_TEMP; \
00079 COMMON3_CLOSE
00080
00081 #define SIMILARBLOCK2 \
00082 COMMON3_OPEN \
00083 PHASEDIR(2,up); COMMONTMPSTARTLEVEL \
00084 TMP_EQL_TMP; if (TMP_LE_ZRO) TMP_EQL_MAX; \
00085 COMMON3_CLOSE
00086
00087
00088 #define CHANGEDLOOP_BLOCK if (TMP_GE_MAX) RESET_TEMP; \
00089 SIMILARBLOCK1 \
00090 EXITWHENZEROCROSS
00091
00092 #define Changedloop_CLOSEPRE \
00093 COMMONBLOCK_OPEN \
00094 if (TMP_LE_ZRO) TMP_EQL_MAX; \
00095 SIMILARBLOCK2\
00096 PHASEDIR(1,up); CALCCROSSING1 CROSSINGSBLOCK2 \
00097 else CHECKALT CHECKALTBLOCK \
00098 else if SAMECROSSINGSEXPR HAVEALTERNATIVE \
00099 else BLOCKCOPYING1B \
00100 \
00101 RENAME_ALT \
00102 EXITWHENZEROCROSS
00103
00104
00105 #define COMMONBLOCK_OPEN while (changed) { COMMONBLOCK_BLOCK
00106
00107 #define CHANGEDLOOP_CLOSE COMMONBLOCK_OPEN CHANGEDLOOP_BLOCK } CHANGEDLOOP_POST
00108
00109
00110 #define COMMON3_PRE1 CALCCROSSING1 CROSSINGSBLOCK1
00111 #define COMMON3_COND1 else CHECKALT
00112 #define COMMON3_POST1 RESTORELAYER P2_EQ_TMP_ALT;
00113
00114
00115 #define COMMON3_PRE2 CALCCROSSING2 \
00116 else MORECROSSINGS BLOCKCOPYING1B \
00117 else HAVEALTERNATIVE
00118
00119 #define COMMON3_POST2 else if SAMECROSSINGSEXPR HAVEALTERNATIVE \
00120 else \
00121 BLOCKCOPYING1B \
00122 RENAME_ALT
00123
00124 #define COMMON3_OPEN COMMON3_PRE1 COMMON3_COND1 { COMMON3_POST1
00125
00126 #define COMMON3_CLOSE COMMON3_PRE2 } COMMON3_POST2
00127
00128 #define Changedloop_CLOSEPOS EXITWHENZEROCROSS SKIP_BARYPHASE2 NOPHASE1 \
00129 SET_TEA(0); ISCHANGED \
00130 CHANGEDLOOP_CLOSE \
00131 CHANGEDLOOP2
00132
00133 #define Changedloop_CLOSE Changedloop_CLOSEPRE } Changedloop_CLOSEPOS }
00134