<<>> <> <> <> DIRECTORY CedarProcess, Draw2d, G3dBasic, G3dCubeDraw, G3dDraw, G3dMatrix, G3dOctree, G3dPlane, G3dPolygon, G3dShape, G3dVector, Imager, ImagerPath, ImplicitDraw, ImplicitDefs, ImplicitPoints, ImplicitPolygons, ImplicitSurface, Real; ImplicitDrawImpl: CEDAR PROGRAM IMPORTS CedarProcess, G3dCubeDraw, G3dDraw, G3dOctree, G3dVector, Imager, ImagerPath, ImplicitPoints, ImplicitPolygons, ImplicitSurface, Real EXPORTS ImplicitDraw ~ BEGIN MarkType: TYPE ~ Draw2d.MarkType; NatSequence: TYPE ~ G3dBasic.NatSequence; Triple: TYPE ~ G3dBasic.Triple; Cube: TYPE ~ G3dOctree.Cube; Octant: TYPE ~ G3dOctree.Octant; <> DiagramProgress: PUBLIC PROC [ context: Imager.Context, surface: ImplicitDefs.Surface, whatChanged: REF ANY, refAny: REF ANY, view: G3dMatrix.Matrix, viewport: G3dMatrix.Viewport ¬ [], currentCube: Cube ¬ NIL, drawEdges: BOOL ¬ FALSE, drawPolygons: BOOL ¬ FALSE, drawRoots: BOOL ¬ FALSE] ~ { Mark: PROC [mark: MarkType] ~ { vertex: G3dShape.Vertex ¬ NARROW[refAny]; SELECT mark FROM x => G3dDraw.Mark[context, vertex.point, view, vp,, x]; dot => G3dDraw.Box[context, vertex.point, view, vp, 3, 3]; ENDCASE; }; root: Cube ¬ IF surface # NIL AND surface.octree # NIL THEN surface.octree.root ELSE NIL; vp: G3dMatrix.Viewport ¬ viewport; SELECT whatChanged FROM $NewCube, $MakeOctree => { IF drawEdges THEN G3dCubeDraw.SimpleCube[context, currentCube, view, vp,, dotted]; IF drawRoots THEN G3dCubeDraw.SimpleCube[context, root, view, vp, TRUE, solid]; }; $NewRoot => IF drawRoots THEN G3dCubeDraw.SimpleCube[context, root, view, vp, TRUE, solid]; $AdaptOctree => { m: MarkType ¬ SELECT refAny FROM $Dot => dot, $Cross => cross, ENDCASE => x; G3dDraw.Mark[context, G3dOctree.Center[currentCube], view, vp,, m]; }; $SetCorners => G3dCubeDraw.SimpleCube[context, currentCube, view, vp,, solid]; $MakePolygons => IF drawPolygons THEN DrawPolygon[context, surface, NARROW[refAny, NatSequence]]; $MakeVertices => IF drawPolygons THEN Mark[dot]; $MakeTextures => IF drawPolygons THEN Mark[x]; NIL => { IF drawEdges THEN G3dCubeDraw.TerminalCubes[context, root, view, vp, dotted]; IF drawRoots THEN G3dCubeDraw.SimpleCube[context, root, view, vp, TRUE, solid]; }; ENDCASE; }; DrawPolygon: PUBLIC PROC [ context: Imager.Context, surface: ImplicitDefs.Surface, polygon: NatSequence, clipCube: Cube ¬ NIL, directionSelect: G3dOctree.DirectionSelect ¬ xyz, forInterpress: BOOL ¬ FALSE] ~ { IF polygon = NIL OR polygon.length < 3 OR clipCube = NIL OR surface = NIL THEN RETURN; FOR i: NAT IN [0..polygon.length) DO IF NOT G3dOctree.PointInCube[surface.vertices[polygon[i]].point, clipCube, .05] THEN RETURN; ENDLOOP; IF forInterpress THEN { t: Imager.Trajectory ¬ ImagerPath.MoveTo[surface.screens[polygon[0]].pos]; FOR n: NAT IN [1..polygon.length) DO t ¬ ImagerPath.LineTo[t, surface.screens[polygon[n]].pos]; ENDLOOP; Imager.SetStrokeJoint[context, round]; Imager.MaskStrokeTrajectory[context, t, TRUE]; } ELSE { Eq: PROC [r, s: REAL] RETURNS [b: BOOL] ~ INLINE {b ¬ ABS[r-s] < 0.0001}; Rnd: PROC [r: REAL] RETURNS [i: INT] ~ INLINE {i ¬ Real.Round[r]}; s0, s1: G3dBasic.Pair; n0, n1: NAT ¬ polygon[polygon.length-1]; p0, p1: Triple ¬ surface.vertices[n0].point; FOR i: NAT IN [0..polygon.length) DO n0 ¬ n1; p0 ¬ p1; p1 ¬ surface.vertices[n1 ¬ polygon[i]].point; IF directionSelect # xyz THEN SELECT directionSelect FROM x => IF Eq[p0.x, p1.x] THEN LOOP; y => IF Eq[p0.y, p1.y] THEN LOOP; z => IF Eq[p0.z, p1.z] THEN LOOP; xy => IF Eq[p0.x, p1.x] OR Eq[p0.y, p1.y] THEN LOOP; xz => IF Eq[p0.x, p1.x] OR Eq[p0.z, p1.z] THEN LOOP; yz => IF Eq[p0.y, p1.y] OR Eq[p0.z, p1.z] THEN LOOP; ENDCASE; s0 ¬ surface.screens[n0].pos; s1 ¬ surface.screens[n1].pos; G3dDraw.Line2d[context, [Rnd[s0.x], Rnd[s0.y]], [Rnd[s1.x], Rnd[s1.y]], solid]; ENDLOOP; }; }; <