| 1 |
%% |
| 2 |
%% This is file `tikzlibrarytqft.code.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% tqft_code.dtx (with options: `library') |
| 8 |
%% ---------------------------------------------------------------- |
| 9 |
%% tqft --- a TikZ library for drawing TQFT diagrams |
| 10 |
%% E-mail: [email protected] |
| 11 |
%% Released under the LaTeX Project Public License v1.3c or later |
| 12 |
%% See http://www.latex-project.org/lppl.txt |
| 13 |
%% ---------------------------------------------------------------- |
| 14 |
%% |
| 15 |
\ProvidesFile{tikzlibrarytqft.code.tex}[2024/05/31 v2.3 Tikz/PGF commands for drawing TQFT diagrams] |
| 16 |
\ifcsname pgfk@/handlers/.pic/.@cmd\endcsname |
| 17 |
\else |
| 18 |
\pgfwarning{This library only works with TikZ 3.0 or later; for earlier versions of TikZ use the TQFT package} |
| 19 |
\fi |
| 20 |
\usetikzlibrary{shapes.geometric} |
| 21 |
\def\pgf@tqft@minus{-} |
| 22 |
\let\pgf@tqft@upper\@empty |
| 23 |
\let\pgf@tqft@lower\pgf@tqft@minus |
| 24 |
\newif\iftqft@twisted |
| 25 |
\def\tqft@split(#1,#2){% |
| 26 |
\pgfmathsetmacro\tqft@y{#2 * (-\tqft@val{cobordism height})}% |
| 27 |
\pgfmathsetmacro\tqft@x{(#1 - 1 + max(min(#2,1),0)*\tqft@val{offset}) * \tqft@val{boundary separation}}% |
| 28 |
\def\tqft@shift{(\tqft@x pt, \tqft@y pt)}% |
| 29 |
}% |
| 30 |
\tikzset{ |
| 31 |
pic alias/.code={% |
| 32 |
\tikz@fig@mustbenamed |
| 33 |
\expandafter\def\expandafter\tikz@alias\expandafter{\tikz@alias\pgfnodealias{\tikz@pp@name{#1}}{\tikz@fig@name}}% |
| 34 |
}, |
| 35 |
tqft/.style={% |
| 36 |
pic type=cobordism, |
| 37 |
every tqft/.try, |
| 38 |
tqft/.cd, |
| 39 |
}, |
| 40 |
tqft/.unknown/.code={% |
| 41 |
\let\tqft@searchname=\pgfkeyscurrentname% |
| 42 |
\pgfkeysalso{% |
| 43 |
/tikz/\tqft@searchname={#1} |
| 44 |
} |
| 45 |
}, |
| 46 |
tqft/.cd, |
| 47 |
incoming boundary components/.initial=5, |
| 48 |
outgoing boundary components/.initial=4, |
| 49 |
skip incoming boundary components/.initial={}, |
| 50 |
skip outgoing boundary components/.initial={}, |
| 51 |
genus/.initial = 0, |
| 52 |
offset/.initial=0, |
| 53 |
cobordism height/.initial=2cm, |
| 54 |
boundary separation/.initial=2cm, |
| 55 |
circle x radius/.initial=10pt, |
| 56 |
circle y radius/.initial=5pt, |
| 57 |
view from/.is choice, |
| 58 |
view from/incoming/.code={% |
| 59 |
\let\pgf@tqft@upper\pgf@tqft@minus |
| 60 |
\let\pgf@tqft@lower\@empty |
| 61 |
}, |
| 62 |
view from/outgoing/.code={% |
| 63 |
\let\pgf@tqft@lower\pgf@tqft@minus |
| 64 |
\let\pgf@tqft@upper\@empty |
| 65 |
}, |
| 66 |
twisted/.is if=tqft@twisted, |
| 67 |
anchor/.initial = none, |
| 68 |
pair of pants/.style={ |
| 69 |
/tikz/tqft, |
| 70 |
incoming boundary components=1, |
| 71 |
outgoing boundary components=2, |
| 72 |
offset=-.5 |
| 73 |
}, |
| 74 |
/tikz/tqft pair of pants/.style={ |
| 75 |
/tikz/tqft/pair of pants, |
| 76 |
}, |
| 77 |
reverse pair of pants/.style={ |
| 78 |
/tikz/tqft, |
| 79 |
incoming boundary components=2, |
| 80 |
outgoing boundary components=1, |
| 81 |
offset=.5 |
| 82 |
}, |
| 83 |
/tikz/tqft reverse pair of pants/.style={ |
| 84 |
/tikz/tqft/reverse pair of pants, |
| 85 |
}, |
| 86 |
cylinder to prior/.style={ |
| 87 |
/tikz/tqft, |
| 88 |
incoming boundary components=1, |
| 89 |
outgoing boundary components=1, |
| 90 |
offset=-.5 |
| 91 |
}, |
| 92 |
/tikz/tqft cylinder to prior/.style={ |
| 93 |
/tikz/tqft/cylinder to prior, |
| 94 |
}, |
| 95 |
cylinder to next/.style={ |
| 96 |
/tikz/tqft, |
| 97 |
incoming boundary components=1, |
| 98 |
outgoing boundary components=1, |
| 99 |
offset=.5 |
| 100 |
}, |
| 101 |
/tikz/tqft cylinder to next/.style={ |
| 102 |
/tikz/tqft/cylinder to next, |
| 103 |
}, |
| 104 |
cylinder/.style={ |
| 105 |
/tikz/tqft, |
| 106 |
incoming boundary components=1, |
| 107 |
outgoing boundary components=1 |
| 108 |
}, |
| 109 |
/tikz/tqft cylinder/.style={ |
| 110 |
/tikz/tqft/cylinder, |
| 111 |
}, |
| 112 |
cup/.style={ |
| 113 |
/tikz/tqft, |
| 114 |
incoming boundary components=1, |
| 115 |
outgoing boundary components=0 |
| 116 |
}, |
| 117 |
/tikz/tqft cup/.style={ |
| 118 |
/tikz/tqft/cup, |
| 119 |
}, |
| 120 |
cap/.style={ |
| 121 |
/tikz/tqft, |
| 122 |
incoming boundary components=0, |
| 123 |
outgoing boundary components=1 |
| 124 |
}, |
| 125 |
/tikz/tqft cap/.style={ |
| 126 |
/tikz/tqft/cap, |
| 127 |
}, |
| 128 |
} |
| 129 |
\def\tqft@val#1{\pgfkeysvalueof{/tikz/tqft/#1}} |
| 130 |
\tikzset{ |
| 131 |
cobordism/.pic={ |
| 132 |
\gdef\tqft@fullpath{}% |
| 133 |
\global\let\tqft@blist\pgfutil@gobble% |
| 134 |
\gdef\tqft@gclip{}% |
| 135 |
\global\let\tqft@glist\pgfutil@gobble% |
| 136 |
\global\let\tqft@clist\pgfutil@gobble% |
| 137 |
\global\let\tqft@alist\pgfutil@gobble |
| 138 |
\global\let\tqft@ibdrylist=\pgfutil@gobble |
| 139 |
\global\let\tqft@cibdrylist=\pgfutil@gobble |
| 140 |
\global\let\tqft@obdrylist=\pgfutil@gobble |
| 141 |
\global\let\tqft@cobdrylist=\pgfutil@gobble |
| 142 |
\global\let\tqft@robdrylist=\pgfutil@gobble |
| 143 |
\global\let\tqft@rcobdrylist=\pgfutil@gobble |
| 144 |
\iftqft@twisted |
| 145 |
\pgfmathsetmacro\tqft@outgoing@end{0}% |
| 146 |
\pgfmathsetmacro\tqft@outgoing@dir{-1}% |
| 147 |
\else |
| 148 |
\pgfmathsetmacro\tqft@outgoing@end{1}% |
| 149 |
\pgfmathsetmacro\tqft@outgoing@dir{1}% |
| 150 |
\fi |
| 151 |
\ifnum\tqft@val{incoming boundary components}>0\relax |
| 152 |
\xdef\tqft@fullpath{% |
| 153 |
\tqft@fullpath |
| 154 |
(-\tqft@val{circle x radius},0) arc[start angle=\pgf@tqft@upper180, end angle=0, x radius=\tqft@val{circle x radius}, y radius=\tqft@val{circle y radius}] |
| 155 |
}% |
| 156 |
\xdef\tqft@alist{% |
| 157 |
\tqft@alist,-incoming boundary 1/{(0,0)},-incoming boundary/{(0,0)}% |
| 158 |
}% |
| 159 |
\ifnum\tqft@val{incoming boundary components}>1\relax |
| 160 |
\foreach \k in {2,...,\tqft@val{incoming boundary components}} { |
| 161 |
\edef\tqft@temp{\noexpand\pgfutil@in@{,\k,}{,\tqft@val{skip incoming boundary components},}} |
| 162 |
\tqft@temp |
| 163 |
\ifpgfutil@in@ |
| 164 |
\xdef\tqft@cibdrylist{\tqft@cibdrylist,\k} |
| 165 |
\else |
| 166 |
\xdef\tqft@ibdrylist{\tqft@ibdrylist,\k} |
| 167 |
\fi |
| 168 |
} |
| 169 |
\ifx\tqft@ibdrylist\pgfutil@gobble |
| 170 |
\else |
| 171 |
\foreach \k [ |
| 172 |
remember=\k as \kmo (initially 1), |
| 173 |
evaluate=\k as \xpos using (\k-1)*\tqft@val{boundary separation} -\tqft@val{circle x radius}, |
| 174 |
] in \tqft@ibdrylist { |
| 175 |
\pgfmathsetmacro\xppos{(\kmo - 1)*\tqft@val{boundary separation} + \tqft@val{circle x radius}} |
| 176 |
\pgfmathsetmacro\cpos{(\xpos + \xppos)/2} |
| 177 |
\xdef\tqft@fullpath{% |
| 178 |
\tqft@fullpath |
| 179 |
.. controls +(0,-\tqft@val{cobordism height}/3) and +(0,-\tqft@val{cobordism height}/3) .. (\xpos pt,0) arc[start angle=\pgf@tqft@upper180, end angle=0, x radius=\tqft@val{circle x radius}, y radius=\tqft@val{circle y radius}] |
| 180 |
}% |
| 181 |
\xdef\tqft@blist{% |
| 182 |
\tqft@blist,incoming boundary \k/incoming/{% |
| 183 |
(\xppos pt,0) .. controls +(0,-\tqft@val{cobordism height}/3) and +(0,-\tqft@val{cobordism height}/3) .. (\xpos pt,0)}% |
| 184 |
}% |
| 185 |
\xdef\tqft@clist{% |
| 186 |
\tqft@clist,-between incoming \kmo\space and \k/{(\cpos pt,-\tqft@val{cobordism height}/4)}% |
| 187 |
}% |
| 188 |
\xdef\tqft@alist{% |
| 189 |
\tqft@alist,-incoming boundary \k/{(\kmo * \tqft@val{boundary separation},0)}% |
| 190 |
}% |
| 191 |
}% |
| 192 |
\fi |
| 193 |
\fi |
| 194 |
\ifnum\tqft@val{outgoing boundary components}>0\relax |
| 195 |
\pgfmathsetmacro\xppos{% |
| 196 |
(\tqft@outgoing@end * (\tqft@val{outgoing boundary components} -1) |
| 197 |
+ \tqft@val{offset}) * \tqft@val{boundary separation} |
| 198 |
+ \tqft@outgoing@dir * \tqft@val{circle x radius}}% |
| 199 |
\pgfmathsetmacro\tqft@ht{abs(\tqft@val{incoming boundary components} - \tqft@val{outgoing boundary components} - \tqft@val{offset})}% |
| 200 |
\pgfmathsetmacro\tqft@ht{1/3 + 2/3*\tqft@ht/(\tqft@ht + 1)}% |
| 201 |
\xdef\tqft@fullpath{% |
| 202 |
\tqft@fullpath |
| 203 |
.. controls +(0,-\tqft@ht*\tqft@val{cobordism height}) and +(0,\tqft@ht*\tqft@val{cobordism height}) .. (\xppos pt, -\tqft@val{cobordism height}) |
| 204 |
}% |
| 205 |
\xdef\tqft@blist{% |
| 206 |
\tqft@blist,between last incoming and last outgoing/incoming and outgoing/{% |
| 207 |
(\tqft@val{incoming boundary components} * \tqft@val{boundary separation} + \tqft@val{circle x radius} - \tqft@val{boundary separation},0pt) |
| 208 |
.. controls +(0,-\tqft@ht*\tqft@val{cobordism height}) and +(0,\tqft@ht*\tqft@val{cobordism height}) .. (\xppos pt, -\tqft@val{cobordism height})}% |
| 209 |
}% |
| 210 |
\pgfmathsetmacro\xppos{(\xppos + (\tqft@val{incoming boundary components} -1) * \tqft@val{boundary separation} +\tqft@val{circle x radius})/2}% |
| 211 |
\xdef\tqft@clist{% |
| 212 |
\tqft@clist,-between last incoming and last outgoing/{(\xppos pt,-\tqft@val{cobordism height}/2)}% |
| 213 |
}% |
| 214 |
\else |
| 215 |
\pgfmathsetmacro\tqft@ht{1/3 + 2/3*(\tqft@val{incoming boundary components} - 1)/\tqft@val{incoming boundary components}} |
| 216 |
\xdef\tqft@fullpath{% |
| 217 |
\tqft@fullpath |
| 218 |
.. controls +(0,-\tqft@ht*\tqft@val{cobordism height}) and +(0,-\tqft@ht*\tqft@val{cobordism height}) .. (-\tqft@val{circle x radius},0) |
| 219 |
}% |
| 220 |
\xdef\tqft@blist{% |
| 221 |
\tqft@blist,between first and last incoming/incoming and outgoing/{% |
| 222 |
(\tqft@val{incoming boundary components} * \tqft@val{boundary separation} + \tqft@val{circle x radius} - \tqft@val{boundary separation},0pt) |
| 223 |
.. controls +(0,-\tqft@ht*\tqft@val{cobordism height}) and +(0,-\tqft@ht*\tqft@val{cobordism height}) .. (-\tqft@val{circle x radius},0)} |
| 224 |
}% |
| 225 |
\pgfmathsetmacro\xppos{(\tqft@val{incoming boundary components} -1) * \tqft@val{boundary separation}/2}% |
| 226 |
\xdef\tqft@clist{% |
| 227 |
\tqft@clist,-between first and last incoming/{(\xppos pt,-\tqft@ht*\tqft@val{cobordism height}*3/4)},-between first incoming and last incoming/{(\xppos pt,-\tqft@ht*\tqft@val{cobordism height}*3/4)}% |
| 228 |
}% |
| 229 |
\fi |
| 230 |
\else |
| 231 |
\ifnum\tqft@val{outgoing boundary components}>0\relax |
| 232 |
\pgfmathsetmacro\xppos{( \tqft@outgoing@end * (\tqft@val{outgoing boundary components} -1)+\tqft@val{offset}) * \tqft@val{boundary separation} + \tqft@outgoing@dir * \tqft@val{circle x radius}} |
| 233 |
\xdef\tqft@fullpath{% |
| 234 |
\tqft@fullpath |
| 235 |
(\xppos pt, -\tqft@val{cobordism height}) |
| 236 |
}% |
| 237 |
\fi |
| 238 |
\fi |
| 239 |
\ifnum\tqft@val{outgoing boundary components}>0\relax |
| 240 |
\pgfmathsetmacro\xppos{% |
| 241 |
( \tqft@outgoing@end * (\tqft@val{outgoing boundary components} -1) |
| 242 |
+ \tqft@val{offset}) * \tqft@val{boundary separation} |
| 243 |
- \tqft@outgoing@dir * \tqft@val{circle x radius}}% |
| 244 |
\xdef\tqft@fullpath{% |
| 245 |
\tqft@fullpath |
| 246 |
arc[end angle=\pgf@tqft@upper180, start angle=0, x radius=\tqft@outgoing@dir * \tqft@val{circle x radius}, y radius=\tqft@val{circle y radius}] |
| 247 |
}% |
| 248 |
\xdef\tqft@alist{% |
| 249 |
\tqft@alist,-outgoing boundary \tqft@val{outgoing boundary components}/{(\xppos pt + \tqft@outgoing@dir * \tqft@val{circle x radius},-\tqft@val{cobordism height})},-outgoing boundary/{(\tqft@val{offset}*\tqft@val{boundary separation},-\tqft@val{cobordism height})}% |
| 250 |
}% |
| 251 |
\ifnum\tqft@val{outgoing boundary components}>1\relax |
| 252 |
\foreach \k [evaluate=\k as \ok using int(\tqft@outgoing@end * (\tqft@val{outgoing boundary components} + 1) - \tqft@outgoing@dir * \k)] in {2,...,\tqft@val{outgoing boundary components}} { |
| 253 |
\edef\tqft@temp{\noexpand\pgfutil@in@{,\ok,}{,\tqft@val{skip outgoing boundary components},}} |
| 254 |
\tqft@temp |
| 255 |
\ifpgfutil@in@ |
| 256 |
\xdef\tqft@cobdrylist{\tqft@cobdrylist,\k} |
| 257 |
\else |
| 258 |
\xdef\tqft@obdrylist{\tqft@obdrylist,\k} |
| 259 |
\fi |
| 260 |
} |
| 261 |
\ifx\tqft@obdrylist\pgfutil@gobble |
| 262 |
\else |
| 263 |
\foreach \k [ |
| 264 |
remember=\k as \kmo (initially 1), |
| 265 |
evaluate=\k as \xpos using ( \tqft@outgoing@end * (\tqft@val{outgoing boundary components} + 1) - 1 - \tqft@outgoing@dir * \k + \tqft@val{offset})*\tqft@val{boundary separation} + \tqft@outgoing@dir * \tqft@val{circle x radius}, |
| 266 |
] in \tqft@obdrylist { |
| 267 |
\pgfmathsetmacro\xppos{(\tqft@outgoing@end * (\tqft@val{outgoing boundary components} + 1) - 1 - \tqft@outgoing@dir * \kmo + \tqft@val{offset})*\tqft@val{boundary separation} - \tqft@outgoing@dir * \tqft@val{circle x radius}} |
| 268 |
\pgfmathsetmacro\cpos{(\xpos + \xppos)/2} |
| 269 |
\pgfmathsetmacro\nk{int(\tqft@val{outgoing boundary components} - \k + 1)} |
| 270 |
\pgfmathsetmacro\nkpo{int(\tqft@val{outgoing boundary components} - \kmo + 1)} |
| 271 |
\xdef\tqft@fullpath{% |
| 272 |
\tqft@fullpath |
| 273 |
.. controls +(0,\tqft@val{cobordism height}/3) and +(0,\tqft@val{cobordism height}/3) .. (\xpos pt,-\tqft@val{cobordism height}) arc[end angle=\pgf@tqft@upper180, start angle=0, x radius=\tqft@outgoing@dir * \tqft@val{circle x radius}, y radius=\tqft@val{circle y radius}] |
| 274 |
}% |
| 275 |
\xdef\tqft@blist{% |
| 276 |
\tqft@blist,between outgoing \nk\space and \nkpo/outgoing/{% |
| 277 |
(\xppos pt,-\tqft@val{cobordism height}) |
| 278 |
.. controls +(0,\tqft@val{cobordism height}/3) and +(0,\tqft@val{cobordism height}/3) .. (\xpos pt,-\tqft@val{cobordism height}) ++(-2*\tqft@val{circle x radius},0)}% |
| 279 |
}% |
| 280 |
\xdef\tqft@clist{% |
| 281 |
\tqft@clist,-between outgoing \nk\space and \nkpo/{(\cpos pt,-3*\tqft@val{cobordism height}/4)}% |
| 282 |
}% |
| 283 |
\xdef\tqft@alist{% |
| 284 |
\tqft@alist,-outgoing boundary \nk/{(\xpos pt - \tqft@val{circle x radius},-\tqft@val{cobordism height})}% |
| 285 |
}% |
| 286 |
}% |
| 287 |
\fi |
| 288 |
\fi |
| 289 |
\ifnum\tqft@val{incoming boundary components}>0\relax |
| 290 |
\pgfmathsetmacro\tqft@ht{1/3 + 2/3*abs(\tqft@val{offset})/(abs(\tqft@val{offset}) + 1)}% |
| 291 |
\xdef\tqft@fullpath{% |
| 292 |
\tqft@fullpath |
| 293 |
.. controls +(0,\tqft@ht*\tqft@val{cobordism height}) and +(0,-\tqft@ht*\tqft@val{cobordism height}) .. (-\tqft@val{circle x radius},0) |
| 294 |
}% |
| 295 |
\xdef\tqft@blist{% |
| 296 |
\tqft@blist,between first incoming and first outgoing/incoming and outgoing/{% |
| 297 |
({ ( (1 - \tqft@outgoing@end) * (\tqft@val{outgoing boundary components} - 1) + \tqft@val{offset}) * \tqft@val{boundary separation} - \tqft@outgoing@dir * \tqft@val{circle x radius}},-\tqft@val{cobordism height}) |
| 298 |
.. controls +(0,\tqft@ht*\tqft@val{cobordism height}) and +(0,-\tqft@ht*\tqft@val{cobordism height}) .. (-\tqft@val{circle x radius},0)}% |
| 299 |
}% |
| 300 |
\xdef\tqft@clist{% |
| 301 |
\tqft@clist,-between first incoming and first outgoing/{({ ( (1 - \tqft@outgoing@end) * (\tqft@val{outgoing boundary components} - 1) +\tqft@val{offset})*\tqft@val{boundary separation}/2- \tqft@outgoing@end * \tqft@val{circle x radius}},-\tqft@val{cobordism height}/2)}% |
| 302 |
}% |
| 303 |
\else |
| 304 |
\pgfmathsetmacro\xppos{(\tqft@val{outgoing boundary components} -1+\tqft@val{offset}) * \tqft@val{boundary separation} +\tqft@val{circle x radius}}% |
| 305 |
\pgfmathsetmacro\tqft@ht{1/3 + 2/3*(\tqft@val{outgoing boundary components} - 1)/\tqft@val{outgoing boundary components}} |
| 306 |
\xdef\tqft@fullpath{% |
| 307 |
\tqft@fullpath |
| 308 |
.. controls +(0,\tqft@ht*\tqft@val{cobordism height}) and +(0,\tqft@ht*\tqft@val{cobordism height}) .. (\xppos pt,-\tqft@val{cobordism height}) |
| 309 |
}% |
| 310 |
\xdef\tqft@blist{% |
| 311 |
\tqft@blist,between first and last outgoing/incoming and outgoing/{% |
| 312 |
(\tqft@val{offset} * \tqft@val{boundary separation} - \tqft@val{circle x radius},-\tqft@val{cobordism height}) |
| 313 |
.. controls +(0,\tqft@ht*\tqft@val{cobordism height}) and +(0,\tqft@ht*\tqft@val{cobordism height}) .. (\xppos pt,-\tqft@val{cobordism height})}% |
| 314 |
}% |
| 315 |
\pgfmathsetmacro\xppos{(\tqft@val{outgoing boundary components}/2 + \tqft@val{offset} -1/2) * \tqft@val{boundary separation}}% |
| 316 |
\pgfmathsetmacro\tqft@ht{1 -\tqft@ht*3/4}% |
| 317 |
\xdef\tqft@clist{% |
| 318 |
\tqft@clist,-between first and last outgoing/{(\xppos pt,-\tqft@ht*\tqft@val{cobordism height})},-between first outgoing and last outgoing/{(\xppos pt,-\tqft@ht*\tqft@val{cobordism height})}% |
| 319 |
}% |
| 320 |
\fi |
| 321 |
\fi |
| 322 |
\pgfmathsetmacro\xpos{% |
| 323 |
( |
| 324 |
\tqft@val{outgoing boundary components} > 0 ? |
| 325 |
( |
| 326 |
\tqft@val{incoming boundary components} > 0 ? |
| 327 |
min(0,\tqft@val{offset}) : \tqft@val{offset} |
| 328 |
) : 0 |
| 329 |
) |
| 330 |
*\tqft@val{boundary separation} - 2*\tqft@val{circle x radius}}% |
| 331 |
\xdef\tqft@gclip{(\xpos pt,2*\tqft@val{circle y radius}) rectangle }% |
| 332 |
\pgfmathsetmacro\xpos{% |
| 333 |
(( |
| 334 |
\tqft@val{outgoing boundary components} > 0 ? |
| 335 |
( |
| 336 |
\tqft@val{incoming boundary components} > 0 ? |
| 337 |
max(\tqft@val{incoming boundary components},\tqft@val{outgoing boundary components} + \tqft@val{offset}) : \tqft@val{outgoing boundary components} + \tqft@val{offset} |
| 338 |
) : \tqft@val{incoming boundary components} |
| 339 |
)-1) |
| 340 |
*\tqft@val{boundary separation} + 2*\tqft@val{circle x radius}}% |
| 341 |
\xdef\tqft@gclip{\tqft@gclip (\xpos pt,-\tqft@val{cobordism height} - 2*\tqft@val{circle y radius})}% |
| 342 |
\ifnum\tqft@val{genus}>0\relax |
| 343 |
\pgfmathsetmacro\xpos{% |
| 344 |
( |
| 345 |
\tqft@val{outgoing boundary components} > 0 ? |
| 346 |
( |
| 347 |
\tqft@val{incoming boundary components} > 0 ? |
| 348 |
\tqft@val{offset}/2 : \tqft@val{offset} |
| 349 |
) : 0 |
| 350 |
) |
| 351 |
*\tqft@val{boundary separation} - \tqft@val{circle x radius}}% |
| 352 |
\pgfmathsetmacro\ypos{% |
| 353 |
( |
| 354 |
\tqft@val{outgoing boundary components} > 0 ? |
| 355 |
( |
| 356 |
\tqft@val{incoming boundary components} > 0 ? |
| 357 |
-\tqft@val{cobordism height}/2 : -1 + \tqft@val{cobordism height}/3 |
| 358 |
) : - \tqft@val{cobordism height}/3 |
| 359 |
)}% |
| 360 |
\xdef\tqft@gclip{% |
| 361 |
\tqft@gclip |
| 362 |
(\xpos pt,\ypos pt) |
| 363 |
}% |
| 364 |
\pgfmathsetmacro\gsize{% |
| 365 |
(( |
| 366 |
\tqft@val{outgoing boundary components} > 0 ? |
| 367 |
( |
| 368 |
\tqft@val{incoming boundary components} > 0 ? |
| 369 |
(\tqft@val{incoming boundary components} + \tqft@val{outgoing boundary components})/2 : \tqft@val{outgoing boundary components} |
| 370 |
) : \tqft@val{incoming boundary components} |
| 371 |
)-1) |
| 372 |
*\tqft@val{boundary separation}/\tqft@val{circle x radius} + 2}% |
| 373 |
\pgfmathsetmacro\gscale{min(1,\gsize/(3*\tqft@val{genus}+1))}% |
| 374 |
\pgfmathsetmacro\gyscale{\tqft@val{circle y radius}*\gscale*.707}% |
| 375 |
\pgfmathsetmacro\gxscale{\tqft@val{circle x radius}*\gscale}% |
| 376 |
\pgfmathsetmacro\gsep{((\gsize - 2*\tqft@val{genus}*\gscale)/(\tqft@val{genus} + 1)*\tqft@val{circle x radius}}% |
| 377 |
\xdef\tqft@gclip{% |
| 378 |
\tqft@gclip |
| 379 |
++(\gsep/2 pt,0) |
| 380 |
}% |
| 381 |
\pgfmathsetmacro\omrstwo{1 - 1/sqrt(2)}% |
| 382 |
\pgfmathsetmacro\sqrtwo{sqrt(2)}% |
| 383 |
\foreach[ |
| 384 |
evaluate=\k as \kmo using int(2 * \k-1) |
| 385 |
] \k in {1,...,\tqft@val{genus}} { |
| 386 |
\xdef\tqft@gclip{% |
| 387 |
\tqft@gclip |
| 388 |
++(\gsep/2 pt + \omrstwo*\gxscale pt,0) |
| 389 |
.. controls +(\gxscale*\sqrtwo/3 pt,4/3*\gyscale pt) and +(-\gxscale*\sqrtwo/3 pt,4/3*\gyscale pt) |
| 390 |
.. ++(\sqrtwo*\gxscale pt,0) |
| 391 |
.. controls +(-\gxscale*\sqrtwo/3 pt,-4/3*\gyscale pt) and +(\gxscale*\sqrtwo/3 pt,-4/3*\gyscale pt) |
| 392 |
.. ++(-\sqrtwo*\gxscale pt,0) |
| 393 |
++(2*\gxscale pt -\omrstwo*\gxscale pt + \gsep/2 pt,0) |
| 394 |
} |
| 395 |
\xdef\tqft@glist{% |
| 396 |
\tqft@glist,% |
| 397 |
hole \k/lower/{% |
| 398 |
(\xpos pt + \k * \gsep pt + \kmo * \gxscale pt + \gxscale pt -\omrstwo*\gxscale pt,\ypos pt) |
| 399 |
.. controls +(-\gxscale pt*\sqrtwo/3,\pgf@tqft@upper4/3*\gyscale pt) and +(\gxscale pt*\sqrtwo/3,\pgf@tqft@upper4/3*\gyscale pt) |
| 400 |
.. ++(-\sqrtwo*\gxscale pt,0)},% |
| 401 |
hole \k/upper/{(\xpos pt + \k * \gsep pt + \kmo * \gxscale pt - \gxscale pt,\ypos pt + \pgf@tqft@upper\gyscale pt)% |
| 402 |
.. controls +(\gxscale pt*2/3,\pgf@tqft@lower8/3*\gyscale pt) and +(-\gxscale pt*2/3,\pgf@tqft@lower8/3*\gyscale pt) |
| 403 |
.. ++(2*\gxscale pt,0)}% |
| 404 |
}% |
| 405 |
\xdef\tqft@clist{% |
| 406 |
\tqft@clist,-hole \k/{(\xpos pt + \k * \gsep pt + \kmo * \gxscale pt,\ypos pt)}% |
| 407 |
}% |
| 408 |
}% |
| 409 |
\fi |
| 410 |
\gdef\tqft@shift{(0,0)}% |
| 411 |
\edef\tqft@anchor{\tqft@val{anchor}}% |
| 412 |
\expandafter\pgfutil@in@\expandafter{\expandafter,\expandafter}\expandafter{\tqft@anchor}% |
| 413 |
\ifpgfutil@in@ |
| 414 |
\expandafter\tqft@split\tqft@anchor\relax |
| 415 |
\else |
| 416 |
\edef\tqft@anchor{-\tqft@val{anchor}}% |
| 417 |
\xdef\tqft@alist{\tqft@clist,\tqft@alist}% |
| 418 |
\foreach \anchor/\coord in \tqft@alist |
| 419 |
{ |
| 420 |
\ifx\anchor\tqft@anchor\relax |
| 421 |
\global\let\tqft@shift\coord |
| 422 |
\fi |
| 423 |
}% |
| 424 |
\fi |
| 425 |
\tikz@scan@one@point\pgfutil@firstofone\tqft@shift\relax |
| 426 |
\begin{scope}[shift={(-\pgf@x,-\pgf@y)}] |
| 427 |
\ifnum\tqft@val{incoming boundary components}>0\relax |
| 428 |
\ifx\tqft@ibdrylist\pgfutil@gobble |
| 429 |
\xdef\tqft@ibdrylist{1} |
| 430 |
\else |
| 431 |
\xdef\tqft@ibdrylist{1,\tqft@ibdrylist} |
| 432 |
\fi |
| 433 |
\foreach[evaluate=\k as \xpos using (\k-1)*\tqft@val{boundary separation}] \k in \tqft@ibdrylist { |
| 434 |
\node[ |
| 435 |
transform shape, |
| 436 |
node contents={}, |
| 437 |
ellipse, |
| 438 |
inner sep=0pt, |
| 439 |
outer sep=0pt, |
| 440 |
minimum width=2*\tqft@val{circle x radius}, |
| 441 |
minimum height=2*\tqft@val{circle y radius}, |
| 442 |
at={(\xpos pt,0)}, |
| 443 |
name=-incoming boundary \k, |
| 444 |
/tikz/tqft/every boundary component/.try, |
| 445 |
/tikz/tqft/every incoming boundary component/.try, |
| 446 |
/tikz/tqft/incoming boundary component \k/.try |
| 447 |
]; |
| 448 |
}% |
| 449 |
\ifx\tqft@cibdrylist\pgfutil@gobble |
| 450 |
\else |
| 451 |
\foreach[evaluate=\k as \xpos using (\k-1)*\tqft@val{boundary separation}] \k in \tqft@cibdrylist { |
| 452 |
\node[ |
| 453 |
transform shape, |
| 454 |
node contents={}, |
| 455 |
ellipse, |
| 456 |
inner sep=0pt, |
| 457 |
outer sep=0pt, |
| 458 |
minimum width=2*\tqft@val{circle x radius}, |
| 459 |
minimum height=2*\tqft@val{circle y radius}, |
| 460 |
at={(\xpos pt,0)}, |
| 461 |
name=-incoming boundary \k, |
| 462 |
/tikz/tqft/every skipped boundary component/.try, |
| 463 |
/tikz/tqft/every skipped incoming boundary component/.try, |
| 464 |
/tikz/tqft/skipped incoming boundary component \k/.try, |
| 465 |
]; |
| 466 |
}% |
| 467 |
\fi |
| 468 |
\path node also[pic alias=-incoming boundary] (-incoming boundary 1); |
| 469 |
\fi |
| 470 |
\ifnum\tqft@val{outgoing boundary components}>0\relax |
| 471 |
\ifx\tqft@obdrylist\pgfutil@gobble |
| 472 |
\xdef\tqft@obdrylist{1} |
| 473 |
\else |
| 474 |
\xdef\tqft@obdrylist{1,\tqft@obdrylist} |
| 475 |
\fi |
| 476 |
\foreach \k [evaluate=\k as \ok using int(\tqft@outgoing@end * (\tqft@val{outgoing boundary components} + 1) - \tqft@outgoing@dir * \k)] in \tqft@obdrylist { |
| 477 |
\xdef\tqft@robdrylist{\tqft@robdrylist,\ok} |
| 478 |
} |
| 479 |
\foreach[ |
| 480 |
evaluate=\k as \xpos using (\k-1+\tqft@val{offset})*\tqft@val{boundary separation} |
| 481 |
] \k in \tqft@robdrylist { |
| 482 |
\node[ |
| 483 |
transform shape, |
| 484 |
node contents={}, |
| 485 |
ellipse, |
| 486 |
inner sep=0pt, |
| 487 |
outer sep=0pt, |
| 488 |
minimum width=2*\tqft@val{circle x radius}, |
| 489 |
minimum height=2*\tqft@val{circle y radius}, |
| 490 |
at={(\xpos pt,-\tqft@val{cobordism height})}, |
| 491 |
name=-outgoing boundary \k, |
| 492 |
/tikz/tqft/every boundary component/.try, |
| 493 |
/tikz/tqft/every outgoing boundary component/.try, |
| 494 |
/tikz/tqft/outgoing boundary component \k/.try |
| 495 |
]; |
| 496 |
}% |
| 497 |
\ifx\tqft@cobdrylist\pgfutil@gobble |
| 498 |
\else |
| 499 |
\foreach \k[evaluate=\k as \ok using int(\tqft@outgoing@end * (\tqft@val{outgoing boundary components} + 1) - \tqft@outgoing@dir * \k)] |
| 500 |
in \tqft@cobdrylist { |
| 501 |
\xdef\tqft@rcobdrylist{\tqft@rcobdrylist,\ok} |
| 502 |
} |
| 503 |
\foreach[ |
| 504 |
evaluate=\k as \xpos using (\k-1+\tqft@val{offset})*\tqft@val{boundary separation} |
| 505 |
] \k in \tqft@rcobdrylist { |
| 506 |
\node[ |
| 507 |
transform shape, |
| 508 |
node contents={}, |
| 509 |
ellipse, |
| 510 |
inner sep=0pt, |
| 511 |
outer sep=0pt, |
| 512 |
minimum width=2*\tqft@val{circle x radius}, |
| 513 |
minimum height=2*\tqft@val{circle y radius}, |
| 514 |
at={(\xpos pt,-\tqft@val{cobordism height})}, |
| 515 |
name=-outgoing boundary \k, |
| 516 |
/tikz/tqft/every skipped boundary component/.try, |
| 517 |
/tikz/tqft/every skipped outgoing boundary component/.try, |
| 518 |
/tikz/tqft/skipped outgoing boundary component \k/.try |
| 519 |
]; |
| 520 |
}% |
| 521 |
\fi |
| 522 |
\path node also[pic alias=-outgoing boundary] (-outgoing boundary 1); |
| 523 |
\fi |
| 524 |
\ifnum\tqft@val{incoming boundary components}>0\relax |
| 525 |
\foreach[evaluate=\k as \xpos using (\k-1)*\tqft@val{boundary separation}] \k in \tqft@ibdrylist { |
| 526 |
\path[ |
| 527 |
/tikz/tqft/every lower boundary component/.try, |
| 528 |
/tikz/tqft/every incoming lower boundary component/.try, |
| 529 |
/tikz/tqft/incoming lower boundary component \k/.try |
| 530 |
] (\xpos pt - \tqft@val{circle x radius},0) arc[start angle=\pgf@tqft@lower180,end angle=0, x radius=\tqft@val{circle x radius}, y radius =\tqft@val{circle y radius}]; |
| 531 |
}% |
| 532 |
\fi |
| 533 |
\ifnum\tqft@val{outgoing boundary components}>0\relax |
| 534 |
\foreach[ |
| 535 |
evaluate=\k as \xpos using (\k-1+\tqft@val{offset})*\tqft@val{boundary separation} |
| 536 |
] \k in \tqft@robdrylist { |
| 537 |
\path[ |
| 538 |
/tikz/tqft/every lower boundary component/.try, |
| 539 |
/tikz/tqft/every outgoing lower boundary component/.try, |
| 540 |
/tikz/tqft/outgoing lower boundary component \k/.try |
| 541 |
] (\xpos pt - \tqft@val{circle x radius},-\tqft@val{cobordism height}) arc[start angle=\pgf@tqft@lower180,end angle=0, x radius=\tqft@val{circle x radius}, y radius =\tqft@val{circle y radius}]; |
| 542 |
}% |
| 543 |
\fi |
| 544 |
\begin{scope} |
| 545 |
\path[overlay,clip] \tqft@gclip; |
| 546 |
\path[ |
| 547 |
/tikz/tqft/cobordism/.try, |
| 548 |
pic actions, |
| 549 |
/tikz/tqft/cobordism outer path/.try, |
| 550 |
] \tqft@fullpath; |
| 551 |
\end{scope} |
| 552 |
\ifx\tqft@glist\pgfutil@gobble |
| 553 |
\else |
| 554 |
\foreach \tqft@gstyle/\tqft@gside/\tqft@gpath in \tqft@glist { |
| 555 |
\path[ |
| 556 |
/tikz/tqft/cobordism/.try, |
| 557 |
pic actions, |
| 558 |
fill=none, |
| 559 |
shade=none, |
| 560 |
/tikz/tqft/cobordism edge/.try, |
| 561 |
/tikz/tqft/genus style/.try, |
| 562 |
/tikz/tqft/genus \tqft@gside/.try, |
| 563 |
/tikz/tqft/\tqft@gstyle/.try, |
| 564 |
/tikz/tqft/\tqft@gstyle\space\tqft@gside/.try, |
| 565 |
] \tqft@gpath; |
| 566 |
} |
| 567 |
\fi |
| 568 |
\ifx\tqft@blist\pgfutil@gobble |
| 569 |
\else |
| 570 |
\foreach \tqft@bstyle/\tqft@btype/\tqft@bpath in \tqft@blist { |
| 571 |
\path[ |
| 572 |
/tikz/tqft/cobordism edge/.try, |
| 573 |
/tikz/tqft/cobordism outer edge/.try, |
| 574 |
/tikz/tqft/between \tqft@btype/.try, |
| 575 |
/tikz/tqft/\tqft@bstyle/.try, |
| 576 |
] \tqft@bpath; |
| 577 |
} |
| 578 |
\fi |
| 579 |
\ifx\tqft@clist\pgfutil@gobble |
| 580 |
\else |
| 581 |
\foreach \name/\coord in \tqft@clist { |
| 582 |
\path \coord node[coordinate,node contents={},name=\name]; |
| 583 |
} |
| 584 |
\fi |
| 585 |
\ifnum\tqft@val{incoming boundary components}>0\relax |
| 586 |
\foreach[evaluate=\k as \xpos using (\k-1)*\tqft@val{boundary separation}] \k in \tqft@ibdrylist { |
| 587 |
\path[ |
| 588 |
/tikz/tqft/every upper boundary component/.try, |
| 589 |
/tikz/tqft/every incoming upper boundary component/.try, |
| 590 |
/tikz/tqft/incoming upper boundary component \k/.try |
| 591 |
] (\xpos pt - \tqft@val{circle x radius},0) arc[start angle=\pgf@tqft@upper180,end angle=0, x radius=\tqft@val{circle x radius}, y radius =\tqft@val{circle y radius}]; |
| 592 |
} |
| 593 |
\fi |
| 594 |
\ifnum\tqft@val{outgoing boundary components}>0\relax |
| 595 |
\foreach[ |
| 596 |
evaluate=\k as \xpos using (\k-1+\tqft@val{offset})*\tqft@val{boundary separation} |
| 597 |
] \k in \tqft@robdrylist { |
| 598 |
\path[ |
| 599 |
/tikz/tqft/every upper boundary component/.try, |
| 600 |
/tikz/tqft/every outgoing upper boundary component/.try, |
| 601 |
/tikz/tqft/outgoing upper boundary component \k/.try |
| 602 |
] (\xpos pt - \tqft@val{circle x radius},-\tqft@val{cobordism height}) arc[start angle=\pgf@tqft@upper180,end angle=0, x radius=\tqft@val{circle x radius}, y radius =\tqft@val{circle y radius}]; |
| 603 |
} |
| 604 |
\fi |
| 605 |
\end{scope} |
| 606 |
} |
| 607 |
} |
| 608 |
|
| 609 |
%% |
| 610 |
%% Copyright (C) 2011-2024 by Andrew Stacey <[email protected]> |
| 611 |
%% |
| 612 |
%% This work may be distributed and/or modified under the |
| 613 |
%% conditions of the LaTeX Project Public License (LPPL), either |
| 614 |
%% version 1.3c of this license or (at your option) any later |
| 615 |
%% version. The latest version of this license is in the file: |
| 616 |
%% |
| 617 |
%% http://www.latex-project.org/lppl.txt |
| 618 |
%% |
| 619 |
%% This work is "maintained" (as per LPPL maintenance status) by |
| 620 |
%% Andrew Stacey. |
| 621 |
%% |
| 622 |
%% This work consists of the files tqft_code.dtx, |
| 623 |
%% tqft.tex, |
| 624 |
%% and the derived files tqft_code.ins, |
| 625 |
%% tqft_code.pdf, |
| 626 |
%% tqft.pdf, |
| 627 |
%% tqft.sty, and |
| 628 |
%% tikzlibrarytqft.code.tex. |
| 629 |
%% |
| 630 |
%% |
| 631 |
%% End of file `tikzlibrarytqft.code.tex'. |