INTERFACE Model; (* A model of a deformable object, with named vertices and cells. *) (* Created 1995/1996 by J. Stolfi and R. L. W. Liesenfeld. *) IMPORT Vertex, Cell; TYPE T = RECORD vertex: REF Vertex.List; cell: REF Cell.List; name: TEXT; END; TYPE Name = TEXT; (* Name of a model *) PROCEDURE Empty(): T; (* The trivial model with no vertices and no cells. *) (* TOPOLOGICAL OPERATIONS *) (* The following procedures generally produce new models with a different vertex and cell sets, and/or a different topology. Note that vertex and cell numbers are usually invalidated by operations that change the topology, even when the element itself is preserved. To identify cells and vertices in the resulting model, use their names: the topological operations generally preserve names, or modify them predictable ways. *) PROCEDURE Merge(name: Name; READONLY part: ARRAY OF T): T; (* Merges zero or more models into a single model, renumbering the vertices with disjoint ranges. The names of vertices and cells from "part[i]" will get qualified with the prefix "part[i].name" and a dot (see "QualifyName"). *) PROCEDURE IdentifyVertices(READONLY m: T; READONLY pair: ARRAY OF VertexPair): T; (* Returns a new model, obtained from "m" by identifying the pairs of vertices whose numbers are listed in "pair". The identifications are applied in order. Whenever "u" is identified with "v", the merged vertex will receive "v"'s current position and name. *) TYPE VertexPair = ARRAY [0..1] OF Vertex.Num; PROCEDURE WeldParts(READONLY m: T; READONLY weld: ARRAY OF Weld := ARRAY OF Weld{}): T; (* Applies "IdentifyVertices" to pairs of vertices named by the "weld" array. The "name" of the result is that of "m". *) TYPE Weld = ARRAY [0..1] OF Joint; (* A pair of joints TO be welded together. Specifies that each vertex named in the fist joint whould be identified with the corresponding vertex in the second joint. *) Joint = RECORD part: Name := ""; vertex: REF ARRAY OF Vertex.Name; END; (* An ordered list of vertex names, implicitly qualified with the "part" name and a dot (see "QualifyName"). *) (* LOW-LEVEL HACKS *) PROCEDURE QualifyName(prefix, name: TEXT): TEXT; (* If "prefix" is empty, returns "name" itself, else prepends "prefix" and a dot to "name". *) PROCEDURE Merge2Names(u, v: TEXT; lp, rp: TEXT): TEXT; PROCEDURE Merge3Names(u, v, w: TEXT; lp, rp: TEXT): TEXT; (* Factors a common prefix of the given names, using "lp" and "rp" as delimiters. E.g., given "u = \"xxyyzz\"" and "v = \"xxwwzz\"" returns "\"xx(yyzz,wwzz)\"". These procedures are used to make up edge and face names from the nemes of their vertices. *) END Model.