# Fill in the hollow Spheres - generate solid spheres

I'd like to generate microstructures of composite materials and I use an algorithm to find the centers of the spheres knowing also the radius.

My problem is that I only want solid spheres in order to export in a next step this file in .obj type and then in .vtk type.

Does anyone know how to make the spheres solid in the whole sphere's volume?

The plot code I use is the next one:

Graphics3D[{Sphere[X, r]}, PlotRange -> {{0, L}, {0, L}, {0, L}}, Lighting -> Automatic]


where X corresponds to the center of the spheres.

Here is an example of my microstructure:

• Ball[X,r] is a solid. Dec 14, 2020 at 23:37
• This Compute Lattice Packing Densities:New in Wolfram Language 12 seems relevant. Dec 14, 2020 at 23:42
• @cvgmt Ball gives the same result Dec 14, 2020 at 23:43
• @TimLaska Thanks both of you for the quick response, but I forgot to say that I have downloaded the 11.3 version and as I tried the RegionPlot3D command I had the same problem because the spheres looked solid but when I exported in obj type, again looked hollow inside Dec 15, 2020 at 0:13
• Could you please let me know how to generate the microstructure you show in the first figure? I am trying to do the same, but I am now still stuck at this problem. Thank you so much. May 23, 2022 at 8:29

centers = RandomReal[{-2, 2}, {10, 3}];
unitball[c_, x_] := EuclideanDistance[c, x] <= 1;
regs = Show[
RegionPlot3D[
unitball[#, {x, y, z}], {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
Mesh -> False, Boxed -> False, Axes -> False] & /@ centers]
Export["test.obj",regs]


Or use Ball[] and RegionMember

centers = RandomReal[{-2, 2}, {10, 3}];
Table[RegionPlot3D[
RegionMember[Ball[center], {x, y, z}], {x, -1, 1}, {y, -1,
1}, {z, -1, 1}, Mesh -> False, Boxed -> False, Axes -> False], {center, centers}] // Show;
Export["test.obj", %]


Another way maybe work.

centers = RandomReal[{-2, 2}, {4, 3}];
cuboid = Cuboid[{-1, -1, -1}, {1, 1, 1}];
balls = DiscretizeRegion /@ Ball /@ centers;
newballs = RegionIntersection[#, cuboid] & /@ balls // Quiet;
regs = Show[DeleteCases[newballs, _EmptyRegion]]


• BoundaryStyle -> None Dec 16, 2020 at 23:55
• Thanks a lot for your help! Dec 18, 2020 at 19:35
centers = RandomReal[{-2, 2}, {4, 3}];