From c12e1348d0914fb7b830a01270caab9a64392f83 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 20 Mar 2013 21:37:35 +0000
Subject: pst-optexp (20mar13)

git-svn-id: svn://tug.org/texlive/trunk@29444 c570f23f-e606-0410-a88d-b1316a301751
---
 .../source/latex/pst-optexp/pst-optexp.dtx         | 556 +++++++++++++++------
 1 file changed, 416 insertions(+), 140 deletions(-)

(limited to 'Master/texmf-dist/source/latex/pst-optexp/pst-optexp.dtx')

diff --git a/Master/texmf-dist/source/latex/pst-optexp/pst-optexp.dtx b/Master/texmf-dist/source/latex/pst-optexp/pst-optexp.dtx
index 0c09624c4b1..89536791ff1 100644
--- a/Master/texmf-dist/source/latex/pst-optexp/pst-optexp.dtx
+++ b/Master/texmf-dist/source/latex/pst-optexp/pst-optexp.dtx
@@ -18,7 +18,7 @@
 %<stylefile>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<stylefile>\ProvidesPackage{pst-optexp}
 %<*stylefile>
-    [2013/02/22 v3.5 Optical experimental setups with PSTricks]
+    [2013/03/20 v3.6 Optical experimental setups with PSTricks]
 %</stylefile>
 %
 %<*driver>
@@ -118,20 +118,31 @@
     newOptexpDipole, newOptexpTripole, newOptexpFiberDipole,optplane}, %
   explpreset={%
     pos=l, width=-99pt, hsep=5mm, overhang=\codeoverhang, varwidth,
-    vsep=\bigskipamount, rframe={}}, extendedchars=true, }
+    vsep=\bigskipamount, rframe={}}, extendedchars=true
+}%
 \lstdefinestyle{example}{explpreset={%
     escapechar=*, pos=l, width=-99pt, hsep=5mm, overhang=\codeoverhang,
-    varwidth, vsep=\bigskipamount, rframe={}}} \makeatletter
+    varwidth, vsep=\bigskipamount, rframe={}}}
+\makeatletter
 \providecommand\ON{%
   \gdef\lst@alloverstyle##1{\textcolor{black!50}{\strut##1}%
-  }} \providecommand\OFF{\xdef\lst@alloverstyle##1{##1}} \makeatother
+}}
+\providecommand\OFF{\xdef\lst@alloverstyle##1{##1}}
+\makeatother
 \colorlet{sectioncolor}{DOrange}
 \addtokomafont{sectioning}{\color{sectioncolor}}
-\usepackage[automark,nouppercase]{scrpage2} \pagestyle{scrheadings}
-\clearscrheadings \clearscrplain \ohead{\pagemark} \ihead{\headmark}
-\ofoot[\pagemark]{} \automark[subsection]{section}
-\setheadsepline{.4pt}[\color{DOrange}] \setheadwidth[0pt]{text}
-\setfootwidth[0pt]{text} \makeatletter
+\usepackage[automark,nouppercase]{scrpage2}
+\pagestyle{scrheadings}
+\clearscrheadings
+\clearscrplain
+\ohead{\pagemark}
+\ihead{\headmark}
+\ofoot[\pagemark]{}
+\automark[subsection]{section}
+\setheadsepline{.4pt}[\color{DOrange}]
+\setheadwidth[0pt]{text}
+\setfootwidth[0pt]{text}
+\makeatletter
 \patchcmd{\l@chapter}{1.5em}{2em}{}{}
 \renewcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{3.0em}}
 \renewcommand*\l@subsection{\bprot@dottedtocline{2}{3.8em}{4.0em}}
@@ -139,11 +150,14 @@
 \def\ltd@fnurl#1#2{\footnote{#1\hyper@linkurl{\Hurl{#2}}{#2}}}
 \newrobustcmd*{\arxivurl}[1]{\href{http://arxiv.org/abs/#1}{arXiv:#1}}
 \newrobustcmd*{\doiurl}[1]{\href{http://dx.doi.org/#1}{DOI:#1}}
-\makeatother \usepackage{csquotes} \MakeAutoQuote{«}{»}
+\makeatother
+\usepackage{csquotes}
+\MakeAutoQuote{«}{»}
 %^^A spot is used in ltxdockit.sty
 \colorlet{spot}{sectioncolor}
 \newpsstyle{Refline}{linecolor=gray!70}
 \newpsstyle{CenterNode}{linecolor=blue, dotstyle=x, dotscale=1.5}
+\psset[optexp]{usefiberstyle}
 \colorlet{Refline}{gray!70}
 %^^A Fonts definitions used in ltxdockit.sty
 \renewcommand*{\verbatimfont}{\ttfamily}
@@ -464,7 +478,7 @@
 % \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\let,\if,\ifx,\else,\fi,\@ifnextchar}
 % \DoNotIndex{\space,\relax,\nr,\val,\ignorespaces,\ifdim,\ifcat,\@nil,\@none,\@empty}
 % \DoNotIndex{\PackageError,\PackageWarning,\advance,\csname,\endcsname,\bgroup,\egroup}
-% \DoNotIndex{\expandafter,\@@comp,\@postcode}
+% \DoNotIndex{\expandafter,\POE@comp,\@postcode}
 % \DoNotIndex{\psset}
 % \DoNotIndex{\@wd,\@sz,\@ht,\@yshift,\@step,\@xl,\@sep,\@r,\@dp,\@altan,\@extpostcode}
 % \DoNotIndex{\@f@cnt,\@f@r,\@f@sep,\@hshift,\@bs@wd,\@c@caxisL,\@cnt,\@pstfalse,\@psttrue}
@@ -2192,6 +2206,72 @@
 % \iffalse
 %</ignore>
 % \fi
+%
+% \numitem[0]{compoffset}
+% \ifGERMAN Verschiebt eine Komponente vertikal bezüglich ihrer
+% Referenzlinie (siehe \prettyref{sec:refnode}). Reflektierende
+% Komponenten werden entlang der reflektiven Grenzfläche verschoben. Die
+% Verschiebung erfolgt also senkrecht zu einer Verschiebung mit
+% \Lkeyword{compshift}. Ein Anwendungsbeispiel ist
+% \prettyref{ex:autocorrelation}.
+% \fi
+% \ifENGLISH
+% Shift a component perpendicular to its reference line (see
+% \prettyref{sec:refnode}). For reflective components it is shifted
+% along the reflective interface. The displacement is vertical to a
+% displacement with \Lkeyword{compshift}. For an example see
+% \prettyref{ex:autocorrelation}.
+% \fi
+% \iffalse
+%<*ignore>
+% \fi
+\begin{LTXexample}[linerange={1-3,9-9}, morekeywords={[21]{compshift}}]
+\begin{pspicture}(3,2)
+  \pnode(0,1){A}\pnode(2.7,1){B}
+  \lens[compoffset=0.3](A)(B){L}
+  \psline[style=Refline](\oenodeRefA{})(\oenodeRefB{})
+  \psdot(\oenodeRefA{})\uput[-90](\oenodeRefA{}){RefA}
+  \psdot(\oenodeRefB{})\uput[-90](\oenodeRefB{}){RefB}
+  \psdot[style=CenterNode](\oenodeIn{})
+  \psdot[style=CenterNode](\oenodeOut{})
+\end{pspicture}
+\end{LTXexample}
+\begin{LTXexample}[linerange={1-3,9-9}, morekeywords={[21]{compshift}}]
+\begin{pspicture}(3,2) 
+  \pnode(0,1){A}\pnode(2,0){B}
+  \mirror[compoffset=0.3](A)(2,1)(B){mirror}
+  \psline[style=Refline](\oenodeRefA{})(\oenodeRefB{}|\oenodeRefA{})(\oenodeRefB{})
+  \psdot(\oenodeRefA{})\uput[-90](\oenodeRefA{}){RefA}
+  \psdot(\oenodeRefB{})\uput[180](\oenodeRefB{}){RefB}
+  \psdot[style=CenterNode](\oenodeIn{})
+  \psdot[style=CenterNode](\oenodeOut{})
+\end{pspicture}
+\end{LTXexample}
+% \iffalse
+%</ignore>
+% \fi
+% \choitem{innercompalign}{rel, relative, abs, absolute}
+% \ifGERMAN Ist dieser Parameter auf \opt{absolute} gesetzt, so wird das
+% «Innere» einer Komponente nicht mitgedreht. Diese Option wird derzeit
+% nur von \Lcs{optfilter} verwendet.
+% \fi
+% \ifENGLISH If this parameter is set to \opt{absolute}, the «inner»
+% component part is not rotated with the component. At the moment, this
+% option is used only by \Lcs{optfilter}. 
+% \fi
+% \iffalse
+%<*ignore>
+% \fi
+\begin{LTXexample}
+\begin{pspicture}(3,2)
+\psset[optexp]{labelangle=-90, position=start}
+\optfilter[innercompalign=rel](0.5,1.2)(0.5,2){rel}
+\optfilter[innercompalign=abs](2.5,1.2)(2.5,2){abs}
+\end{pspicture}
+\end{LTXexample}
+% \iffalse
+%</ignore>
+% \fi
 % \end{optionlist}
 %
 %
@@ -3931,7 +4011,6 @@
 % werden anders ausgerichtet.
 % \fi
 %
-% \psset{usefiberstyle}
 % \begin{optionlist}
 %   \boolitem{usefiberstyle} 
 %   \ifGERMAN
@@ -4926,8 +5005,13 @@
 % \fi
 %
 % \numitem[0]{filterangle}
-% \ifGERMAN Dreht das «Innere» des Filters relativ zum seinem Rahmen.\fi
-% \ifENGLISH Rotates the «inner» part of the filter relativ to its frame.\fi
+% \ifGERMAN Dreht das «Innere» des Filters relativ zum seinem
+% Rahmen. Anstattdessen kann auch \Lkeyword{innercompalign} verwendet
+% werden.
+% \fi
+% \ifENGLISH Rotates the «inner» part of the filter relativ to its
+% frame. Alternatively \Lkeyword{innercompalign} can be used.
+% \fi
 % \iffalse
 %<*ignore>
 % \fi
@@ -6751,6 +6835,37 @@
 %</ignore>
 % \fi
 %
+% \numitem[0]{beampathskip}
+% \ifGERMAN
+% Überspringt \prm{num} Segmente am Anfang des Strahlengangs.
+% \fi
+% \ifENGLISH
+% Skip \prm{num} segments at the beginning of the beam path. 
+% \fi
+% \iffalse
+%<*ignore>
+% \fi
+\begin{LTXexample}[morekeywords = {[21]{beampathskip}}, pos=t]
+\begin{pspicture}(5,2)
+\pnode(0,1){A}\pnode(5,1){B}\pnode(2,0){C}
+\begin{optexp}
+  \glanthompson(A)(B)
+  \optplane(B)\optplane[angle=90](C)
+  \polarization[abspos=1, poltype=misc, linecolor=yellow!80!black](A)(B)
+  \drawbeam[beaminsidelast, linecolor=yellow!80!black](A){1}
+  \drawbeam[beampathskip=2](A){1-2}
+  \drawbeam[beampathskip=2, savebeam, linestyle=dashed, dash=2pt 2pt, linecolor=red,arrowscale=1.5, arrows=->](A){1}{3}
+\end{optexp}
+\nodexn{(\oenodeBeam{})-1.5(!\oeBeamVec{})}{D}
+\polarization[poltype=parallel, linecolor=red](D)(\oenodeBeam{})
+\polarization[abspos=4, poltype=perp, linecolor=green, dotscale=1.5](A)(B)
+\end{pspicture}
+\end{LTXexample}
+% \iffalse
+%</ignore>
+% \fi
+% \end{optionlist}
+%
 % \ifGERMAN\subsection{Interner Strahlengang}\fi
 % \ifENGLISH\subsection{Internal beam path}\fi
 %
@@ -6766,7 +6881,8 @@
 % werden, kann mit mehreren Parametern festgelegt werden. Die erste, letzte und
 % die übrigen Komponenten werden separat gehandhabt.
 % \fi
-% 
+%
+% \begin{optionlist}
 % \boolitem[true]{beaminside}
 % \ifGERMAN
 % Zeichnet den Strahlengang innerhalb aller Komponenten mit Ausnahme der
@@ -9529,6 +9645,39 @@
 \end{LTXexample}
 \endgroup
 
+\begingroup
+\captionsetup[lstlisting]{format=poecaption}
+\begin{LTXexample}[pos=t, caption={\ifGERMAN Angepasst von \fi\ifENGLISH Adapted from \fi\doiurl{10.1364/AOP.1.000308}, \ifGERMAN Abb. \fi\ifENGLISH Fig. \fi 8}, label={ex:autocorrelation}]
+\begin{pspicture}(5.7,2.8)
+\psset{mirrorwidth=0.7, bsstyle=plate, bssize=0.5, arrowinset=0, arrowscale=1.2}
+\newpsobject{splitterplate}{beamsplitter}{linewidth=2\pslinewidth, linecolor=gray!50}
+\pnode(2.3,0){In}\pnode([offset=0.5]In){STM1}
+\pnode([Xnodesep=-2]STM1){M1}\pnode([offset=1]M1){M2}
+\pnode([offset=2]STM1){M3}\pnode([Xnodesep=-1]M3){M4}
+\pnode(M4|M2){STM2}
+\splitterplate(In)(STM1)(M1)
+\mirror(STM1)(M1)(M2)
+\mirror(M1)(M2)(M3|M2)
+\mirror(STM1)(M3)(M4)
+\mirror[label=0.6 180 . absolute](M3)(M4)(STM2)
+\rput[r](\oenodeLabel{}){$\tau$
+  \psline[arrows=<->](0.15, 0.4)(0.15, -0.2)}
+\splitterplate[compoffset=0.2, compname=STM2](M4)(STM2)([Xnodesep=1]STM2)
+\pnode(\oenodeCenter{STM2}){STM2C}
+\pnode([Xnodesep=4]STM2C){Out}
+\lens[n=2](STM2C)(Out)
+\optbox[position=0.65, optboxsize=0.1 0.6](STM2C)(Out)
+\optplate[linestyle=none, position=0.75](STM2C)(Out)
+\pinhole[position=0.95, outerheight=0.6](STM2C)(Out)
+\optdetector[detsize=0.5 0.6](STM2C)(Out)
+\drawbeam[linecolor=blue]{8-}
+\newpsstyle{Beam}{ArrowInside=->, linecolor=red, ArrowInsideMinLength=1, arrows=>-}
+\drawbeam[ArrowInsidePos=0.835](In){1-3}{7-9}
+\drawbeam[ArrowInsidePos=0.74](In){1}{4-9}
+\end{pspicture}
+\end{LTXexample}
+\endgroup
+
 \begin{LTXexample}[pos=t, linerange={1-1}, caption={caption}]
 
 \psset{unit=1.1}
@@ -10500,17 +10649,25 @@
 %
 % \begin{changelog}
 %\patchcmd{\release}{\setlength{\itemsep}{0pt}}{\setlength{\itemsep}{0pt}\setlength{\parsep}{0pt}}{}{}
-%   ^^A Do not wrap lines inside the \items, otherwise Changes.py does not work properly
+%   \begin{release}{3.6}{2013-03-20}
+%   \item Added option \opt{compoffset}\see{prm:compoffset}
+%   \item Added option \opt{beampathskip}\see{prm:beampathskip}
+%   \item Added option \opt{innercompalign}\see{prm:innercompalign}
+%   \item Fixed some bugs in the raytracing and beam code.
+%   \end{release}
 %   \begin{release}{3.5}{2013-02-22}
 %   \item Added option \opt{filterangle}\see{prm:filterangle}
 %   \item Fixed wrong output fiber style in \cs{optcoupler}
-%   \item Fixed strange Postscript error which occured with some interpreters.
+%   \item Fixed strange Postscript error which occured with some
+%     interpreters.
 %   \end{release}
 %   \begin{release}{3.4}{2013-02-03}
 %   \item Fixed bugs when using \opt{fillstyle} for some components
 %   \item Extended option \opt{switchsize}\see{cmd:optswitch}
-%   \item Modified coupler center node to be on the base line\see{sec:centernode}
-%   \item Extended error checking for \cs{drawbeam} and \cs{drawfiber}\see{sec:accessobj}
+%   \item Modified coupler center node to be on the base
+%     line\see{sec:centernode}
+%   \item Extended error checking for \cs{drawbeam} and
+%     \cs{drawfiber}\see{sec:accessobj}
 %   \item Fixed some bugs in the connection code
 %   \end{release}
 %   \begin{release}{3.3a}{2012-09-18}
@@ -10519,46 +10676,66 @@
 %   \end{release}
 %   \begin{release}{3.3}{2012-08-17}
 %   \item Extended \cs{opttripole} and \cs{optdipole}\see{cmd:optdipole}
-%   \item Modified reference angle for label of \cs{opttripole}\see{sec:bwd-comp-3.3}
-%   \item Added option \opt{optdipolesize} to support two interfaces for \cs{optdipole}\see{prm:optdipolesize}
+%   \item Modified reference angle for label of
+%     \cs{opttripole}\see{sec:bwd-comp-3.3}
+%   \item Added option \opt{optdipolesize} to support two interfaces for
+%     \cs{optdipole}\see{prm:optdipolesize}
 %   \item Added option \opt{gratingalign}\see{prm:gratingalign}
 %   \item Added option \opt{forcebeaminside}\see{prm:forcebeaminside}
 %   \item Extended option \opt{mirrorradius}\see{prm:mirrorradius}
-%   \item Improved \cs{drawbeam} and \cs{drawwidebeam} to be able to use \opt{ArrowInside} without linestyle\see{prm:ArrowInsideMaxLength}
-%   \item Fixed orientation of \cs{oenodeBeamUp} and \cs{oenodeBeamLow}\see{cmd:oenodeBeamUp}
-%   \item Fixed a bug related to \opt{beaminside} and ambiguous components.
+%   \item Improved \cs{drawbeam} and \cs{drawwidebeam} to be able to use
+%     \opt{ArrowInside} without linestyle\see{prm:ArrowInsideMaxLength}
+%   \item Fixed orientation of \cs{oenodeBeamUp} and
+%     \cs{oenodeBeamLow}\see{cmd:oenodeBeamUp}
+%   \item Fixed a bug related to \opt{beaminside} and ambiguous
+%     components.
 %   \item Fixed some trailing spaces
 %   \item Added more examples\see{sec:examples}
 %   \end{release}
 %   \begin{release}{3.2}{2012-07-26}
 %   \item Added component \cs{glanthompson}\see{cmd:glanthompson}
-%   \item Added access to beam vectors with \cs{oeBeamVec}, \cs{oeBeamVecUp} and \cs{oeBeamVecLow}\see{cmd:oeBeamVec}
+%   \item Added access to beam vectors with \cs{oeBeamVec},
+%     \cs{oeBeamVecUp} and \cs{oeBeamVecLow}\see{cmd:oeBeamVec}
 %   \item Fixed wrong computation of node distance in \cs{fiberbox}
-%   \item Fixed bug in \cs{wdmsplitter} for \opt{coupleralign=b} and \opt{couplertype=none}
-%   \item Fixed bug when filling components placed with \opt{position=end}/\opt{start}
-%   \item Added value \opt{absolute} to parameter \opt{labelref}\see{prm:labelref}
+%   \item Fixed bug in \cs{wdmsplitter} for \opt{coupleralign=b} and
+%     \opt{couplertype=none}
+%   \item Fixed bug when filling components placed with
+%     \opt{position=end}/\opt{start}
+%   \item Added value \opt{absolute} to parameter
+%     \opt{labelref}\see{prm:labelref}
 %   \item Added examples\see{sec:examples}
 %   \end{release}
 %   \begin{release}{3.1}{2012-07-17}
 %   \item Added component \cs{fiberbox}\see{cmd:fiberbox}
-%   \item Extended connection macros to not required curly braces around node parenthesis any more\see{sec:namingobj}
-%   \item Modified \cs{fibercollimator} to have \opt{allowbeaminside=false} by default\see{cmd:fibercollimator}
-%   \item Extended fiber couplers to allow using only two nodes\see{sec:coupler}
+%   \item Extended connection macros to not required curly braces around
+%     node parenthesis any more\see{sec:namingobj}
+%   \item Modified \cs{fibercollimator} to have
+%     \opt{allowbeaminside=false} by default\see{cmd:fibercollimator}
+%   \item Extended fiber couplers to allow using only two
+%     nodes\see{sec:coupler}
 %   \item Fixed a bug concerning node expressions with \cs{drawfiber}
 %   \end{release}
 %   \begin{release}{3.0}{2012-07-09}
-%   \item Modified beam connections with \cs{drawbeam} to support raytracing\see{cmd:drawbeam}
+%   \item Modified beam connections with \cs{drawbeam} to support
+%     raytracing\see{cmd:drawbeam}
 %   \item Added wide beams with \cs{drawwidebeam}\see{cmd:drawwidebeam}
 %   \item Added \cs{drawfiber} for fiber connections\see{cmd:drawfiber}
-%   \item Added \opt{optexp} environment for layering of components and connections\see{sec:layers}
+%   \item Added \opt{optexp} environment for layering of components and
+%     connections\see{sec:layers}
 %   \item Added german documentation
 %   \item Modified naming of component nodes\see{sec:objnodes}
-%   \item Modified \opt{extnode} to work with more components\see{prm:extnode}
-%   \item Modified \opt{angle} and \opt{rotateref} to affect all components\see{sec:rotshift}
-%   \item Modified \opt{endbox} to affect all components\see{sec:positioning}
-%   \item Extended \opt{position} by values \opt{start} and \opt{end}\see{sec:positioning}
-%   \item Extended \opt{abspos} by values \opt{start} and \opt{end}\see{sec:positioning}
-%   \item Removed deprecated lens code which used \opt{lenswidth} and \opt{lensheight} for construction\see{cmd:lens}
+%   \item Modified \opt{extnode} to work with more
+%     components\see{prm:extnode}
+%   \item Modified \opt{angle} and \opt{rotateref} to affect all
+%     components\see{sec:rotshift}
+%   \item Modified \opt{endbox} to affect all
+%     components\see{sec:positioning}
+%   \item Extended \opt{position} by values \opt{start} and
+%     \opt{end}\see{sec:positioning}
+%   \item Extended \opt{abspos} by values \opt{start} and
+%     \opt{end}\see{sec:positioning}
+%   \item Removed deprecated lens code which used \opt{lenswidth} and
+%     \opt{lensheight} for construction\see{cmd:lens}
 %   \item Added option \opt{platesize}\see{prm:platesize}
 %   \item Added option \opt{phwidth}\see{cmd:pinhole}
 %   \item Modified option \opt{caxislength}\see{cmd:crystal}
@@ -10568,7 +10745,8 @@
 %   \item Added option \opt{optboxsize}\see{cmd:optbox}
 %   \item Extended option \opt{detsize}\see{cmd:optdetector}
 %   \item Added style \opt{DetectorStyle}\see{cmd:optdetector}
-%   \item Removed deprecated \cs{detector}, use \cs{optdetector}\see{cmd:optdetector}
+%   \item Removed deprecated \cs{detector}, use
+%     \cs{optdetector}\see{cmd:optdetector}
 %   \item Extended option \opt{doveprismsize}\see{cmd:doveprism}
 %   \item Added style \opt{Polarization}\see{cmd:polarization}
 %   \item Deprecated option \opt{pollinewidth}\see{cmd:polarization}
@@ -10577,14 +10755,21 @@
 %   \item Added style \opt{VariableStyle}\see{cmd:mirror}
 %   \item Added mirror type \opt{semitrans}\see{prm:mirrortype}
 %   \item Renamed \cs{optgrid} to \cs{optgrating}\see{cmd:optgrating}
-%   \item Renamed \opt{optgridwidth} to \opt{gratingwidth}\see{cmd:optgrating}
-%   \item Renamed \opt{optgridheight} to \opt{gratingheight}\see{cmd:optgrating}
-%   \item Renamed \opt{optgriddepth} to \opt{gratingdepth}\see{cmd:optgrating}
-%   \item Renamed \opt{optgridcount} to \opt{gratingcount}\see{cmd:optgrating}
-%   \item Renamed \opt{optgridtype} to \opt{gratingtype}\see{cmd:optgrating}
-%   \item Renamed \opt{optgridlinewidth} to \opt{gratinglinewidth}\see{cmd:optgrating}
+%   \item Renamed \opt{optgridwidth} to
+%     \opt{gratingwidth}\see{cmd:optgrating}
+%   \item Renamed \opt{optgridheight} to
+%     \opt{gratingheight}\see{cmd:optgrating}
+%   \item Renamed \opt{optgriddepth} to
+%     \opt{gratingdepth}\see{cmd:optgrating}
+%   \item Renamed \opt{optgridcount} to
+%     \opt{gratingcount}\see{cmd:optgrating}
+%   \item Renamed \opt{optgridtype} to
+%     \opt{gratingtype}\see{cmd:optgrating}
+%   \item Renamed \opt{optgridlinewidth} to
+%     \opt{gratinglinewidth}\see{cmd:optgrating}
 %   \item Added option \opt{prismalign}\see{cmd:optprism}
-%   \item Modified faulty alignment of \cs{rightangleprism}\see{cmd:rightangleprism}
+%   \item Modified faulty alignment of
+%     \cs{rightangleprism}\see{cmd:rightangleprism}
 %   \item Extended option \opt{optampsize}\see{cmd:optamp}
 %   \item Extended option \opt{optmzmsize}\see{cmd:optmzm}
 %   \item Added option \opt{polcontroltype}\see{cmd:polcontrol}
@@ -10596,7 +10781,8 @@
 %   \item Added component \cs{optcirculator}\see{cmd:optcirculator}
 %   \item Extended option \opt{couplersize}\see{cmd:optcoupler}
 %   \item Extended option \opt{couplertype}\see{cmd:optcoupler}
-%   \item Renamed option \opt{align} to \opt{coupleralign}\see{cmd:optcoupler}
+%   \item Renamed option \opt{align} to
+%     \opt{coupleralign}\see{cmd:optcoupler}
 %   \item Added style \opt{VariableCoupler}\see{cmd:optcoupler}
 %   \item Added style \opt{FilterStyle}\see{cmd:optfilter}
 %   \item Extended option \opt{fibercolsize}\see{cmd:fibercollimator}
@@ -10604,44 +10790,55 @@
 %   \item Removed deprecated option \opt{iwidth}\see{cmd:pinhole}
 %   \item Removed deprecated option \opt{owidth}\see{cmd:pinhole}
 %   \item Removed deprecated option \opt{bswidth}\see{cmd:beamsplitter}
-%   \item Deprecated \cs{newOptexpDipoleNolabel}, use \cs{newOptexpDipole}\see{sec:newobj}
-%   \item Deprecated option \opt{refractiveindex}\see{prm:refractiveindex}
+%   \item Deprecated \cs{newOptexpDipoleNolabel}, use
+%     \cs{newOptexpDipole}\see{sec:newobj}
+%   \item Deprecated option
+%     \opt{refractiveindex}\see{prm:refractiveindex}
 %   \item Deprecated option \opt{conn}\see{sec:drawbeam}
 %   \item Extended option \opt{fiber}\see{prm:fiber}
 %   \end{release}
 %   \begin{release}{2.1}{2009-11-05}
-%   \item Added component \cs{optfiberpolarizer}\see{cmd:optfiberpolarizer}
+%   \item Added component
+%     \cs{optfiberpolarizer}\see{cmd:optfiberpolarizer}
 %   \item Added option \opt{compshift}\see{prm:compshift}
 %   \item Added option \opt{label}\see{prm:label}
 %   \item Added option \opt{connjoin}
-%   \item Added options \opt{addtoBeam} and \opt{newBeam}\see{sec:drawbeam}
-%   \item Added style \opt{OptComp} and related options \opt{addtoOptComp} and \opt{newOptComp}\see{sec:appearance}
+%   \item Added options \opt{addtoBeam} and
+%     \opt{newBeam}\see{sec:drawbeam}
+%   \item Added style \opt{OptComp} and related options
+%     \opt{addtoOptComp} and \opt{newOptComp}\see{sec:appearance}
 %   \item Added option \opt{bsstyle}\see{cmd:beamsplitter}
-%   \item Extended \cs{fibercollimator} to use up to four reference nodes\see{cmd:fibercollimator}
-%   \item Improved \opt{thicklens} to work also with plain lenses\see{prm:thicklens}
+%   \item Extended \cs{fibercollimator} to use up to four reference
+%     nodes\see{cmd:fibercollimator}
+%   \item Improved \opt{thicklens} to work also with plain
+%     lenses\see{prm:thicklens}
 %   \item Use pst-doc class for the documentation
 %   \end{release}
 %
 %   \begin{release}{2.0}{2008-07-27}
-%     \item Added fiber-optical components\see{chap:fibercomp}
-%     \item Added component \cs{optdiode}\see{cmd:optdiode}
-%     \item Added component \cs{pentaprism}\see{cmd:pentaprism}
-%     \item Added component \cs{rightangleprism}\see{cmd:rightangleprism}
-%     \item Added component \cs{doveprism}\see{cmd:doveprism}
-%     \item Added component \cs{optprism}\see{cmd:optprism}
-%     \item Added \cs{drawbeam}\see{sec:drawbeam}
-%     \item Added component connections (options \opt{fiber}, \opt{conn} and \opt{beam})\see{chap:connecting}
-%     \item Added option \opt{compname}\see{prm:compname}
-%     \item Added option \opt{extnode}\see{prm:extnode}
-%     \item Renamed \cs{detector} to \cs{optdetector}\see{cmd:optdetector}
+%   \item Added fiber-optical components\see{chap:fibercomp}
+%   \item Added component \cs{optdiode}\see{cmd:optdiode}
+%   \item Added component \cs{pentaprism}\see{cmd:pentaprism}
+%   \item Added component \cs{rightangleprism}\see{cmd:rightangleprism}
+%   \item Added component \cs{doveprism}\see{cmd:doveprism}
+%   \item Added component \cs{optprism}\see{cmd:optprism}
+%   \item Added \cs{drawbeam}\see{sec:drawbeam}
+%   \item Added component connections (options \opt{fiber}, \opt{conn}
+%     and \opt{beam})\see{chap:connecting}
+%   \item Added option \opt{compname}\see{prm:compname}
+%   \item Added option \opt{extnode}\see{prm:extnode}
+%   \item Renamed \cs{detector} to \cs{optdetector}\see{cmd:optdetector}
 %   \end{release}
 %   \begin{release}{1.2}{2008-06-17}
 %   \item Modified lens design to use interface curvatures\see{cmd:lens}
-%   \item Added options \opt{lensradiusleft} and \opt{lensradiusright}\see{cmd:lens}
+%   \item Added options \opt{lensradiusleft} and
+%     \opt{lensradiusright}\see{cmd:lens}
 %   \item Added option \opt{thicklens}\see{cmd:lens}
 %   \item Added option \opt{lenstype}\see{cmd:lens}
-%   \item Added option \opt{mirrorradius} (curved mirrors)\see{cmd:mirror}
-%   \item Added option \opt{optgridtype} (binary gratings)\see{cmd:optgrating}
+%   \item Added option \opt{mirrorradius} (curved
+%     mirrors)\see{cmd:mirror}
+%   \item Added option \opt{optgridtype} (binary
+%     gratings)\see{cmd:optgrating}
 %   \item Added \cs{newOptexpDipole}\see{sec:newobj}
 %   \item Added \cs{newOptexpDipoleNolabel}\see{sec:newobj}
 %   \item Added \cs{newOptexpTripole}\see{sec:newobj}
@@ -10651,8 +10848,10 @@
 %   \begin{release}{1.1}{2007-09-06}
 %   \item Improved labeling features\see{sec:labels}
 %   \item Added parameter \opt{labelref}\see{sec:labels}
-%   \item Replaced \opt{labelrelative} by \opt{labelref=relative}\see{sec:labels}
-%   \item Renamed \cs{polarisation} to \cs{polarization}\see{cmd:polarization}
+%   \item Replaced \opt{labelrelative} by
+%     \opt{labelref=relative}\see{sec:labels}
+%   \item Renamed \cs{polarisation} to
+%     \cs{polarization}\see{cmd:polarization}
 %   \item Renamed \opt{polwidth} to \opt{polsize}\see{cmd:polarization}
 %   \item Renamed \opt{pol} to \opt{poltype}\see{cmd:polarization}
 %   \item Renamed \opt{bswidth} to \opt{bssize}\see{cmd:beamsplitter}
@@ -10943,30 +11142,55 @@
 %    \end{macrocode}
 % The positioning parameters.
 %    \begin{macrocode}
+\define@boolkey[psset]{optexp}[POE@]{endbox}[true]{}
+\define@boolkey[psset]{optexp}[POE@]{startbox}[true]{}
 \define@choicekey*+[psset]{optexp}{position}[\val\nr]{start,end}{%
   \ifcase\nr\relax
     \psset[optexp]{startbox, endbox=false}%
   \or
     \psset[optexp]{startbox=false, endbox=true}%
   \fi
-}{\edef\POE@key@position{#1}}%
+}{%
+  \psset[optexp]{startbox=false, endbox=false}%
+  \edef\POE@key@position{#1}%
+}%
 \define@choicekey*+[psset]{optexp}{abspos}[\val\nr]{start,end}{%
   \ifcase\nr\relax
     \psset[optexp]{startbox, endbox=false}%
   \or
     \psset[optexp]{startbox=false, endbox=true}%
   \fi
-}{\edef\POE@key@abspos{#1}}%
+}{%
+  \psset[optexp]{startbox=false, endbox=false}%
+  \edef\POE@key@abspos{#1}%
+}%
 \define@key[psset]{optexp}{compshift}{%
   \pst@checknum{#1}\POE@key@compshift
 }
 \define@key[psset]{optexp}{angle}{%
   \pst@checknum{#1}\POE@key@angle
 }
+\define@key[psset]{optexp}{compoffset}{%
+  \pst@checknum{#1}\POE@key@compoffset
+}
+\define@choicekey+[psset]{optexp}{innercompalign}%
+  [\val\nr]{rel,abs,relative,absolute}%
+  {%
+    \ifcase\nr\relax
+      \let\POE@key@innercompalign\POE@str@relative
+    \or
+      \let\POE@key@innercompalign\POE@str@absolute
+    \else
+      \def\POE@key@innercompalign{#1}%
+    \fi
+  }%
+  {\PackageError{pst-optexp}{Unknown value '\val' for innercompalign}}%
 \psset[optexp]{%
   position={},
   abspos={},
   compshift=0,
+  compoffset=0,
+  innercompalign=relative,
   angle=0
 }%
 %    \end{macrocode}
@@ -11339,8 +11563,6 @@
   \fi
   \psset[optexp]{optboxwidth=#1, optboxheight=#2}%
 }%
-\define@boolkey[psset]{optexp}[POE@]{endbox}[true]{}
-\define@boolkey[psset]{optexp}[POE@]{startbox}[true]{}
 \psset[optexp]{%
   optboxwidth=1.4,
   optboxheight=0.8
@@ -12069,8 +12291,8 @@
 \define@boolkey[psset]{optexp}[POE@]{forcebeaminside}[true]{}%
 \define@boolkey[psset]{optexp}[POE@]{raytrace}[true]{}%
 \define@boolkey[psset]{optexp}[POE@]{useNA}[true]{}%
-\define@key[psset]{optexp}{skipconn}{%
-  \pst@checknum{#1}\POE@key@skipconn
+\define@key[psset]{optexp}{beampathskip}{%
+  \pst@checknum{#1}\POE@key@beampathskip
 }%
 \define@choicekey+[psset]{optexp}{beamalign}%
   [\val\nr]{rel,abs,relative,absolute}%
@@ -12110,7 +12332,7 @@
   ,beamwidth=0
   ,beamdiv=0
   ,n=1.5
-  ,skipconn=0
+  ,beampathskip=0
   ,ArrowInsideMinLength=0.2
   ,ArrowInsideMaxLength=-1
 }%
@@ -12507,7 +12729,7 @@
        \else 
          relative
        \fi def
-     /skipconn \POE@key@skipconn\space def
+     /beampathskip \POE@key@beampathskip\space def
      /useNA \ifPOE@useNA true \else false \fi def
   }%
 }%
@@ -12975,7 +13197,7 @@
     \fi
     \POE@getlastcomp#2%
     \ifnum\POE@firstcomp>\the\POE@cnt
-      \ifnum\POE@lastcomp>\the\POE@cnt
+      \ifnum\POE@lastcomp>\the\POE@cnt\relax
         \PackageError{pst-optexp}%
           {All components \POE@firstcomp-\POE@lastcomp\space out of range}%
       \fi
@@ -13003,14 +13225,13 @@
   \fi
 }%
 \def\POE@getlastcomp#1-{%
-  \ifx\\#1\\%
+  \ifx\@empty#1\relax
+    \ifnum\POE@firstcomp>\the\POE@cnt\relax
+      \PackageError{pst-optexp}{All components \POE@firstcomp- out of range.}%
+    \fi
     \edef\POE@lastcomp{\the\POE@cnt}%
   \else
-    \ifx\@empty#1\relax
-      \edef\POE@lastcomp{\the\POE@cnt}%
-    \else
-      \edef\POE@lastcomp{#1}%
-    \fi
+    \edef\POE@lastcomp{#1}%
   \fi
 }%
 %    \end{macrocode}
@@ -13525,15 +13746,15 @@
 % \end{macro}
 %
 %    \begin{macrocode}
-\def\oe@BeamVec#1#2{%
+\def\POE@beamvec#1#2{%
   \POE@dict{%
     /prevVec#1\ifx\\#2\\1\else#2\fi\space dup
     currentdict exch known { load exec }{ pop 0 0 } ifelse
   }%
 }%
-\def\oeBeamVec#1{\oe@BeamVec{}{#1}}%
-\def\oeBeamVecUp#1{\oe@BeamVec{Up}{#1}}%
-\def\oeBeamVecLow#1{\oe@BeamVec{Low}{#1}}%
+\def\oeBeamVec#1{\POE@beamvec{}{#1}}%
+\def\oeBeamVecUp#1{\POE@beamvec{Up}{#1}}%
+\def\oeBeamVecLow#1{\POE@beamvec{Low}{#1}}%
 %    \end{macrocode}
 % \section{Components}
 %
@@ -13696,7 +13917,7 @@
 % is done by \opt{abspos} or \opt{position}
 %    \begin{macrocode}
     \let\POE@key@comp@Yshift\POE@key@compshift%
-    \def\POE@key@comp@Xshift{0}%
+    \let\POE@key@comp@Xshift\POE@key@compoffset%
     \edef\POE@refnodeA{\oenodeRefA{}}%
     \edef\POE@refnodeB{\oenodeRefB{}}%
     \edef\POE@trefnodeA{\oenodeTrefA{}}%
@@ -13723,7 +13944,7 @@
 % for multipoles the default shifting is in $x$-direction
 %    \begin{macrocode}
   \def\POE@key@comp@Xshift{\POE@key@compshift\space neg }%
-  \def\POE@key@comp@Yshift{0}%
+  \let\POE@key@comp@Yshift\POE@key@compoffset
 %    \end{macrocode}
 % The positioning parameters are disabled, because \opt{compshift} does the job for tripoles.
 %    \begin{macrocode}
@@ -13792,8 +14013,8 @@
 % \end{macro}
 %
 %    \begin{macrocode}
-\def\getCLWH{CLW \pst@number\psxunit 2 mul div }%
-\def\getCLW{CLW \pst@number\psxunit div }%
+\def\POE@clwh{CLW \pst@number\psxunit 2 mul div }%
+\def\POE@clw{CLW \pst@number\psxunit div }%
 \let\POE@restorerefnodes\relax
 %    \end{macrocode}
 % 
@@ -14764,7 +14985,7 @@
     {\POE@drawcomponent@i}{\POE@drawcomponent@i[]}%
 }%
 \def\POE@drawcomponent@i[#1]#2#3{%
-  \def\@@comp{%
+  \def\POE@comp{%
     #3%
     \ifx\POE@key@extnode\@empty\else
       \ifPOE@backlayer
@@ -14787,6 +15008,7 @@
   \ifx\\#1\\\else
     \@ifundefined{#1@ref}{}{\@nameuse{#1@ref}}%
   \fi
+  \begingroup
   \ifPOE@endbox
     \psset[optexp]{abspos={%
       \POE@dict{%
@@ -14804,7 +15026,6 @@
 %    \end{macrocode}
 % Positioning of the component
 %    \begin{macrocode}
-  \begingroup
     \psset{style=OptComp}%
 %    \end{macrocode}
 % linestyle to use, if component should be marked as optional
@@ -14820,13 +15041,13 @@
 % Then check if absolute positioning with \opt{abspos} is wanted.
 %    \begin{macrocode}
       \ifx\POE@key@position\@empty
-        \ncput[nrot=:U,npos=]{\POE@putcomp{\@@comp}}%
+        \ncput[nrot=:U,npos=]{\POE@putcomp{\POE@comp}}%
       \else
-        \ncput[nrot=:U,npos=\POE@key@position]{\POE@putcomp{\@@comp}}%
+        \ncput[nrot=:U,npos=\POE@key@position]{\POE@putcomp{\POE@comp}}%
       \fi
     \else
       \POE@nlput[nrot=:U](\POE@refnodeA)(\POE@refnodeB)%
-        {\POE@key@abspos}{\POE@putcomp{\@@comp}}%
+        {\POE@key@abspos}{\POE@putcomp{\POE@comp}}%
     \fi
   \endgroup
   \ifPOE@backlayer
@@ -15114,7 +15335,7 @@
         (! \@ht neg 0)(! \@ht 0)
     \else
       \psline[linewidth=\POE@key@mirrorlinewidth]%
-        (! \@ht neg \getCLWH)(! \@ht \getCLWH)
+        (! \@ht neg \POE@clwh)(! \@ht \POE@clwh)
     \fi
   \else
 %    \end{macrocode}
@@ -15693,8 +15914,8 @@
       \pspolygon(! \@sz -0.2 mul \@sz -0.4 mul)%
                 (! \@sz 0.6 mul \@sz -0.4 mul)%
                 (! \@sz 0.2 mul \@sz 0.4 mul)%
-      \psline(! \@sz -0.2 mul \@sz 0.4 mul \getCLWH add)%
-             (! \@sz 0.6 mul \@sz 0.4 mul \getCLWH add)
+      \psline(! \@sz -0.2 mul \@sz 0.4 mul \POE@clwh add)%
+             (! \@sz 0.6 mul \@sz 0.4 mul \POE@clwh add)
       \psset{arrows=->, arrowinset=0, arrowscale=0.8}%
       \psline(! \@sz -0.8 mul \@sz 0.3 mul)%
              (! \@sz -0.3 mul \@sz 0.15 mul)%
@@ -15749,8 +15970,8 @@
    \pspolygon(! \@sz -0.2 mul \@sz -0.2 mul)
              (! \@sz -0.2 mul \@sz 0.2 mul)
              (! \@sz 0.2 mul 0)
-   \psline(! \@sz 0.2 mul \getCLWH add \@sz 0.2 mul)%
-          (! \@sz 0.2 mul \getCLWH add \@sz -0.2 mul)
+   \psline(! \@sz 0.2 mul \POE@clwh add \@sz 0.2 mul)%
+          (! \@sz 0.2 mul \POE@clwh add \@sz -0.2 mul)
 \ignorespaces}%
 %    \end{macrocode}
 % \end{macro}
@@ -15892,7 +16113,11 @@
   \edef\@ang{\POE@key@prismangle\space 0.5 mul\space}%
   \edef\@hshift{%
     \ifx\POE@key@prismalign\POE@str@auto
-      \@sz 0.6 mul \@ang tan mul \POE@dict{OEangle} 0.5 mul tan div 
+      \POE@dict{OEangle} 1e-5 lt {
+        0
+      } {
+        \@sz 0.6 mul \@ang tan mul \POE@dict{OEangle} 0.5 mul tan div 
+      } ifelse
     \else
       0
     \fi
@@ -15917,7 +16142,11 @@
   \edef\@altan{\POE@key@prismangle\space 0.5 mul tan }%
   \edef\@hshift{%
     \ifx\POE@key@prismalign\POE@str@auto
-      \@sz 0.6 mul \@altan mul \POE@dict{OEangle} 0.5 mul tan div 
+      \POE@dict{OEangle} 1e-5 lt {
+        0
+       } {
+        \@sz 0.6 mul \@altan mul \POE@dict{OEangle} 0.5 mul tan div 
+       } ifelse
     \else
       0
     \fi
@@ -16053,9 +16282,17 @@
 %
 % \begin{macro}{\optfilter@ref}
 %    \begin{macrocode}
-\def\optfilter@ref{%
-  \POE@setref{\POE@key@filtersize\space 0.5 mul dup /@@y ED /@@x ED }%
-}%
+ \def\optfilter@ref{%
+  \POE@setref{%
+    \POE@key@filtersize\space 0.5 mul dup /@@y ED /@@x ED 
+    /@@ang 
+    \ifx\POE@key@innercompalign\POE@str@absolute
+      /N@\oenodeRefA{} /N@\oenodeRefB{} SlopeAngle \POE@key@angle sub
+    \else
+      \POE@key@filterangle
+    \fi def
+  }%
+ }%
 \let\optfilter@nodes\dipole@nodes
 %    \end{macrocode}
 % \end{macro}
@@ -16070,7 +16307,7 @@
       90 add cos 0.2 \@sz mul mul}%
   }%
   \psframe[dimen=outer](! \@sz neg dup)(! \@sz dup)
-  \psrotate(\oenodeCenter{}){\POE@key@filterangle}{%
+  \psrotate(\oenodeCenter{}){!\POE@dict{@@ang}}{%
   \psset{style=FilterStyle}%
     \ifx\POE@key@filtertype\POE@str@filtertype@bandpass
       \psline(! -0.3 \@sz mul -0.65 \@sz mul)%
@@ -16275,7 +16512,7 @@
 %    \end{macrocode}
 % storing the linewidth of the object allows for some aesthetic fine tuning 
 %    \begin{macrocode}
-  \pstVerb{tx@Dict begin /@lw \getCLW def end}%
+  \pstVerb{tx@Dict begin /@lw \POE@clw def end}%
   \bgroup
     \ifPOE@usefiberstyle
       \psset{style=Fiber, arrows=-, ArrowInside=-}
@@ -16644,8 +16881,8 @@
 \def\fibercollimator@comp{%
   \def\@wd{\POE@key@fibercolwidth\space 0.5 mul }%
   \def\@ht{\POE@key@fibercolheight\space 0.5 mul }%
-  \pspolygon(!\@wd neg \getCLWH add \@ht neg)%
-            (!\@wd 0)(!\@wd neg \getCLWH add \@ht)
+  \pspolygon(!\@wd neg \POE@clwh add \@ht neg)%
+            (!\@wd 0)(!\@wd neg \POE@clwh add \@ht)
 }%
 %    \end{macrocode}
 % \end{macro}
@@ -17576,7 +17813,17 @@ tx@OptexpDict begin
 % Load some parameters from \opt{ambcomp}
 %    \begin{macrocode}
   aload pop /draw ED /name ED
-  name cvn load /N get /N ED
+  name cvn load /N get dup /N ED
+%    \end{macrocode}
+% If the ambiguous component has only one interface, there exists no internal beam
+%    \begin{macrocode}
+  1 eq { /draw true def } if
+%    \end{macrocode}
+% \PSvar{CurrTmp} is the current point of the beam on the interface
+% prior to the ambiguos component, \PSvar{CurrVecTmp} its outgoing
+% vector. For wide beams, the lower ray is used. These vectors will be
+% changed inside this procedure.
+%    \begin{macrocode}
   currentdict /Curr known {
     /CurrTmp /Curr load def
     /CurrVecTmp /CurrVec load def
@@ -17584,14 +17831,10 @@ tx@OptexpDict begin
     /CurrTmp /CurrLow load def
     /CurrVecTmp /CurrVecLow load def
   } ifelse
-%    \end{macrocode}
-% \PSvar{CurrTmp} is the current point of the beam on the interface prior to the
-% ambiguos component, \PSvar{CurrVecTmp} its outgoing vector. For wide beams,
-% the lower ray is used.
-%    \begin{macrocode}
   PN 1 eq {
 %    \end{macrocode}
-% If it is the first interface, the starting point is always the (C) plane
+% If it is the first interface, the starting point is always the (C)
+% plane, the mode is set arbitrarily to transmittive.
 %    \begin{macrocode}
     [ (C) name name GetRefIndex trans draw] cvx
 %    \end{macrocode}
@@ -17600,7 +17843,8 @@ tx@OptexpDict begin
     name /outToPlane load GetNextPlane
     dup 0 eq not {
 %    \end{macrocode}
-% If there is one, i.e. if \PSvar{GetNextPlane} leaves something not equal to \PSvar{0} on the stack, this is the plane.
+% If there is one, i.e. if \PSvar{GetNextPlane} leaves something not
+% equal to \PSvar{0} on the stack, this is the plane.
 %    \begin{macrocode}
       [ exch name bgRefIndex trans draw ] cvx exch
       /IfcCntTmp IfcCntTmp 1 add def
@@ -17608,33 +17852,39 @@ tx@OptexpDict begin
       pop
     } ifelse
   }{
+%    \end{macrocode}
+% It is not the first component, check which interface of the component
+% is the nearest one to the current beam point and save its name in
+% \PSvar{firstPlane}.
+%    \begin{macrocode}
     CurrTmp name GetNearestPlane dup /firstPlane ED
     name isAmbiguousIfc not {
 %    \end{macrocode}
-% The first interface is not the ambiguous one.
-%
-% check if mode is trans or refl
+% The first interface is not the ambiguous one, put it on the stack and
+% calculated the new beam vector.
 %    \begin{macrocode}
-      CurrVecTmp firstPlane name GetPlaneVec NormalVec
-      (C) name GetIfcCenter firstPlane name GetIfcCenter 
-      @ABVect 2 copy 6 2 roll DotProd 
-      0 lt { trans }{ refl } ifelse
-      3 1 roll ToVec /CurrVecTmp ED
+      firstPlane name
+      name firstPlane GetIfcMode
+      connectifc { bgRefIndex }{ name GetRefIndex } ifelse
+      CurrTmp CurrVecTmp
+      10 dict begin HandleInterface end pop 
+      ToVec /CurrVecTmp ED ToVec /CurrTmp ED
       [ firstPlane name
       connectifc {
         bgRefIndex
       }{
         name GetRefIndex
       } ifelse
+      name firstPlane GetIfcMode
 %    \end{macrocode}
 % always draw to first interface
 %    \begin{macrocode}
-      5 -1 roll true ] cvx
+      true ] cvx
       /IfcCntTmp IfcCntTmp 1 add def
     } if
     PN IfcCnt eq {
 %    \end{macrocode}
-% its the last comp, just put the center plane on the stack
+% Its the last comp, just put the ambiguous interface on the stack, the mode is irrelevant.
 %    \begin{macrocode}
       [ (C) name
       name GetRefIndex
@@ -17642,18 +17892,24 @@ tx@OptexpDict begin
       IfcCntTmp IfcCnt gt { exch } if
     }{
 %    \end{macrocode}
-% check the mode of the ambiguous interface
+% Otherwise put the ambiguous interface on the stack and check its mode.
 %    \begin{macrocode}
       [ (C) name
       name GetRefIndex
       CurrVecTmp (C) name GetPlaneVec NormalVec outToPlane 
       GetIfcCenter (C) name GetIfcCenter @ABVect DotProd
-      0 lt { trans } { refl } ifelse % mode
+      0 lt { trans } { refl } ifelse
+      dup 6 1 roll
 %    \end{macrocode}
 % if the ambiguous interface is the first, always draw to it
 %    \begin{macrocode}
       IfcCntTmp IfcCnt eq { true }{ draw } ifelse
-      ] cvx 
+      ] cvx
+      (C) name 4 -1 roll
+      connectifc { bgRefIndex }{ name GetRefIndex } ifelse
+      CurrTmp CurrVecTmp
+      10 dict begin HandleInterface end pop 
+      ToVec /CurrVecTmp ED ToVec /CurrTmp ED
 %    \end{macrocode}
 % now check which is the outgoing plane
 %    \begin{macrocode}
@@ -17684,8 +17940,9 @@ tx@OptexpDict begin
 /GetNextPlane {
   (GetNextPlane) DebugBegin
   2 copy (C) 3 -1 roll
-  GetIfcCenter 3 -1 roll exec GetIfcCenter 
-  4 2 roll 4 copy @ABVect /VecY ED /VecX ED 
+  GetIfcCenter 3 -1 roll
+  exec GetIfcCenter
+  4 2 roll 4 copy @ABVect ToVec /Vec ED
   @ABDist /centerDist ED
   /sprod 1 def
   /nextPlane 0 def
@@ -17696,8 +17953,8 @@ tx@OptexpDict begin
 %    \begin{macrocode}
    dup ambIfc eq not {
       3 copy 3 -1 roll 2 copy
-      GetPlaneVec VecX VecY 4 2 roll NormalVec 
-      VecX VecY DotProd dup sprod lt 5 2 roll
+      GetPlaneVec Vec 4 2 roll NormalVec 
+      Vec DotProd dup sprod lt 5 2 roll
       GetIfcCenter 3 -1 roll exec GetIfcCenter @ABDist 
       centerDist lt and
       { /sprod ED /nextPlane ED } { pop pop } ifelse
@@ -17800,7 +18057,7 @@ tx@OptexpDict begin
     } ifelse
     2 copy
     ToVec /Curr ED 
-    draw PN skipconn 1 add gt and
+    draw PN beampathskip 1 add gt and
     counttomark 3 roll
     /PrevCenter /CurrCenter load def
     /lastBeamPointTmp /Curr load def
@@ -17959,7 +18216,7 @@ tx@OptexpDict begin
 %    \end{macrocode}
 % \PSvar{draw} indicates if the beam to the current interface should be drawn.
 %    \begin{macrocode}
-    PN skipconn 1 add gt and /draw ED
+    PN beampathskip 1 add gt and /draw ED
 %    \end{macrocode}
 % \PSvar{Mode} stores the mode (transmittive or reflective) of the current interface.
 %    \begin{macrocode}
@@ -18387,6 +18644,13 @@ tx@OptexpDict begin
       } if
       AdjustRelRot
     } {
+%    \end{macrocode}
+% check if the first plane is an NodeIfc and correct its rotation, the
+% node ordering in CompA is irrelevant at this point, so we use desc.
+%    \begin{macrocode}
+      i 2 eq {
+        CompB amb CompA desc AdjustRelRot
+      } if
       pop amb dup
     } ifelse
     CompB /CompA CompB def
@@ -18571,6 +18835,18 @@ tx@OptexpDict begin
 %    \end{macrocode}
 % \end{macro}
 % 
+% \begin{macro}{GetIfcMode}
+%   \begin{pssyntax}
+%     \PSstring{name} \PSvar{num} \PSop{GetIfcMode} \PSvar{mode}
+%   \end{pssyntax}
+%    \begin{macrocode}
+/GetIfcMode {
+  exch cvn load begin
+    IfcName load /mode get
+  end
+} bind def
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{NodeName}
 % Construct the plane name from IfcNum. This must be called within a dict of a
 % optexpcomp, because the last node ends with (N) instead of the number and we must
-- 
cgit v1.2.3

