import java.awt.Rectangle; import java.util.Enumeration; import java.util.Vector; class Blob extends Composite implements java.io.Serializable { Blob() { inPnt = new cVector(); name = "Blob"; threshold = 30; cellSize = 4; tolerance = 0; //.1; } Object3D deepCopy() { Blob blob = new Blob(); deepCopySelf(blob); return blob; } protected void deepCopyNode(Object3D other) { super.deepCopyNode(other); Blob b = (Blob)other; b.threshold = threshold; b.cellSize = cellSize; b.tolerance = tolerance; } void generatePOV(StringBuffer buffer) { generateNameComment(buffer); generateIndent(buffer); buffer.append("blob { threshold "); buffer.append(threshold); buffer.append("\n"); BlobComponent child; for (Enumeration e = children.elements(); e.hasMoreElements(); child.generatePOV(buffer)) child = (BlobComponent)e.nextElement(); generateTransform(buffer); generateIndent(buffer); buffer.append("}\n"); } void createEditWindow(GroupEditor callee, boolean newWindow) { //editWindow = (new BlobEditor(this, deepCopy(), callee)).GetEditor(); if (newWindow) objectUI = new BlobEditor(this, deepCopy(), callee); else objectUI = new BlobEditor(this, callee); editWindow = objectUI.GetEditor(); } void draw(ClickInfo info, int level, boolean select) { drawSelf(info, level, select); if (level == 0 && (info.flags & 0x1) == 0) super.draw(info, level, select); } /* void draw000(javax.media.opengl.GL gl) { //drawSelf(gl); //if (level == 0 && (info.flags & 0x1) == 0) super.draw(gl); } */ boolean doSelection(ClickInfo info, Rectangle r, int level) { if (level == 0 && (info.flags & 0x1) == 0) return super.doSelection(info, r, level); else return doSelectionSelf(info, r, level); } void retile() { new Exception().printStackTrace(); System.exit(0); ClearList(); bRep = (new ImplicitTiler(this, ImplicitTiler.SURFACEID, true, true, true, cellSize, cellSize, tolerance, true)).bRep; } public void getBounds(cVector minima, cVector maxima, boolean xform) { if (children.size() == 0) { minima.x = minima.y = minima.z = -1; maxima.x = maxima.y = maxima.z = 1; return; } super.getBounds(minima, maxima, xform); /* Enumeration e = children.elements(); BlobComponent comp = (BlobComponent)e.nextElement(); double radius = comp.radius * 1.1; for (int i=0; i < 3; i++) { minima.set(i, comp.center.get(i) - radius); maxima.set(i, comp.center.get(i) + radius); } while (e.hasMoreElements()) { comp = (BlobComponent)e.nextElement(); radius = comp.radius * 1.1; for (int i=0; i < 3; i++) { if (comp.center.get(i) - radius < minima.get(i)) minima.set(i, comp.center.get(i) - radius); if (comp.center.get(i) + radius > maxima.get(i)) maxima.set(i, comp.center.get(i) + radius); } } if (xform) transformBounds(minima, maxima); */ } public boolean inside(double x, double y, double z, boolean xform) { //if (xform) // untransform(x, y, z, inPnt); //else // LA.setVector(inPnt, x, y, z); untransform(x, y, z, cStatic.point1); x = cStatic.point1.x; y = cStatic.point1.y; z = cStatic.point1.z; double total = 0; //for (Enumeration e = children.elements(); e.hasMoreElements();) for (int i=0; i threshold; } public void boxInside(double x[], double y[], double z[], boolean out[]) { double range[] = new double[2]; boxTotal(x, y, z, range); if (range[1] < threshold || range[0] > threshold) out[0] = out[1] = false; else if (x[1] - x[0] <= cellSize && y[1] - y[0] <= cellSize && z[1] - z[0] <= cellSize) { out[0] = out[1] = true; } else { out[0] = false; out[1] = true; } } private void boxTotal(double x[], double y[], double z[], double range[]) { double contrib[] = new double[2]; for (Enumeration e = children.elements(); e.hasMoreElements(); Interval.boxAdd(contrib, range, range)) { BlobComponent comp = (BlobComponent)e.nextElement(); comp.boxFieldStrength(x, y, z, contrib); } } double threshold; double cellSize; double tolerance; protected cVector inPnt; }