INTERFACE Cell; (* A cell from a model *) IMPORT Vertex, Material, Visual, LR3; TYPE T = RECORD v: Corners; (* Corner indices in "vertex" list, in any order *) t: CornerTags; (* Persistent corner labels. *) rest: Geometry; (* Rest shape and position *) mat: Material.Name; (* Physical material properties *) vis: Visual.Name; (* Texture name for rendering *) name: Name; (* Cell name *) END; Corners = ARRAY [0..3] OF Vertex.Num; (* The four vertices at the corners of a cell. *) CornerTag = CHAR; CornerTags = ARRAY [0..3] OF CornerTag; (* Persistent labels for the corners of a cell. When corners are permuted, these labels are carried along. The tag OF a corner also labels implicitly the opposite face of the cell. *) Geometry = ARRAY [0..3] OF LR3.T; (* Corner positions for a cell *) (* Used for the cell's rest geometry. Note: even though the simulator needs only the relative positions of the corners, the absolute positions are needed for proper texture mapping. *) TYPE List = ARRAY OF T; Num = CARDINAL; (* Index in a "List" *) Name = TEXT; CONST None = LAST(CARDINAL); (* NIL value for "Num" *) PROCEDURE Find(READONLY cell: List; name: Name): Num; (* Returns the cell number given the cell name. *) PROCEDURE Copy(READONLY cell: List; extra: CARDINAL := 0): REF List; (* Makes a copy of "cell", with extra room at the end for "extra" new cells. *) PROCEDURE GetNames(READONLY cell: List; READONLY num: ARRAY OF Num): REF ARRAY OF Name; (* Makes a list of "cell[num[i]].name" for all "i" *) PROCEDURE GetNums(READONLY cell: List; READONLY name: ARRAY OF Name): REF ARRAY OF Num; (* Makes a list of "Find(cell, name[i])" for all "i" *) PROCEDURE Make(v0, v1, v2, v3: Vertex.Num; t: CornerTags; name: Name): T; (* Creates a cell with the specified vertices, tags, and name. The material and visual properties are set to "\"\"", and the rest geometry is the canonical tetrahedron. *) PROCEDURE SetRestGeometry(VAR cell: T; READONLY vertex: Vertex.List); (* Sets the rest geometry and volume of "cell", as implied by the position of its vertices in "vertex". Will also swap corners 1 and 2 if the four corners have a negative screw. *) PROCEDURE SetAllRestGeometries(VAR cell: List; READONLY vertex: Vertex.List); (* Applies "SetRestGeometry(c, m.vertex^)" to every cell "c" in "cell". *) PROCEDURE ReverseOrientation(VAR cell: T); (* Permutes the corners of the cell so as to reverse their orientation. *) PROCEDURE ReverseAllOrientations(VAR cell: List); (* Applies "ReverseOrientation(c)" to every cell "c" in "cell". *) PROCEDURE SetOrientation(VAR cell: T); (* Renumbers the corners of "cell" so that they have a positive screw in the rest configuration. *) PROCEDURE SetAllOrientations(VAR cell: List); (* Applies "SetOrientation(c)" to every cell "c" in "cell". *) PROCEDURE SetAllMaterials(VAR cell: List; mat: Material.Name); (* Sets the "mat" field of all the given cells. *) PROCEDURE SetAllVisuals(VAR cell: List; vis: Visual.Name); (* Sets the "vis" field of all the given cells. *) END Cell.