diff options
Diffstat (limited to 'Master/texmf-dist/dvips')
-rw-r--r-- | Master/texmf-dist/dvips/pst-intersect/pst-intersect.pro | 195 |
1 files changed, 124 insertions, 71 deletions
diff --git a/Master/texmf-dist/dvips/pst-intersect/pst-intersect.pro b/Master/texmf-dist/dvips/pst-intersect/pst-intersect.pro index fc0492bb9f5..920774cc758 100644 --- a/Master/texmf-dist/dvips/pst-intersect/pst-intersect.pro +++ b/Master/texmf-dist/dvips/pst-intersect/pst-intersect.pro @@ -160,25 +160,55 @@ tx@IntersectDict begin } if DebugEnd %1 debug } bind def -/movetype { /moveto load } bind def -/linetype { /lineto load } bind def -/curvetype { /curveto load } bind def +/InitTracing { + /movetype /moveto load def + /linetype /lineto load def + /curvetype /curveto load def +} bind def +InitTracing +/GetFullPath { + { /movetype counttomark 3 roll } + { /linetype counttomark 3 roll } + { /curvetype counttomark 7 roll }{} pathforall +} bind def /PreparePath { - [ exch aload pop - { -dup type /nametype eq not { exit } if -dup /movetype eq { - pop ToVec /@mycp exch def -} { - dup /linetype eq { -pop [ @mycp 4 2 roll 2 copy ToVec /@mycp exch def ToVec ] + [ exch aload pop + { + dup type /nametype eq not { exit } if + dup /movetype eq { + pop ToVec /@mycp exch def } { -pop [ @mycp 8 2 roll 2 copy ToVec /@mycp exch def -ToVec 5 1 roll ToVec 4 1 roll ToVec 3 1 roll ] + dup /linetype eq { + pop [ @mycp 4 2 roll 2 copy ToVec /@mycp exch def ToVec ] + } { + pop [ @mycp 8 2 roll 2 copy ToVec /@mycp exch def + ToVec 5 1 roll ToVec 4 1 roll ToVec 3 1 roll ] + } ifelse + counttomark 1 roll } ifelse - counttomark 1 roll -} ifelse - } loop ] + } loop ] +} bind def +/GetSegmentCount { + dup IsPath { + [ exch aload pop 0 + { + counttomark 1 eq { exit } if + exch + dup /movetype eq { + pop 3 1 roll pop pop + }{ + dup /linetype eq { + pop 1 add 3 1 roll pop pop + }{ + pop 1 add 7 1 roll 6 { pop } repeat + } ifelse + } ifelse + } loop + exch pop + } { + % a Bezier curve is a single segment + pop 1 + } ifelse } bind def /LoadLineIntersectionPoints { (LoadLineIntersectionPoints) DebugBegin @@ -248,8 +278,14 @@ ToVec 5 1 roll ToVec 4 1 roll ToVec 3 1 roll ] } bind def /IterateIntersection { (IterateIntersection) DebugBegin - 11 dict begin + 12 dict begin /precision MaxPrecision def + 4 2 roll 2 copy 6 2 roll + dup IsPath not { PointArrayToArray } if + 0 exch { dup type /nametype eq { pop }{ abs max} ifelse } forall + exch dup IsPath not { PointArrayToArray } if + { dup type /nametype eq { pop }{ abs max} ifelse } forall + Epsilon mul /epsilon exch def /counter 0 def /depth 0 def /domsA [] def @@ -534,8 +570,7 @@ AreNear and exch /AreNear { (AreNear) DebugBegin aload pop 3 -1 roll aload pop - 4 copy abs 3 { exch abs max } repeat Epsilon mul - dup 6 2 roll VecSub abs 4 -1 roll lt exch abs 3 -1 roll lt and + VecSub abs epsilon lt exch abs epsilon lt and DebugEnd } bind def /Min { @@ -714,69 +749,87 @@ pop /IsPath { dup length 1 sub get type /nametype eq { true } { false } ifelse } bind def -/ShowFullPath { - 4 dict begin - /movetype /moveto load def - /linetype /lineto load def - /curvetype /curveto load def - mark exch aload pop - { - counttomark 0 eq { exit } if - load exec - } loop - pop - end -} bind def /ShowPathPortion { 6 dict begin - exch dup 0 lt { pop 0 } if /tstart exch def - % if tstart is < 0, use the array length - dup 0 lt { pop dup length } if /tstop exch def - tstop tstart gt { - /movetype /moveto load def - /linetype /lineto load def - /curvetype /curveto load def - /n 0 def - mark exch aload pop - { - counttomark 0 eq { pop exit } if - dup /movetype eq not { /n n 1 add def } if - % current section is after tstart - n tstop sub 1 ge { cleartomark exit } if + /tstop exch def + /tstart exch def + InitTracing + /n 0 def + mark exch aload pop + { + counttomark 0 eq n tstop ge or { pop exit } if + dup /movetype eq not { /n n 1 add def } if - dup /movetype eq { - load exec + dup /movetype eq { + load exec + } { + tstart n gt { + /curvetype eq { 6 2 roll 4 { pop } repeat } if + movetype } { - tstart n gt { - % current path section is before tstart - /curvetype eq { 6 2 roll 4 { pop } repeat } if - movetype - } { - tstart n 1 sub gt tstop n lt or { - % draw a truncated section - tstart n sub 1 add tstop n sub 1 add - ToUnitInterval exch + tstart n 1 sub gt tstop n lt or { + tstart n sub 1 add tstop n sub 1 add + ToUnitInterval exch + /linetype eq { + 3 1 roll ToVec currentpoint ToVec exch ToVec + dup 3 -1 roll Portion + aload pop exch + tstart n 1 sub gt { + exch aload pop 3 -1 roll aload pop ArrowA + tstop n le { + currentpoint 4 2 roll ArrowB lineto pop pop + } { + lineto + } ifelse + } { + pop aload pop currentpoint 4 2 roll ArrowB lineto pop pop + } ifelse + } { + 7 1 roll [ currentpoint 9 3 roll ] ArrayToPointArray + dup 3 -1 roll Portion + { aload pop } forall + 8 -2 roll + tstart n 1 sub gt { moveto } { pop pop } ifelse + 6 -2 roll currentpoint ArrowA 6 2 roll + tstop n le { + ArrowB + } if + curveto + } ifelse + }{ + tstart n 1 sub eq { /linetype eq { - 3 1 roll ToVec currentpoint ToVec exch ToVec - dup 3 -1 roll Portion - aload pop exch - tstart n 1 sub gt { aload pop moveto } { pop } ifelse - aload pop lineto + currentpoint ArrowA + tstop n eq { + currentpoint 4 2 roll ArrowB lineto pop pop + } { + lineto + } ifelse } { - 7 1 roll [ currentpoint 9 3 roll ] ArrayToPointArray - dup 3 -1 roll Portion - { aload pop } forall - 8 -2 roll - tstart n 1 sub gt { moveto } { pop pop } ifelse + 6 -2 roll currentpoint ArrowA 6 2 roll + tstop n eq { + ArrowB + } if + curveto + } ifelse + } { + /linetype eq { + tstop n eq { + currentpoint 4 2 roll ArrowB lineto pop pop + }{ + lineto + } ifelse + } { + tstop n eq { + ArrowB + } if curveto } ifelse - }{ - load exec } ifelse } ifelse } ifelse - } loop - } if + } ifelse + } loop end } bind def % Graham Scal algorithm to compute the convex hull of a set of |