MODULE SPFindBasis EXPORTS Main; (* Finds a basis for the space H^d[T], given the triangulation T. *) IMPORT SPTriang, SPBasis, SPPWFunction; IMPORT ParseParams; IMPORT FileWr, FileRd, OSError, Thread, Wr, Process; FROM Stdio IMPORT stderr; <* FATAL Thread.Alerted, Wr.Failure, OSError.E *> (* This program reads a triangulation "T" and computes a basis for the space of piecewise homogeneous polynomials of a given degree over that triangulation. The basis elements are written out, in the Bezier coeffciient representation. *) TYPE Options = RECORD triName: TEXT; (* Name of triangulation file (minus the ".tri" extension). *) outName: TEXT; (* Name of basis file (minus the ".bas" extension) *) degree: NAT; (* Degree of polynomials in each triangle. *) continuity: [0..1]; (* Order of continuity across edges. *) ortho: BOOL; (* TRUE aplies the semi-orthogonalization heuristic *) END; BOOL = BOOLEAN; NAT = CARDINAL; PROCEDURE Main() = BEGIN WITH o = GetOptions(), rd = FileRd.Open(o.triName & ".tri"), tri = MakeTriRef(SPTriang.Read(rd)), basis = SPBasis.BuildHBasis(o.degree, o.continuity, tri, o.ortho)^, wr = FileWr.Open(o.outName & ".bas") DO SPPWFunction.WriteBasis(wr, basis); Wr.Close(wr) END END Main; PROCEDURE MakeTriRef(READONLY tri: SPTriang.T): REF SPTriang.T = BEGIN WITH t = NEW(REF SPTriang.T) DO t^ := tri; RETURN t END END MakeTriRef; PROCEDURE GetOptions (): Options = VAR o: Options; <* FATAL Wr.Failure, Thread.Alerted *> BEGIN TRY WITH pp = NEW(ParseParams.T).init(stderr) DO pp.getKeyword("-triName"); o.triName := pp.getNext(); pp.getKeyword("-outName"); o.outName := pp.getNext(); pp.getKeyword("-degree"); o.degree := pp.getNextInt(2, 7); pp.getKeyword("-continuity"); o.continuity := pp.getNextInt(0, 1); o.ortho := pp.keywordPresent("-ortho"); pp.finish(); END EXCEPT | ParseParams.Error => Wr.PutText(stderr, "Usage: SPFindBasis \\\n"); Wr.PutText(stderr, " -triName TRINAME \\\n"); Wr.PutText(stderr, " -outName BASISNAME \\\n"); Wr.PutText(stderr, " [ -ortho ] \\\n"); Wr.PutText(stderr, " -degree NUM -continuity NUN \n"); Process.Exit (1); END; RETURN o END GetOptions; BEGIN Main() END SPFindBasis.