DIRECTORY G2dBasic, G2dVector, Imager, ImagerSample, IO, Rope, ViewerClasses; G2dContour: CEDAR DEFINITIONS IMPORTS Imager ~ BEGIN Error: ERROR [code: ATOM, reason: ROPE]; Contour: TYPE ~ REF ContourRep; ContourRep: TYPE ~ RECORD [ t: REAL ¬ 0.0, -- curve parameter, if known closed: BOOL ¬ FALSE, -- if true, last point connects to 1st circle: BOOL ¬ TRUE, -- if true, normals = points pairs: PairSequence ¬ NIL, -- 2d points on contour normals: PairSequence ¬ NIL, -- 2d normals of contour points percents: RealSequence ¬ NIL, -- % along contour for each point clientData: REF ¬ NIL ]; ContourSequence: TYPE ~ REF ContourSequenceRep; ContourSequenceRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Contour ]; Span: TYPE ~ RECORD [y, x0, x1: INTEGER]; SpanSequence: TYPE ~ REF SpanSequenceRep; SpanSequenceRep: TYPE ~ RECORD [ length: CARDINAL ¬ 0, element: SEQUENCE maxLength: CARDINAL OF Span ]; RealIndex: TYPE ~ RECORD [n: NAT ¬ 0, alpha: REAL ¬ 0.0]; ROPE: TYPE ~ Rope.ROPE; STREAM: TYPE ~ IO.STREAM; Viewer: TYPE ~ ViewerClasses.Viewer; Context: TYPE ~ Imager.Context; SampleMap: TYPE ~ ImagerSample.SampleMap; Rectangle: TYPE ~ Imager.Rectangle; Color: TYPE ~ Imager.Color; Border: TYPE ~ G2dBasic.Border; Pair: TYPE ~ G2dBasic.Pair; -- RECORD [x, y: REAL] PairSequence: TYPE ~ G2dBasic.PairSequence; PairSequenceRep: TYPE ~ G2dBasic.PairSequenceRep; IntegerPair: TYPE ~ G2dBasic.IntegerPair; -- RECORD [x, y: INTEGER] IntegerPairSequence: TYPE ~ G2dBasic.IntegerPairSequence; IntegerPairSequenceRep: TYPE ~ G2dBasic.IntegerPairSequenceRep; NatPair: TYPE ~ G2dBasic.NatPair; -- RECORD [x, y: Nat] NatPairSequence: TYPE ~ G2dBasic.NatPairSequence; NatPairSequenceRep: TYPE ~ G2dBasic.NatPairSequenceRep; RealSequence: TYPE ~ G2dBasic.RealSequence; RealSequenceRep: TYPE ~ G2dBasic.RealSequenceRep; FromPairs: PROC [pairs: PairSequence, closed: BOOL ¬ FALSE, t: REAL ¬ 0.0] RETURNS [Contour]; FromIntegerPairs: PROC [ integerPairs: IntegerPairSequence, closed: BOOL ¬ FALSE, t: REAL ¬ 0.0] RETURNS [Contour]; IntegerPairsFromPairs: PROC [pairs: PairSequence] RETURNS [IntegerPairSequence]; PairsFromIntegerPairs: PROC [integerPairs: IntegerPairSequence] RETURNS [PairSequence]; ShiftPairs: PROC [pairs: PairSequence, shift: INTEGER]; Scale: PROC [contour: Contour, scale: Pair] RETURNS [Contour]; Offset: PROC [contour: Contour, offset: Pair] RETURNS [Contour]; Center: PROC [contour: Contour] RETURNS [Contour]; Orient: PROC [contour: Contour] RETURNS [Contour]; ContourOK: PUBLIC PROC [contour: Contour] RETURNS [BOOL]; MinMax: PROC [contour: Contour] RETURNS [min, max: Pair]; Centroid: PROC [contour: Contour] RETURNS [Pair]; Area: PROC [contour: Contour] RETURNS [REAL]; SmoothPairs: PROC [src: PairSequence, dst: PairSequence ¬ NIL] RETURNS [PairSequence]; Smooth: PROC [contour: Contour] RETURNS [Contour]; Thin: PROC [contour: Contour, epsilon: REAL ¬ 3.0] RETURNS [Contour]; ResampleNats: PROC [src: NatPairSequence, dstnum: NAT, dst: PairSequence ¬ NIL] RETURNS [PairSequence]; ResamplePairs: PROC [src: PairSequence, dstnum: NAT, dst: PairSequence ¬ NIL] RETURNS [PairSequence]; Interpolate: PROC [contour0, contour1: Contour, alpha: REAL] RETURNS [Contour]; Sample: PROC [contour: Contour, nPairs: INTEGER] RETURNS [Contour]; Similar: PROC [contour0, contour1: Contour] RETURNS [REAL]; InsideContour: PROC [p: Pair, pairs: PairSequence] RETURNS [Border]; CirclePairs: PROC [nPairs: INTEGER] RETURNS [PairSequence]; Circle: PROC [nPairs: INTEGER] RETURNS [Contour]; Normals: PROC [contour: Contour] RETURNS [PairSequence]; Percents: PROC [contour: Contour] RETURNS [RealSequence]; AtPercent: PROC [contour: Contour, percent: REAL] RETURNS [RealIndex]; PercentPair: PROC [contour: Contour, percent: REAL] RETURNS [Pair]; PercentNormal: PROC [contour: Contour, percent: REAL] RETURNS [Pair]; Spans: PROC [contour: Contour, rectangle: Rectangle] RETURNS [SpanSequence]; FillSpans: PROC [map: SampleMap, spans: SpanSequence, color: CARDINAL]; Fill: PROC [context: Context, contour: Contour, color: Color ¬ Imager.black]; Outline: PROC [context: Context, contour: Contour, color: Color ¬ Imager.black]; OutlineMap: PROC [map: SampleMap, contour: Contour, color: CARDINAL ¬ 0]; FillMap: PROC [map: SampleMap, contour: Contour, color: CARDINAL]; Copy: PROC [contour: Contour] RETURNS [Contour]; CopySequence: PROC [contour: ContourSequence] RETURNS [ContourSequence]; Paint: PUBLIC PROC [contour: Contour, context: Context, paintNormals: BOOL ¬ FALSE]; Write: PROC [stream: STREAM, contour: Contour]; Read: PROC [stream: STREAM] RETURNS [Contour]; END.  G2dContour.mesa Copyright Σ 1985, 1988, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, July 1, 1992 7:04 pm PDT Glassner, March 18, 1990 3:28:34 pm PST Note The contour type supported by this interface is, simply, a sequence of two-dimensional points; there is no higher or analytic representation for the contour. The contour may be closed, in which case the last point of the sequence connects to the first point. Local Types Imported Types Contour Creation Return the contour given the input sequence. Return the contour given the input sequence. General Operations Convert the sequence. Convert the sequence. Barrel shift of the sequence; positive shift is to the left, negative to the right. Return the input contour scaled by the given amount. Return the input contour offset by the given amount. Return the input contour centered about [0, 0]. Return the input contour after orienting it to start at the lowest point in y. Attributes Return true if contour and contour.pairs are non-nil. Return the minimum and maximum of the contour. Return the center of the contour. Return contour area: + if clockwise, - if counterclockwise, 0 if not closed. Smoothing and Thinning Compute weighted local average of src; use dst if # NIL and long enough. Replace contour points with weighted local average. Remove redundant points (epsilon is the permissible angular degree deviation from straight). Interpolation/Resampling/Comparing Resample src curve to have dstnum (approx) equally spaced points; nats in, reals out. Avoids new allocation if dst # NIL and is long enough. Resample src curve to have dstnum (approx) equally spaced points; reals in, reals out. Avoids new allocation if dst # NIL and is long enough. Return the contour that is alpha*contour0+(1.0-alpha)*contour1. Return a sampled copy of contour. Return a measure of the similarity between the two g2dContour: 0 => dissimilar, 1 => similar. Inside/Outside Test Determine whether p is within the closed boundary defined by pairs. Circles Return the points of a circle. Return a circular contour of nPairs number of points. Normals Return the set of two-dimensional normals for the contour. Percents Set the percentages of each point according to its distance along the contour. Return the index into contour.pairs which is percent percentage around the contour. Return the contour point at percent percentage around the contour. Return the (unitized) contour normal at percent percentage around the contour. Spans Create a sequence of scanline segments which constitue the pixelated contour region. Color the spans. Filling/Outlining Fill the contour with the current Imager color. Outline the contour with the current Imager color. Outline the contour with the given color. Fill the contour with the given color. Copying Return a copy of the input contour; the contour points and normals are copied. Return a copy of the input sequence. Painting Paint the given contour. IO Write the given contour to the given stream. Read the given contour from the given stream. Κέ•NewlineDelimiter –"cedarcode" style™šœ™Jšœ Οeœ=™HJ™%J™'J˜JšΟk œ,žœ˜MJ˜—šΠbl œžœž ˜Jšžœ˜J˜—šœž˜J˜Jšœž œžœ žœ˜-—headšΟl™J™ƒ—š  ™ Jšœ žœžœ ˜#šœžœžœ˜Jšœ žœ Οc˜7Jšœžœžœ‘&˜EJšœžœžœ‘˜;Jšœžœ‘˜:Jšœžœ‘˜CJšœžœ‘!˜FJšœžœžœ˜šœ˜J˜——Jšœžœžœ˜0šœžœžœ˜$Jšœ ž œ˜Jšœž œ žœžœ˜6˜J˜——šœ žœžœ žœ˜.J˜—Jšœžœžœ˜+šœžœžœ˜!Jšœžœ˜Jšœžœ žœžœ˜3J˜J˜—Jš œžœžœžœ žœ˜<—š ™Jšžœžœžœ˜šžœžœžœžœ˜J˜—Jšœ žœ˜(Jšœ žœ˜$Jšœ žœ˜,Jšœžœ˜&šœ žœ˜ J˜—Jšœ žœ˜#Jšœ žœ‘Πcs‘’˜J™4J™—š€œžœ"žœ ˜@J™4J™—š€œžœžœ ˜2J™/J™—š€œžœžœ ˜2J™N——š  ™ š € œžœžœžœžœ˜9J™5J™—š€œžœžœ˜9J™.J™—š€œžœžœ˜1J™!J™—š€œžœžœžœ˜-J™L——š ™š€ œžœ)žœžœ˜VJšœ4£œ™HJ™—š€œžœžœ ˜2J™3J™—š€œžœžœžœ ˜EJ™\——š "™"š€ œžœ žœžœ˜OJšžœ˜J™UJšœΠksœ₯œ™6J˜—š€ œžœžœžœ˜MJšžœ˜J™VJšœ₯œ₯œ™6J™—š€ œžœ&žœžœ ˜OJ™?J™—š€œžœžœžœ ˜CJ™!J™—š€œžœžœžœ˜;J™]——š ™š€ œžœ žœ ˜DJ™D——š ™š€ œžœ žœžœ˜;J™J™—š€œžœ žœžœ ˜1Jšœ5™5——š ™š€œžœžœ˜8J™:——š  ™ š€œžœžœ˜9J™NJ™—š€ œžœžœžœ ˜FJ™SJ˜—š€ œžœžœžœ˜CJ™BJ™—š€ œžœžœžœ˜EJ™N——š ™š€œžœ*žœ˜LJ™TJ™—š€ œžœ.žœ˜GJ™——š ™š€œžœC˜MJ™/J™—š€œžœC˜PJ™2J™—š€ œžœ+žœ˜IJ™)J™—š€œžœ+žœ˜BJ™&——š ™š€œžœžœ ˜0J™NJ™—š€ œžœžœ˜HJ™$——š ™š €œžœžœ4žœžœ˜TJ™——š ™š€œžœ žœ˜/J™,J™—š€œžœ žœžœ ˜.J™-J™——J˜Jšžœ˜J˜J˜—…—΄&™