MODULE SPNHFindBasis EXPORTS Main; (* Finds a basis for the space H^d[T] + H^d-1[T], given the triangulation T. *) IMPORT SPTriang, SPPWFunction, SPOrthoBasis; 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 non-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: CARDINAL; (* 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; PROCEDURE Main() = BEGIN WITH o = GetOptions(), rd = FileRd.Open(o.triName & ".tri"), tri = MakeTriRef(SPTriang.Read(rd)), basis = SPOrthoBasis.BuildNHBasis(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, 6); pp.getKeyword("-continuity"); o.continuity := pp.getNextInt(0, 1); o.ortho := pp.keywordPresent("-ortho"); pp.finish(); END EXCEPT | ParseParams.Error => Wr.PutText(stderr, "Usage: SPNHFindBasis \\\n"); Wr.PutText(stderr, " -triName TRINAME \\\n"); Wr.PutText(stderr, " -outName BASISNAME \\\n"); Wr.PutText(stderr, " -degree NUM -continuity NUM \\\n"); Wr.PutText(stderr, " [ -ortho ] \n"); Process.Exit (1); END; RETURN o END GetOptions; BEGIN Main() END SPNHFindBasis.