use of cbit.vcell.render.Vect3d in project vcell by virtualcell.
the class HitEventRational method toString.
public String toString() {
Vect3d unitNormal = new Vect3d();
polygon.getUnitNormal(unitNormal);
return "HitEvent(rayZ=" + getHitRayZ() + ", centroidZ=" + getCentroidZ() + ", unitNormalInRayDirection=" + getUnitNormalInRayDirection() + ", polygon=" + polygon.toString() + ", normal=" + unitNormal + ", surface=" + surface.toString() + ", interiorMask=" + surface.getInteriorMask() + ", exteriorMask=" + surface.getExteriorMask() + ", extraMessage=\"" + debugMessage + "\"";
}
use of cbit.vcell.render.Vect3d in project vcell by virtualcell.
the class HitEvent method toString.
public String toString() {
Vect3d unitNormal = new Vect3d();
polygon.getUnitNormal(unitNormal);
return "HitEvent(rayZ=" + hitRayZ + ", centroidZ=" + centroidZ + ", unitNormalInRayDirection=" + unitNormalInRayDirection + ", polygon=" + polygon.toString() + ", normal=" + unitNormal + ", surface=" + surface.toString() + ", interiorMask=" + surface.getInteriorMask() + ", exteriorMask=" + surface.getExteriorMask() + ", extraMessage=\"" + debugMessage + "\"";
}
use of cbit.vcell.render.Vect3d in project vcell by virtualcell.
the class SurfaceRenderer method paintBoundingBox.
/**
* Insert the method's description here.
* Creation date: (11/26/2003 12:40:37 PM)
* @param g2d java.awt.Graphics
*/
private void paintBoundingBox(java.awt.Graphics g, double xScale, double yScale, double xOffset, double yOffset, double depthCue, boolean bDrawFrontOnly) {
try {
java.awt.Graphics2D g2d = (java.awt.Graphics2D) g;
double ox = fieldOrigin.getX();
double oy = fieldOrigin.getY();
double oz = fieldOrigin.getZ();
double ex = fieldExtent.getX();
double ey = fieldExtent.getY();
double ez = fieldExtent.getZ();
Vect3d[] boundingBoxCorners = { new Vect3d(ox + 0 * ex, oy + 0 * ey, oz + 0 * ez), new Vect3d(ox + 0 * ex, oy + 0 * ey, oz + 1 * ez), new Vect3d(ox + 0 * ex, oy + 1 * ey, oz + 0 * ez), new Vect3d(ox + 0 * ex, oy + 1 * ey, oz + 1 * ez), new Vect3d(ox + 1 * ex, oy + 0 * ey, oz + 0 * ez), new Vect3d(ox + 1 * ex, oy + 0 * ey, oz + 1 * ez), new Vect3d(ox + 1 * ex, oy + 1 * ey, oz + 0 * ez), new Vect3d(ox + 1 * ex, oy + 1 * ey, oz + 1 * ez) };
double[] cornerZ = new double[8];
double minZ = Double.POSITIVE_INFINITY;
double maxZ = Double.NEGATIVE_INFINITY;
Vect3d proj = new Vect3d();
for (int i = 0; i < boundingBoxCorners.length; i++) {
getTrackball().getCamera().projectPoint(boundingBoxCorners[i], proj);
minZ = Math.min(minZ, proj.getZ());
maxZ = Math.max(maxZ, proj.getZ());
cornerZ[i] = proj.getZ();
}
double frontThreshold = (minZ + 0.001 * (maxZ - minZ));
Vect3d pt1a = new Vect3d();
Vect3d pt2a = new Vect3d();
Vect3d pt1b = new Vect3d();
Vect3d pt2b = new Vect3d();
Vect3d pt1c = new Vect3d();
Vect3d pt2c = new Vect3d();
Vect3d pt1d = new Vect3d();
Vect3d pt2d = new Vect3d();
Vect3d proj1 = new Vect3d();
Vect3d proj2 = new Vect3d();
java.awt.geom.Line2D.Double line = new java.awt.geom.Line2D.Double();
//
for (int direction = 0; direction < 3; direction++) {
double deltaX = 0.0;
double deltaY = 0.0;
double deltaZ = 0.0;
boolean bRenderA = true;
boolean bRenderB = true;
boolean bRenderC = true;
boolean bRenderD = true;
switch(direction) {
case 0:
{
// yz plane (go in x)
deltaX = ex;
// 0 to 4
pt1a.set(ox, oy, oz);
// 1 to 5
pt1b.set(ox, oy, oz + ez);
// 2 to 6
pt1c.set(ox, oy + ey, oz);
// 3 to 7
pt1d.set(ox, oy + ey, oz + ez);
bRenderA = (!bDrawFrontOnly || (cornerZ[0] < frontThreshold || cornerZ[4] < frontThreshold) && bDrawFrontOnly);
bRenderB = (!bDrawFrontOnly || (cornerZ[1] < frontThreshold || cornerZ[5] < frontThreshold) && bDrawFrontOnly);
bRenderC = (!bDrawFrontOnly || (cornerZ[2] < frontThreshold || cornerZ[6] < frontThreshold) && bDrawFrontOnly);
bRenderD = (!bDrawFrontOnly || (cornerZ[3] < frontThreshold || cornerZ[7] < frontThreshold) && bDrawFrontOnly);
break;
}
case 1:
{
// xz plane (go in y)
deltaY = ey;
// 0 to 2
pt1a.set(ox, oy, oz);
// 1 to 3
pt1b.set(ox, oy, oz + ez);
// 4 to 6
pt1c.set(ox + ex, oy, oz);
// 5 to 7
pt1d.set(ox + ex, oy, oz + ez);
bRenderA = (!bDrawFrontOnly || (cornerZ[0] < frontThreshold || cornerZ[2] < frontThreshold) && bDrawFrontOnly);
bRenderB = (!bDrawFrontOnly || (cornerZ[1] < frontThreshold || cornerZ[3] < frontThreshold) && bDrawFrontOnly);
bRenderC = (!bDrawFrontOnly || (cornerZ[4] < frontThreshold || cornerZ[6] < frontThreshold) && bDrawFrontOnly);
bRenderD = (!bDrawFrontOnly || (cornerZ[5] < frontThreshold || cornerZ[7] < frontThreshold) && bDrawFrontOnly);
break;
}
case 2:
{
// xy plane (go in z)
deltaZ = ez;
// 0 to 1
pt1a.set(ox, oy, oz);
// 2 to 3
pt1b.set(ox, oy + ey, oz);
// 4 to 5
pt1c.set(ox + ex, oy, oz);
// 6 to 7
pt1d.set(ox + ex, oy + ey, oz);
bRenderA = (!bDrawFrontOnly || (cornerZ[0] < frontThreshold || cornerZ[1] < frontThreshold) && bDrawFrontOnly);
bRenderB = (!bDrawFrontOnly || (cornerZ[2] < frontThreshold || cornerZ[3] < frontThreshold) && bDrawFrontOnly);
bRenderC = (!bDrawFrontOnly || (cornerZ[4] < frontThreshold || cornerZ[5] < frontThreshold) && bDrawFrontOnly);
bRenderD = (!bDrawFrontOnly || (cornerZ[6] < frontThreshold || cornerZ[7] < frontThreshold) && bDrawFrontOnly);
break;
}
}
int numSteps = 20;
double STEP = 1.0 / numSteps;
for (int i = 0; i < numSteps; i++) {
if (bRenderA) {
pt2a.set(pt1a.getX() + deltaX * STEP, pt1a.getY() + deltaY * STEP, pt1a.getZ() + deltaZ * STEP);
if (getTrackball().getCamera().projectLine(pt1a, pt2a, proj1, proj2)) {
double pt1x = xOffset + xScale * proj1.getX();
double pt1y = yOffset + yScale * proj1.getY();
double pt2x = xOffset + xScale * proj2.getX();
double pt2y = yOffset + yScale * proj2.getY();
double avgZ = (proj1.getZ() + proj2.getZ()) / 2.0;
float colorScale = (float) (1.0 - depthCue * (avgZ - minZ));
colorScale = (float) Math.min(1.0, Math.max(0.0, colorScale));
g2d.setColor(new java.awt.Color(colorScale, colorScale, colorScale));
line.setLine(pt1x, pt1y, pt2x, pt2y);
g2d.draw(line);
// Draw axis labels
if (i == 0) {
if (axisLabelFont == null) {
axisLabelFont = g2d.getFont().deriveFont(java.awt.Font.BOLD).deriveFont(160.0f);
}
g2d.setFont(axisLabelFont);
cbit.vcell.render.Vect3d dirVect = new cbit.vcell.render.Vect3d(pt2x - pt1x, pt2y - pt1y, 0);
if (dirVect.getX() != 0 || dirVect.getY() != 0) {
dirVect.unit();
dirVect.scale(300);
g2d.drawString((direction == 0 ? "X" : (direction == 1 ? "Y" : "Z")), (float) (pt1x + dirVect.getX()), (float) (pt1y + dirVect.getY()));
}
}
}
pt1a.set(pt2a);
}
if (bRenderB) {
pt2b.set(pt1b.getX() + deltaX * STEP, pt1b.getY() + deltaY * STEP, pt1b.getZ() + deltaZ * STEP);
if (getTrackball().getCamera().projectLine(pt1b, pt2b, proj1, proj2)) {
double pt1x = xOffset + xScale * proj1.getX();
double pt1y = yOffset + yScale * proj1.getY();
double pt2x = xOffset + xScale * proj2.getX();
double pt2y = yOffset + yScale * proj2.getY();
double avgZ = (proj1.getZ() + proj2.getZ()) / 2.0;
float colorScale = (float) (1.0 - depthCue * (avgZ - minZ));
colorScale = (float) Math.min(1.0, Math.max(0.0, colorScale));
g2d.setColor(new java.awt.Color(colorScale, colorScale, colorScale));
line.setLine(pt1x, pt1y, pt2x, pt2y);
g2d.draw(line);
}
pt1b.set(pt2b);
}
if (bRenderC) {
pt2c.set(pt1c.getX() + deltaX * STEP, pt1c.getY() + deltaY * STEP, pt1c.getZ() + deltaZ * STEP);
if (getTrackball().getCamera().projectLine(pt1c, pt2c, proj1, proj2)) {
double pt1x = xOffset + xScale * proj1.getX();
double pt1y = yOffset + yScale * proj1.getY();
double pt2x = xOffset + xScale * proj2.getX();
double pt2y = yOffset + yScale * proj2.getY();
double avgZ = (proj1.getZ() + proj2.getZ()) / 2.0;
float colorScale = (float) (1.0 - depthCue * (avgZ - minZ));
colorScale = (float) Math.min(1.0, Math.max(0.0, colorScale));
g2d.setColor(new java.awt.Color(colorScale, colorScale, colorScale));
line.setLine(pt1x, pt1y, pt2x, pt2y);
g2d.draw(line);
}
pt1c.set(pt2c);
}
if (bRenderD) {
pt2d.set(pt1d.getX() + deltaX * STEP, pt1d.getY() + deltaY * STEP, pt1d.getZ() + deltaZ * STEP);
if (getTrackball().getCamera().projectLine(pt1d, pt2d, proj1, proj2)) {
double pt1x = xOffset + xScale * proj1.getX();
double pt1y = yOffset + yScale * proj1.getY();
double pt2x = xOffset + xScale * proj2.getX();
double pt2y = yOffset + yScale * proj2.getY();
double avgZ = (proj1.getZ() + proj2.getZ()) / 2.0;
float colorScale = (float) (1.0 - depthCue * (avgZ - minZ));
colorScale = (float) Math.min(1.0, Math.max(0.0, colorScale));
g2d.setColor(new java.awt.Color(colorScale, colorScale, colorScale));
line.setLine(pt1x, pt1y, pt2x, pt2y);
g2d.draw(line);
}
pt1d.set(pt2d);
}
}
}
} catch (Throwable e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.render.Vect3d in project vcell by virtualcell.
the class SurfaceRenderer method calculateProjectedCentroid.
/**
* Insert the method's description here.
* Creation date: (10/11/2005 7:46:34 AM)
*/
private void calculateProjectedCentroid(Polygon polygon, cbit.vcell.render.Vect3d centroid, cbit.vcell.render.Vect3d centroidProj) {
int polygonDim = polygon.getNodeCount();
centroid.set(0, 0, 0);
for (int k = 0; k < polygonDim; k++) {
cbit.vcell.geometry.surface.Node node = polygon.getNodes(k);
centroid.add(new Vect3d(node.getX(), node.getY(), node.getZ()));
}
centroid.scale(1.0 / polygonDim);
getTrackball().getCamera().projectPoint(centroid, centroidProj);
}
use of cbit.vcell.render.Vect3d in project vcell by virtualcell.
the class XmlReader method getCSGRotation.
private CSGRotation getCSGRotation(Element param) throws XmlParseException {
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String rotateXStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationXTag));
String rotateYStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationYTag));
String rotateZStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationZTag));
String rotationAngleStr = unMangle(param.getAttributeValue(XMLTags.CSGRotationAngleInRadiansTag));
Vect3d rotationAxis = new Vect3d(Double.parseDouble(rotateXStr), Double.parseDouble(rotateYStr), Double.parseDouble(rotateZStr));
CSGRotation csgRotation = new CSGRotation(name, rotationAxis, Double.parseDouble(rotationAngleStr));
// Retrieve CSGNode - CSGRotation element should have one child
Object[] elements = param.getChildren().toArray();
if (elements.length > 1) {
throw new XmlParseException("CSGRotation element cannot have more than one child element");
}
CSGNode csgChildNode = getCSGNode((Element) elements[0]);
csgRotation.setChild(csgChildNode);
return csgRotation;
}
Aggregations