}
private Point4f planeParameter(int i) throws ScriptException {
Vector3f vAB = new Vector3f();
Vector3f vAC = new Vector3f();
Point4f plane = null;
boolean isNegated = (tokAt(i) == Token.minus);
if (isNegated)
i++;
if (i < statementLength)
switch (getToken(i).tok) {
case Token.point4f:
plane = (Point4f) theToken.value;
break;
case Token.dollarsign:
String id = objectNameParameter(++i);
if (isSyntaxCheck)
return new Point4f();
int shapeType = shapeManager.getShapeIdFromObjectName(id);
switch (shapeType) {
case JmolConstants.SHAPE_DRAW:
setShapeProperty(JmolConstants.SHAPE_DRAW, "thisID", id);
Point3f[] points = (Point3f[]) getShapeProperty(
JmolConstants.SHAPE_DRAW, "vertices");
if (points == null || points.length < 3 || points[0] == null
|| points[1] == null || points[2] == null)
break;
plane = Measure.getPlaneThroughPoints(points[0], points[1],
points[2], new Vector3f(), vAB, vAC);
break;
case JmolConstants.SHAPE_ISOSURFACE:
setShapeProperty(JmolConstants.SHAPE_ISOSURFACE, "thisID", id);
plane = (Point4f) getShapeProperty(JmolConstants.SHAPE_ISOSURFACE,
"plane");
break;
}
break;
case Token.x:
if (!checkToken(++i) || getToken(i++).tok != Token.opEQ)
evalError("x=?", null);
plane = new Point4f(1, 0, 0, -floatParameter(i));
break;
case Token.y:
if (!checkToken(++i) || getToken(i++).tok != Token.opEQ)
evalError("y=?", null);
plane = new Point4f(0, 1, 0, -floatParameter(i));
break;
case Token.z:
if (!checkToken(++i) || getToken(i++).tok != Token.opEQ)
evalError("z=?", null);
plane = new Point4f(0, 0, 1, -floatParameter(i));
break;
case Token.identifier:
case Token.string:
String str = parameterAsString(i);
if (str.equalsIgnoreCase("xy"))
return new Point4f(0, 0, 1, 0);
if (str.equalsIgnoreCase("xz"))
return new Point4f(0, 1, 0, 0);
if (str.equalsIgnoreCase("yz"))
return new Point4f(1, 0, 0, 0);
iToken += 2;
break;
case Token.leftbrace:
if (!isPoint3f(i)) {
plane = getPoint4f(i);
break;
}
// fall through
case Token.bitset:
case Token.expressionBegin:
Point3f pt1 = atomCenterOrCoordinateParameter(i);
if (getToken(++iToken).tok == Token.comma)
++iToken;
Point3f pt2 = atomCenterOrCoordinateParameter(iToken);
if (getToken(++iToken).tok == Token.comma)
++iToken;
Point3f pt3 = atomCenterOrCoordinateParameter(iToken);
i = iToken;
Vector3f norm = new Vector3f();
float w = Measure.getNormalThroughPoints(pt1, pt2, pt3, norm, vAB, vAC);
plane = new Point4f(norm.x, norm.y, norm.z, w);
if (!isSyntaxCheck && Logger.debugging)
Logger.debug("points: " + pt1 + pt2 + pt3 + " defined plane: "
+ plane);
break;
}
if (plane == null)
planeExpected();
if (isNegated) {
plane.scale(-1);
}
return plane;
}