All the information is there, but to adjust the sphere radius I had to do a replacement as follows:
spaceFilledPlot[latticeType_] :=
LatticeData[latticeType, "Image"] /.
Sphere[pt_, r_] :> {Opacity[.5],
Sphere[pt, LatticeData[latticeType, "PackingRadius"]]}
spaceFilledPlot["FaceCenteredCubic"]
I added the opacity for better visibility of the underlying lattice.
Oh, and you wanted to crop at the boundaries:
Show[
spaceFilledPlot["FaceCenteredCubic"],
PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]
Edit
In response to the comment, here is how one could replace the spheres in the default plot by RegionPlot
so that the cut surfaces show up in a cropped display, giving a more solid appearance:
volumetricPlot[latticeType_] := Module[
{
img = LatticeData[latticeType, "Image"],
r = LatticeData[latticeType, "PackingRadius"]
},
Show[
img /. Sphere[pt_, r_] :> {},
Map[
RegionPlot3D[(EuclideanDistance[{x, y, z}, #] < r),
{x, -1, 1}, {y, -1, 1}, {z, -1, 1},
Mesh -> False,
PlotStyle -> Opacity[.5]
] &, Cases[img, Sphere[pos_, _] :> pos, Infinity]]
]
]
volumetricPlot["FaceCenteredCubic"]
Edit 2
There is at least one bug in LatticeData
. I just found this when thinking about how to crop a unit cell for a non-cubic lattice. So I tried the hexagonal close-packed structure, which is closely related to the previous example. But here is the plot:
volumetricPlot["HexagonalClosePacking"]
This is clearly not very closely packed! The error is in the "Image"
data for this lattice. It's very easy to spot this when you use my function because it expands the spheres to where they should touch. So I'd recommend being very careful when using these data. A somewhat better-working notebook for this case can be downloaded from Mathworld.
As a temporary fix for the issue with the hcp lattice, you could use the following modification of the plotting function in the question:
volumetricPlot[latticeType_] := Module[
{pts,
img = LatticeData[latticeType, "Image"],
r = LatticeData[latticeType, "PackingRadius"]},
If[latticeType == "HexagonalClosePacking",
pts = {{-1, 0, Sqrt[2/3]}, {-(1/2), Sqrt[3]/2, Sqrt[2/
3]}, {-(1/2), -(Sqrt[3]/2), Sqrt[2/3]}, {0, 0, Sqrt[2/3]}, {1/2,
Sqrt[3]/2, Sqrt[2/3]}, {1/2, -(Sqrt[3]/2), Sqrt[2/3]}, {1, 0,
Sqrt[2/3]}, {-(1/2), 1/(2 Sqrt[3]), 0}, {0,
1/(2 Sqrt[3]) - Sqrt[3]/2, 0}, {1/2, 1/(2 Sqrt[3]), 0}, {-1,
0, -Sqrt[(2/3)]}, {-(1/2), Sqrt[3]/
2, -Sqrt[(2/3)]}, {-(1/2), -(Sqrt[3]/2), -Sqrt[(2/3)]}, {0,
0, -Sqrt[(2/3)]}, {1/2, Sqrt[3]/2, -Sqrt[(2/3)]}, {1/
2, -(Sqrt[3]/2), -Sqrt[(2/3)]}, {1, 0, -Sqrt[(2/3)]}},
pts = Cases[img, Sphere[pos_, _] :> pos, Infinity]];
Show[img /. Sphere[pt_, r_] :> {},
Map[RegionPlot3D[(EuclideanDistance[{x, y, z}, #] < r), {x, -1,
1}, {y, -1, 1}, {z, -1, 1}, Mesh -> False,
PlotStyle -> Opacity[.5]] &, pts]]]
volumetricPlot["HexagonalClosePacking"]
This has the gaps corrected by shifting the z coordinates appropriately to make the center lie at the origin. The function handles the hcp case separately.