// tri_split44.java split 4D data Utah graphics .dat and plot // split every 5 point into 3 triangle // split every quadrangle into 2 triangle // split every triangle into 4 triangle // may use dat_clean44.java later // // 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 // ip1 *--* ip2 no new points // ip1 |\ | 4 1 2 3 4 replaced by: // ip5 *---*---* ip2 | \| 3 1 2 3 // \ / \ / ip4 *--* ip3 3 3 4 1 // ip4 *---* ip3 // // 5 1 2 3 4 5 replaced by 3 1 2 3 3 3 4 1 3 4 5 1 import java.io.*; import java.awt.*; import java.awt.event.*; public class tri_split44 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, wmin, wmax; double ya, xs, ys, zs; // scale for data 0..1 int xp, yp; // ortho returns int pts, pt, k; datread44 DR; // = new datread44(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 xyzw[][] = new double[5000][4]; // x, y, z, w for output int newpts[] = new int[10000]; // 3, xyzw1, xyzw2, xyzw3 for output public tri_split44(String filename, String fileout) { System.out.println("tri_split44.java running"); setTitle("tri_split44"); 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("datread44.java reading "+filename); DR = new datread44(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 input"); 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; wmin = DR.data_points[0].z; wmax = DR.data_points[0].z; for(int i=0; i5) { for(int j=0; j3) { newpts[new_polys++] = 3; newpts[new_polys++] = DR.data_polys[k]; // 3 newpts[new_polys++] = DR.data_polys[k++]; // 4 newpts[new_polys++] = DR.data_polys[k-4]; // 1 } if(pts>4) { newpts[new_polys++] = 3; newpts[new_polys++] = DR.data_polys[k]; // 4 newpts[new_polys++] = DR.data_polys[k++]; // 5 newpts[new_polys++] = DR.data_polys[k-5]; // 1 } } // end else } // end copy polygons new_polys = new_polys/4; System.out.println("split new_points="+new_points+", new_polys="+new_polys); num_polys = new_polys; for(int i=0; i