void setupMep() {
		Atom[] atoms = frame.atoms;
		Point3f xyzMin = new Point3f(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
		Point3f xyzMax = new Point3f(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);
		int modelIndex = viewer.getDisplayModelIndex();
		int iAtom = 0;
		int nSelected = 0;
		iUseBitSets = true;
		int nAtoms = viewer.getAtomCount();
		for (int i = 0; i < nAtoms; i++)
			if (atoms[i].modelIndex == modelIndex) {
				++iAtom;
				if (bsSelected.get(i))
					++nSelected;
			}
		mep_nAtoms = iAtom;
		if (nSelected > 0)
			Logger.info(nSelected + " of " + mep_nAtoms + " atoms will be used in the mep calculation");
		if (mep_nAtoms > 0)
			mep_atoms = new Atom[mep_nAtoms];
		iAtom = 0;
		for (int i = 0; i < nAtoms; i++) {
			Atom atom = atoms[i];
			if (atom.modelIndex != modelIndex)
				continue;
			Point3f pt = new Point3f(atom);
			if (bsSelected.get(i)) {
				float rA = atom.getVanderwaalsRadiusFloat() + mep_marginAngstroms;
				if (pt.x - rA < xyzMin.x)
					xyzMin.x = pt.x - rA;
				if (pt.x + rA > xyzMax.x)
					xyzMax.x = pt.x + rA;
				if (pt.y - rA < xyzMin.y)
					xyzMin.y = pt.y - rA;
				if (pt.y + rA > xyzMax.y)
					xyzMax.y = pt.y + rA;
				if (pt.z - rA < xyzMin.z)
					xyzMin.z = pt.z - rA;
				if (pt.z + rA > xyzMax.z)
					xyzMax.z = pt.z + rA;
				mep_atoms[iAtom++] = atom;
			}
			else {
				++iAtom;
			}
		}
		if (!Float.isNaN(scale)) {
			Vector3f v = new Vector3f(xyzMax);
			v.sub(xyzMin);
			v.scale(0.5f);
			xyzMin.add(v);
			v.scale(scale);
			xyzMax.set(xyzMin);
			xyzMax.add(v);
			xyzMin.sub(v);
		}

		Logger.info("MEP range bohr " + xyzMin + " to " + xyzMax);
		jvxlFileHeader = new StringBuffer();
		jvxlFileHeader.append("MEP range bohr " + xyzMin + " to " + xyzMax + "\n");

		int maxGrid = mep_gridMax;

		setVoxelRange(0, xyzMin.x, xyzMax.x, mep_ptsPerAngstrom, maxGrid);
		setVoxelRange(1, xyzMin.y, xyzMax.y, mep_ptsPerAngstrom, maxGrid);
		setVoxelRange(2, xyzMin.z, xyzMax.z, mep_ptsPerAngstrom, maxGrid);
		jvxlFileHeader.append(jvxlGetVolumeHeader(iAtom));
		Point3f pt = new Point3f();
		for (int i = 0; i < nAtoms; i++) {
			Atom atom = atoms[i];
			if (atom.modelIndex != modelIndex)
				continue;
			pt.set(atom);
			pt.scale(1 / ANGSTROMS_PER_BOHR);
			jvxlFileHeader.append(atom.getAtomicAndIsotopeNumber() + " " + atom.getAtomicAndIsotopeNumber() + ".0 "
					+ pt.x + " " + pt.y + " " + pt.z + "\n");
		}
		atomCount = -Integer.MAX_VALUE;
		negativeAtomCount = false;
		precalculateVoxelData = true;
	}