Advertisement
Guest User

Untitled

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