// gear12.java compile javac -cp . gear12.java 2D to3D new z=10.0 // execute java -cp . gear12 writes gear12d3.java // reads gear12.dat // comes with center hole 12 points, make triangles // there are 16 points in each tooth, 192, 1, 2, ... 16 // 17, 18, ... 32 // 33, 34, ... 48 // ... 177, 178, ... 192 bot z=0 // 217 ...408 top z=10 // hole 193, 194, ... 204 --- to 1, 16, 17, 204 3 triangles bot // 409, 410, ... 420 217, 232, 233, 408 top // tooth center 205, 206, ... 216 bot // 421, 422, ... 432 top public class gear12 { int numteeth = 12; int ptteeth = 12*16; // plus numteeth tooth centers and numteeth hole double xyz[][] = new double[2*(216+8)][3]; // 216+8 layer plus bottom double xyzt[][] = new double[2*(216+8)][3]; // gear12tt.dat top int polyst[] = new int[4*4*(216+8)]; int num_points = 204; // coming in from gear12.dat 1..192 outline // 193..204 hole int num_polys = 204; // coming in from gear12.dat int num_tpoints = 0; // for gear12t.dat + 12 tooth centers int num_tpoly = 0; // computed int new_points = 0; // computed int new_polys = 0; // computed int newt_polys = 0; int newt_points = 0; int oldpolys[] = new int[3*204]; // just 2 1 2 int polys[] = new int[4*4*244]; // 3 1 2 205, double times 2 for outside String filename = "gear12.dat"; // datread String filetri = "gear12t.dat"; // datwrite with triangles String filetrit = "gear12tt.dat"; // datwrite top z=10 String fileout = "gear12d3.dat"; // datwrite datread DR; double g12[][] = new double[12][3]; // for new tooth center points double r = 0.0; double rc = 22.73; // from gear12.dat, tooth 2 int pc = 205; // first of numteeth tooth centers double x = 0.0; double y = 0.0; double z = 10.0; double Pi = Math.PI; double ang = 0.0; double dang = -Pi/6.0; // numteeth/2 of tooth centers int k = 0; int kn = 0; int pt = 0; int pt2 = 0; int pt3 = 0; int pt4 = 0; int pt5 = 0; int pts = 0; int ptc = 204; // first added point int ptz = 204; // tooth center double xmin, xmax, ymin, ymax, zmin, zmax; public gear12() { System.out.println("gear12,java running"); 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; i3 && i<125) System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); polys[k++] = 3; polys[k++] = pt+1; polys[k++] = pt2+1; polys[k++] = pt2; if(i>3 && i<125) System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); pt = pt+1; pt2 = pt2+1; } // end i then 128 1 145 1 145 272 polys[k++] = 3; polys[k++] = 128; polys[k++] = 1; polys[k++] = 145; System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); polys[k++] = 3; polys[k++] = 1; polys[k++] = 145; polys[k++] = 272; System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); System.out.println("outside hole 129-136 273-280"); // outside hole 129-136 273-280 pt = 129; pt2 = 273; for(int i=0; i<7; i++) // one less { polys[k++] = 3; polys[k++] = pt; polys[k++] = pt+1; polys[k++] = pt2; System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); polys[k++] = 3; polys[k++] = pt+1; polys[k++] = pt2+1; polys[k++] = pt2; System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); pt = pt+1; pt2 = pt2+1; } // end i then 136 129 280 129 272 280 polys[k++] = 3; polys[k++] = 136; polys[k++] = 129; polys[k++] = 280; System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); polys[k++] = 3; polys[k++] = 129; polys[k++] = 272; polys[k++] = 280; System.out.println("polys["+(k-4)+"]="+polys[k-4]+" "+polys[k-3]+" "+polys[k-2]+" "+polys[k-1]); new_polys = k/4; System.out.println("new_polys="+new_polys+" k="+k); System.out.println("datwrite "+fileout+" new_points="+new_points+ " new_polys="+new_polys); new datwrite(fileout, xyz, new_points, polys, new_polys); System.out.println("datwrite wrote "+fileout); System.out.println("gear12.java ends"); } public static void main (String[] args) { new gear12(); // filenames built in } } // end gear12.java