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

%% 
%% Copyright (C) 2011 by Andrew Stacey <stacey@math.ntnu.no>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in the file:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%% Andrew Stacey.
%% 
%% This work consists of the files  tqft.dtx,
%%                                  tqft_doc.tex,
%% and the derived files            tqft.ins,
%%                                  tqft.pdf,
%%                                  tqft_doc.pdf,
%%                                  tqft.sty, and
%%                                  tikzlibrarytqft.code.tex.
%% 
%%
%% End of file `tikzlibrarytqft.code.tex'.