/*----------------------------------------------------------------------*/ /* HBlock -- contains hyperblock data */ /*----------------------------------------------------------------------*/ /* Jim Morey -- morey@math.ubc.ca -- February 4, 1997 */ /*----------------------------------------------------------------------*/ import java.io.*; import java.awt.*; import java.lang.*; import java.awt.Color; import java.net.*; import O4matrix; public class HBlock extends Object{ public O4matrix orient; public int cenx,ceny,W,H,npoints,ncons; public double Scale,Zeye=10; public int[][][][] hblock; public double[][] points, rotPts; public int[][] cons, scrPts; public int[] dim; Color colours[]; int colourIndex=0; HBlock(InputStream is, int wid, int heig) throws IOException{ getSolidData(is); rotPts = new double[npoints][4]; scrPts = new int[npoints][2]; /* .. regular setup .. */ W = wid / 2; H = heig / 2; orient = new O4matrix(); int i,j; double bound[][]; bound = new double[4][2]; double len; for (i=0;i<4;i++){ bound[i][0]= 100000; bound[i][1]= -100000; } for (i=0;i points[i][j]) bound[j][0] = points[i][j]; if (bound[j][1]< points[i][j]) bound[j][1] = points[i][j]; } } double max=0; for (i=0;i<4;i++){ max+= (bound[i][1]-bound[i][0])*(bound[i][1]-bound[i][0]); bound[i][0] = (bound[i][0]+bound[i][1])/2; } max = Math.sqrt(max)/1.4; for (i=0;iH) Scale= (double)H/max; else Scale= (double)W/max; CalcScrPts((double)W,(double)H,0); colours = new Color[4]; colourChange(); } /* - - - - - - - - - - - - - - - */ void colourChange(){ colours[colourIndex %4] = Color.black; colours[(colourIndex+1) %4] = Color.red; colours[(colourIndex+2) %4] = Color.white; colours[(colourIndex+3) %4] = Color.blue; colourIndex++; } /* - - - - - - - - - - - - - - - */ void getSolidData(InputStream is) throws IOException{ String str, name, thing; StreamTokenizer token = new StreamTokenizer(is); token.eolIsSignificant(false); token.commentChar('#'); /* .. get the block parameters .. */ dim = new int[4]; token.nextToken(); dim[0] = (int)token.nval; token.nextToken(); dim[1] = (int)token.nval; token.nextToken(); dim[2] = (int)token.nval; token.nextToken(); dim[3] = (int)token.nval; token.nextToken(); npoints = (int)token.nval; token.nextToken(); ncons = (int)token.nval; /* .. get the block data .. */ hblock = new int[dim[0]][dim[1]][dim[2]][dim[3]]; points = new double[npoints][4]; cons = new int[ncons][3]; npoints = 0; ncons = 0; for (int i=0;i-1 && i-1 && j-1 && k-1 && m