From 949a40dc13f864beaec0654b15a8002760168143 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 17 Aug 2012 22:44:46 +0000
Subject: pst-optexp (17aug12)

git-svn-id: svn://tug.org/texlive/trunk@27437 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/latex/pst-optexp/pst-optexp.sty | 318 ++++++++++++++-------
 1 file changed, 221 insertions(+), 97 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/pst-optexp/pst-optexp.sty')

diff --git a/Master/texmf-dist/tex/latex/pst-optexp/pst-optexp.sty b/Master/texmf-dist/tex/latex/pst-optexp/pst-optexp.sty
index 224af6e0280..bdbd986a77f 100644
--- a/Master/texmf-dist/tex/latex/pst-optexp/pst-optexp.sty
+++ b/Master/texmf-dist/tex/latex/pst-optexp/pst-optexp.sty
@@ -9,7 +9,7 @@
 %% This is a generated file.
 %% 
 %% Project: pst-optexp
-%% Version: 3.2 (2012/07/26)
+%% Version: 3.3 (2012/08/17)
 %% 
 %% Copyright (C) 2007-2012 by Christoph Bersch <usenet@bersch.net>
 %% 
@@ -31,7 +31,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{pst-optexp}
-    [2012/07/26 v3.2 Optical experimental setups with PSTricks]
+    [2012/08/17 v3.3 Optical experimental setups with PSTricks]
 \RequirePackage{pstricks}
 \RequirePackage{pst-xkey}
 \RequirePackage{pst-node}
@@ -289,7 +289,7 @@
     \fi
   }{%
     \PackageError{pst-optexp}%
-      {Unknown value '\POE@key@labelref' for labelref}%
+      {Unknown value '\val' for labelref}%
 }%
 \define@choicekey*+[psset]{optexp}{innerlabel}%
   [\val\nr]{true}[true]%
@@ -307,7 +307,7 @@
       \psset[optexp]{labelref=#4}%
     \fi
   \fi
-  \edef\POE@temp{#3}
+  \edef\POE@temp{#3}%
   \ifx\POE@temp\@empty\else
     \expandafter\ifx\POE@temp.\else
       \psset[optexp]{labelalign=#3}%
@@ -718,8 +718,20 @@
   \pst@checknum{#1}\POE@key@mirrordepth
 }
 \define@key[psset]{optexp}{mirrorradius}{%
+  \pst@expandafter\POE@psset@@mirrorradius{#1} {} {} {}\@nil
+}%
+\def\POE@psset@@mirrorradius#1 #2 #3\@nil{%
   \pst@checknum{#1}\POE@key@mirrorradius
-}
+  \ifx\\#2\\
+    \def\POE@key@mirrorradiusB{}%
+  \else
+    \pst@checknum{#2}\POE@key@mirrorradiusB
+    \ifdim\POE@key@mirrorradiusB pt=0pt\else
+      \PackageWarning{optexp}{%
+        The second value for option 'mirrorradius' must be 0.}%
+    \fi
+  \fi
+}%
 \define@boolkey[psset]{optexp}[POE@]{variable}[true]{}
 \psset[optexp]{%
   mirrorwidth=1,
@@ -784,6 +796,17 @@
 \define@key[psset]{optexp}{gratinglinewidth}{%
   \edef\POE@key@gratinglinewidth{#1}%
 }
+\define@choicekey+[psset]{optexp}{gratingalign}%
+  [\val\nr]{t,c,top,center}%
+  {%
+    \ifcase\nr\relax
+      \let\POE@key@gratingalign\POE@str@top
+    \or
+      \let\POE@key@gratingalign\POE@str@center
+    \else
+      \def\POE@key@gratingalign{#1}%
+    \fi}%
+  {\PackageError{pst-optexp}{Unknown value '\val' for gratingalign.}}
 \define@boolkey[psset]{optexp}[POE@]{reverse}[true]{}
 \psset[optexp]{%
   gratingcount=10,
@@ -792,6 +815,7 @@
   gratingdepth=0.075,
   gratingtype=blazed,
   gratinglinewidth=0.7\pslinewidth,
+  gratingalign=t
 }%
 \define@key[psset]{optexp}{pentaprismsize}{%
   \pst@checknum{#1}\POE@key@pentaprismsize
@@ -816,6 +840,18 @@
   prismangle=60,
   prismalign=auto
 }%
+\define@key[psset]{optexp}{optdipolesize}{%
+  \pst@expandafter\POE@psset@@optdipolesize{#1} {} {} {}\@nil
+}%
+\def\POE@psset@@optdipolesize#1 #2 #3\@nil{%
+  \ifx\\#2\\
+    \def\POE@key@optdipoleheight{0}%
+  \else
+    \pst@checknum{#2}\POE@key@optdipoleheight
+  \fi
+  \pst@checknum{#1}\POE@key@optdipolewidth
+}%
+\psset[optexp]{optdipolesize=0 0}%
 \define@key[psset]{optexp}{fiberloops}{%
   \pst@checknum{#1}\POE@key@fiberloops
 }
@@ -1124,9 +1160,9 @@
 \define@choicekey+[psset]{optexp}{loadbeampoints}%
   [\val\nr]{true,false}[true]{%
     \ifcase\nr\relax
-      \def\POE@key@loadbeampoints{1}
+      \def\POE@key@loadbeampoints{1}%
     \or
-      \def\POE@key@loadbeampoints{0}
+      \def\POE@key@loadbeampoints{0}%
     \fi
   }{%
     \ifnum9<1#1
@@ -1161,6 +1197,7 @@
 }%
 \define@boolkey[psset]{optexp}[POE@]{beaminside}[true]{}%
 \define@boolkey[psset]{optexp}[POE@]{allowbeaminside}[true]{}%
+\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}{%
@@ -1190,6 +1227,7 @@
   ,startinside=false
   ,stopinside=false
   ,allowbeaminside=true
+  ,forcebeaminside=false
   ,beaminside=true
   ,beaminsidefirst=false
   ,beaminsidelast=false
@@ -1524,6 +1562,7 @@
      /loadbeampoints \POE@key@loadbeampoints\space def
      /loadbeam \ifPOE@loadbeam true \else false \fi def
      /beamangle \POE@key@beamangle\space def
+     /beamdiv \POE@key@beamdiv\space def
      /savebeampoints \POE@key@savebeampoints\space def
      /savebeam \ifPOE@savebeam true \else false \fi def
      /beaminsidefirst \ifPOE@beaminsidefirst true \else false \fi def
@@ -1592,8 +1631,9 @@
   \fi
 }
 \def\drawbeam@iii{%
-  \ifx\pslinestyle\@none
-    \addto@pscode{ false false }%
+  \ifodd
+    \ifx\pslinestyle\@none\ifx\psk@ArrowInside\@empty 1\else 0\fi\else 0\fi
+    \addto@pscode{ cleartomark false false }%
   \else
     \addto@pscode{%
       {/nbeam {\POE@key@n cvx exec} bind def
@@ -1699,7 +1739,9 @@
       \else
         /fillBeam {\psk@fillstyle} def
       \fi
-      /strokeBeam \ifx\pslinestyle\@none false \else true \fi def
+      /strokeBeam
+        \ifx\pslinestyle\@none false \else true \fi
+        \ifx\psk@ArrowInside\@empty false \else true \fi or def
       [/lastBeamPointTmpLow /lastBeamPointTmpUp
       /lastVecTmpLow /lastVecTmpUp]
       {currentdict exch undef} forall
@@ -2263,12 +2305,39 @@
 \def\oeBeamVec#1{\oe@BeamVec{}{#1}}%
 \def\oeBeamVecUp#1{\oe@BeamVec{Up}{#1}}%
 \def\oeBeamVecLow#1{\oe@BeamVec{Low}{#1}}%
+\def\POE@useifccode{%
+  \POE@Verb{%
+    [ \pst@code
+    \ifPOE@allowbeaminside true \else false \fi
+    \ifPOE@forcebeaminside true \else false \fi
+    (\oenode{}{}) {\tx@ScreenCoor}
+    NewOptexpComp
+  }%
+  \gdef\pst@code{}%
+}%
+\def\begin@CompIfc{%
+  \begingroup
+}%
+\def\end@CompIfc{%
+  \addto@pscode{ false }%
+  \POE@useifccode
+  \endgroup
+  \ignorespaces
+}%
+\def\end@AmbCompIfc{%
+  \addto@pscode{ true }%
+  \POE@useifccode
+  \endgroup
+  \ignorespaces
+}%
 \def\newOptexpComp@#1#2{%
   \POE@Verb{%
     \tx@NodeScale
-    [ #1 #2 \ifPOE@allowbeaminside true \else false \fi
-      (\oenode{}{}) {\tx@ScreenCoor}
-      NewOptexpComp
+    [ #1 #2
+    \ifPOE@allowbeaminside true \else false \fi
+    \ifPOE@forcebeaminside true \else false \fi
+    (\oenode{}{}) {\tx@ScreenCoor}
+    NewOptexpComp
   }%
 \ignorespaces}%
 \def\newOptexpComp#1{%
@@ -3014,16 +3083,21 @@
 \newOptexpTripole[ref@angle=-135]{rightangleprism}{}%
 \newOptexpTripole[ref@angle=-135]{optprism}{}%
 \def\optdipole{\pst@object{optdipole}}
-\def\optdipole@i(#1)(#2)#3#4{%
+\def\optdipole@i(#1)(#2)#3{%
+  \@ifnextchar\bgroup%
+    {\optdipole@i@(#1)(#2){#3}}%
+    {\optdipole@i@(#1)(#2){#3}{}}%
+}%
+\def\optdipole@i@(#1)(#2)#3#4{%
    \begin@OptexpObj
       \ifPOE@backlayer
         \POE@regNodes{#1}{#2}
         \POE@extnodealign
       \fi
-      \POE@drawcomponent{#4}{%
+      \POE@drawcomponent[optdipole]{#4}{%
         \ifPOE@backlayer
-          \pnode(0,0){\oenodeCenter{}}%
-          \newOptexpComp{{0 0} {0 1} 0 0 trans {PlainIfc} 1 }%
+          \pnode(!\POE@dict{@@x0 @@y0}){\oenodeCenter{}}%
+          \dipole@nodes
         \fi
         \ifPOE@frontlayer
           #3
@@ -3034,19 +3108,36 @@
       \fi
    \end@OptexpObj
 }%
+\def\optdipole@ref{%
+  \POE@setref{%
+    /@@x \POE@key@optdipolewidth\space 0.5 mul def
+    /@@y \POE@key@optdipoleheight\space 0.5 mul def
+  }%
+}%
 \def\opttripole{\pst@object{opttripole}}
-\def\opttripole@i(#1)(#2)(#3)#4#5{%
+\def\opttripole@i(#1)(#2)(#3)#4{%
+  \@ifnextchar\bgroup%
+    {\opttripole@i@(#1)(#2)(#3){#4}}%
+    {\opttripole@i@(#1)(#2)(#3){#4}{}}%
+}%
+\def\opttripole@i@(#1)(#2)(#3)#4#5{%
+  \addafter@par{ref@angle=180}
   \begin@OptexpTripole
     \ifPOE@backlayer
-      \POE@regNodes{#1}{#3}%
       \POE@calcNodes{#1}{#2}{#3}%
+      \POE@regNodes{#1}{#3}%
     \fi
     \POE@drawcomponent{#5}{%
-      \pnode(0,0){\oenodeCenter{}}%
-      \newOptexpComp{{0 0} {1 0} 0 0 refl {PlainIfc} 1 }%
-      #4
+      \ifPOE@backlayer
+        \tripole@nodes
+      \fi
+      \ifPOE@frontlayer
+        #4
+      \fi
     }%
-    \POE@drawInternalConnections
+    \ifPOE@backlayer
+      \POE@drawInternalConnections
+    \fi
   \end@OptexpTripole
 }%
 \def\fibercollimator{\pst@object{fibercollimator}}
@@ -3140,7 +3231,9 @@
       \fi
     \fi
   }%
-  \@ifundefined{#1@ref}{}{\@nameuse{#1@ref}}%
+  \ifx\\#1\\\else
+    \@ifundefined{#1@ref}{}{\@nameuse{#1@ref}}%
+  \fi
   \ifPOE@endbox
     \psset[optexp]{abspos={%
       \POE@dict{%
@@ -3282,43 +3375,62 @@
         \POE@setref{\POE@key@mirrordepth\space 0.5 mul dup /@@y0 ED /@@y ED}
       \fi
     \fi
+  \else
+    \POE@setref{/@@x \POE@key@mirrorwidth\space 0.5 mul def}%
+    \ifx\POE@key@mirrortype\POE@str@mirrortype@plain\else
+      \POE@setref{\POE@key@mirrordepth\space 0.5 mul dup /@@y0 ED /@@y ED}
+    \fi
   \fi
 }%
 \def\mirror@nodes{%
+  \begin@CompIfc
   \ifdim\POE@key@mirrorradius pt=0pt
-    \ifx\POE@key@mirrortype\POE@str@mirrortype@semitrans
-      \newOptexpCompAmb{%
-        {0 0} {1 0}
-        \POE@key@mirrorwidth\space -0.5 mul dup neg
-        refl {PlainIfc}
-        {0 \POE@key@mirrordepth} {1 0}
-        \POE@key@mirrorwidth\space -0.5 mul dup neg
-        trans {PlainIfc}
-        \POE@key@mirrordepth\space -1e-5 lt {
-          12 6 roll 2
-        } {
-          \POE@key@mirrordepth\space 1e-5 lt {
-            6 {pop} repeat
-          } if
-          1
-        } ifelse
-      \POE@key@n }%
-    \else
-      \newOptexpComp{%
-        {0 0} {1 0}
-        \POE@key@mirrorwidth\space -0.5 mul dup neg
-        refl {PlainIfc} 1 }%
-    \fi
+    \addto@pscode{%
+      {0 0} {1 0}
+      \POE@key@mirrorwidth\space -0.5 mul dup neg
+      refl {PlainIfc} }%
   \else
-    \newOptexpComp{%
+    \addto@pscode{%
       {0 0} {0 \POE@key@mirrorradius\space neg}
       \POE@key@mirrorwidth\space -0.5 mul dup neg
-      refl {CurvedIfc} 1 }%
-    \ifx\POE@key@mirrortype\POE@str@mirrortype@semitrans
-      \PackageWarning{pst-optexp}{%
-        Mirrortype 'semitrans' does not support curved\MessageBreak
-        mirror, falling back to 'plain' type.}%
-    \fi
+      refl {CurvedIfc} }%
+  \fi
+  \ifx\POE@key@mirrortype\POE@str@mirrortype@semitrans
+    \ifx\POE@key@mirrorradiusB\@empty
+      \ifdim\POE@key@mirrorradius pt=0pt
+        \addto@pscode{%
+          {0 \POE@key@mirrordepth} {1 0}
+          @@x neg @@x trans {PlainIfc} }%
+      \else
+        \addto@pscode{%
+          {0 \POE@key@mirrordepth}
+          {0 \POE@key@mirrorradius\space neg}
+          \POE@key@mirrorwidth\space -0.5 mul dup neg
+          trans {CurvedIfc} }%
+      \fi
+    \else
+      \addto@pscode{%
+        {0 \POE@key@mirrordepth
+        dup \POE@key@mirrorradius\space mul 0 lt {
+          dup sign \POE@key@mirrorradius\space @@x capHeight mul add
+        } if}
+       {1 0} @@x neg @@x trans {PlainIfc} }%
+     \fi
+    \addto@pscode{%
+      \ifdim\POE@key@mirrordepth pt<-0.0001pt
+        12 6 roll 2
+      \else
+        \ifdim\POE@key@mirrordepth pt< 0.0001pt
+          6 {pop} repeat
+        \fi
+        1
+      \fi
+      \POE@key@n
+    }%
+    \end@AmbCompIfc
+  \else
+    \addto@pscode{1 }%
+    \end@CompIfc
   \fi
 }%
 \def\mirror@comp{%
@@ -3333,43 +3445,7 @@
   \edef\@extpostcode{%
     neg \@dp add 5 -1 roll exch 5 2 roll 90 add exch 90 add %
   }%
-  \ifdim\POE@key@mirrorradius pt<0pt
-    \ifx\POE@key@mirrortype\POE@str@mirrortype@extended
-      \bgroup
-        \psset{style=ExtendedMirror}
-        \begin@ClosedObj
-          \addto@pscode{%
-            \pst@optexpdict \@ht \@r rightCurvedIfc \@postcode
-            \@ht \@r rightCurvedIfc \@extpostcode arc
-            closepath end}%
-        \end@ClosedObj
-      \egroup
-    \fi
-    \bgroup
-      \psset{linewidth=\POE@key@mirrorlinewidth}
-      \begin@OpenObj
-        \addto@pscode{\POE@dict{ \@ht \@r rightCurvedIfc \@postcode }}%
-      \end@OpenObj
-    \egroup
-  \else\ifdim\POE@key@mirrorradius pt>0pt
-    \ifx\POE@key@mirrortype\POE@str@mirrortype@extended
-      \bgroup
-        \psset{style=ExtendedMirror}
-        \begin@ClosedObj
-          \addto@pscode{%
-            \pst@optexpdict \@ht \@r rightCurvedIfc \@postcode
-            \@ht \@r rightCurvedIfc \@extpostcode arcn
-            closepath end}%
-        \end@ClosedObj
-      \egroup
-    \fi
-    \bgroup
-      \psset{linewidth=\POE@key@mirrorlinewidth}
-      \begin@OpenObj
-        \addto@pscode{\POE@dict{ \@ht \@r rightCurvedIfc \@postcode }}%
-      \end@OpenObj
-    \egroup
-  \else
+  \ifdim\POE@key@mirrorradius pt=0pt
     \edef\@ht{\POE@key@mirrorwidth\space 0.5 mul }%
     \ifx\POE@key@mirrortype\POE@str@mirrortype@piezo
       \psframe[style=PiezoMirror,
@@ -3397,7 +3473,47 @@
       \psline[linewidth=\POE@key@mirrorlinewidth]%
         (! \@ht neg \getCLWH)(! \@ht \getCLWH)
     \fi
-  \fi\fi
+  \else
+    \ifdim\POE@key@mirrorradius pt<0pt
+      \def\POE@temparc{arc }
+    \else
+      \def\POE@temparc{arcn }
+    \fi
+    \ifodd
+      \ifx\POE@key@mirrortype\POE@str@mirrortype@extended 1
+      \else\ifx\POE@key@mirrortype\POE@str@mirrortype@semitrans 1
+      \else 0
+      \fi\fi
+      \bgroup
+      \ifx\POE@key@mirrortype\POE@str@mirrortype@extended
+        \psset{style=ExtendedMirror}
+      \else\ifx\POE@key@mirrortype\POE@str@mirrortype@semitrans
+        \psset{style=SemitransMirror}
+      \fi\fi
+        \begin@ClosedObj
+          \addto@pscode{%
+            \pst@optexpdict \@ht \@r rightCurvedIfc \@postcode
+            \ifx\POE@key@mirrorradiusB\@empty
+              \@ht \@r rightCurvedIfc \@extpostcode \POE@temparc
+            \else
+              0 \@dp
+              \POE@key@mirrordepth\space\POE@key@mirrorradius\space
+              mul 0 gt {
+                dup sign \@r \@ht capHeight mul add
+              } if
+              rlineto 2 \@ht mul 0 rlineto
+            \fi
+            closepath end}%
+        \end@ClosedObj
+      \egroup
+    \fi
+    \bgroup
+      \psset{linewidth=\POE@key@mirrorlinewidth}
+      \begin@OpenObj
+        \addto@pscode{\POE@dict{ \@ht \@r rightCurvedIfc \@postcode }}%
+      \end@OpenObj
+    \egroup
+  \fi
   \ifPOE@variable
     \psarc[style=VariableStyle]%
       (! \POE@key@mirrorwidth\space 0.5 mul 0.4 sub
@@ -3675,7 +3791,14 @@
   \else
     \edef\@ht{\POE@key@gratingheight\space}%
   \fi
-  \edef\@dp{\POE@key@gratingdepth\space}%
+  \ifx\POE@key@gratingalign\POE@str@top
+    \edef\@dp{\POE@key@gratingdepth\space}%
+    \edef\@bl{0 }%
+  \else
+    \edef\@dp{0 }%
+    \edef\@bl{\POE@key@gratingdepth\space neg }%
+    \edef\@ht{\@ht \POE@key@gratingdepth\space sub }%
+  \fi
   \edef\@step{\POE@key@gratingwidth\space\@cnt div }%
   \ifx\POE@key@gratingtype\POE@str@gratingtype@blazed
     \pscustom[linewidth=\POE@key@gratinglinewidth, linejoin=1]{%
@@ -3685,23 +3808,24 @@
         \psline[liftpen=1]%
           (! \@wd neg \i\space \@step mul add \@dp)%
           (! \@wd neg \i\space
-             \ifPOE@reverse\else 1 add \fi \@step mul add 0)%
+             \ifPOE@reverse\else 1 add \fi \@step mul add \@bl)%
           (! \@wd neg \i\space 1 add \@step mul add \@dp)%
       }%
       \closepath
     }%
   \else\ifx\POE@key@gratingtype\POE@str@gratingtype@binary
-    \pscustom[linewidth=\POE@key@gratinglinewidth]{%
+    \pscustom[linewidth=\POE@key@gratinglinewidth, linejoin=1]{%
       \psline[liftpen=1](! \@wd \@dp)(! \@wd \@ht)%
                         (! \@wd neg \@ht)(! \@wd neg \@dp)%
       \multido{\i=0+1}{\POE@key@gratingcount}{%
         \psline[liftpen=1]%
           (! \@wd neg \i\space \@step mul add \@dp)%
-          (! \@wd neg \i\space \@step mul add 0)%
-          (! \@wd neg \i\space 0.5 add \@step mul add 0)%
+          (! \@wd neg \i\space \@step mul add \@bl)%
+          (! \@wd neg \i\space 0.5 add \@step mul add \@bl)%
           (! \@wd neg \i\space 0.5 add \@step mul add \@dp)%
           (! \@wd neg \i\space 1 add \@step mul add \@dp)%
       }%
+      \closepath
     }%
   \fi\fi
   \ifPOE@variable
-- 
cgit v1.2.3

