// The interface to AMR visualization. // // An AMRCanvas is a collection of visualizable objects. // // To visualize grids and domains, add it to a canvas, and // update the canvas. In some implementations, objects may // also be individually removed from the canvas. // // Some implementations may also support on-the-fly update. /****************************************************************************** CHANGE LOG. 29 Nov 2000: Changed initOutput() to fail gracefully if plotfile can't be opened. [pike] ******************************************************************************/ import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.PrintStream; import java.io.IOException; import java.io.StreamTokenizer; // Temporary. import ti.domains.*; // Temporary end. class AMRCanvas { PrintStream out = null; public PrintStream initOutput() { try { out = new PrintStream(new FileOutputStream("plotfile")); } catch (IOException e) { System.err.println("Unable to open plotfile"); System.exit(-5); } return out; } // Add grid X to canvas at refinement level LEVEL. public double [3d] add(double [3d] x, int level) { return add(x, level, ""); } // ... with name NAME. public double [3d] add(double [3d] x, int level, String name) { if (out == null) out = initOutput(); return dump(x, level, name, out); } public static double [3d] dump(double [3d] x, int level, String name, PrintStream out) { if (name.equals("")) name = "(no name)"; out.println(name); out.println(level); out.println(x.domain().min()[1]); out.println(x.domain().min()[2]); out.println(x.domain().min()[3]); out.println(x.domain().max()[1]); out.println(x.domain().max()[2]); out.println(x.domain().max()[3]); foreach (p in x.domain()) { out.println(p[1]); out.println(p[2]); out.println(p[3]); out.println(x[p]); } return x; } // Remove grid X from canvas. No-op if object is not in // canvas. public void remove(double [3d] x) { } // Update canvas on screen. public void update() { out.flush(); } public static void dump(double [3d] x) { AMRCanvas canvas = new AMRCanvas(); canvas.add(x, 0); canvas.interact(); } // Give control to interactive visualizer. public void interact() { update(); System.out.print("Type return to continue"); System.out.flush(); try { System.in.read(); } catch (Throwable x) {} } }