// tri_split.java plot 3d data Utah graphics .dat // java -cp . tri_split inp.dat out.dat // split every triangle into 4 triangle // ip1 np1 ip2 // *---+---* // \1/4\2/ * initial points // np3 +---+ np2 + new points at edge center of initial triangle // \3/ four triangles replace initial triangle // * remember, in utah .dat ip and np are +1 of subscript // ip3 import java.io.*; import java.awt.*; import java.awt.event.*; public class tri_split extends Frame { // mouse and display variables boolean debug = true; int xm, ym, bm; // mouse position int height = 700; int width = 700; double xmin, xmax, ymin, ymax, zmin, zmax; double ya, xs, ys, zs; // scale for data 0..1 int xp, yp; // ortho returns int pts, pt, k; datread DR; // = new datread(filename); // defines data structures int grid = 1; // box off/on int colora = 0; // black, X, Y, Z int points = 0; // lines, points only, both int num_points = 0; // set from datread int num_polys = 0; // set from datread int new_points = 0; // 3 added for each poly (triangle) int new_polys = 0; // 1 changed and 3 added for each poly double xyz[][] = new double[5000][3]; // x, y, z for output int newpts[] = new int[10000]; // 3, xyz1, xyz2, xyz3 for output public tri_split(String filename, String fileout) { System.out.println("tri_split.java running"); setTitle("tri_split"); setSize(width,height); setBackground(Color.white); setForeground(Color.black); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); this.addMouseListener (new mousePressHandler()); System.out.println("datread.java reading "+filename); DR = new datread(filename); // defines data structures num_points = DR.num_points; num_polys = DR.num_polys; System.out.println("num_points="+DR.num_points+ ", num_polys="+DR.num_polys); System.out.println("print vertices"); xmin = DR.data_points[0].x; xmax = DR.data_points[0].x; ymin = DR.data_points[0].y; ymax = DR.data_points[0].y; zmin = DR.data_points[0].z; zmax = DR.data_points[0].z; for(int i=0; i