# Regions in 3D acting strange with cuboids

Suppose I have two composite regions as follows:

body=RegionUnion[Cylinder[{{2.55, 0, 0}, {4.45, 0, 0}}, 0.55],
RegionDifference[Cylinder[{{2.5, 0, 0}, {4.5, 0, 0}}, 0.6],
Cylinder[{{2.4, 0, 0}, {4.6, 0, 0}}, 0.5]]];
cutouts=RegionUnion[{Cuboid[{3.4, -1, -0.25}, {3.6, 1, 0.25}],
Cuboid[{2.8, -1, -0.25}, {3.0, 1, 0.25}],
Cuboid[{4.0, -1, -0.25}, {4.2, 1, 0.25}]}];
RegionPlot3D[body,PlotPoints->50]
RegionPlot3D[cutouts,PlotPoints->50]


The first of these works fine. The second fails.

However, I can see the result using Graphics3D instead of RegionPlot3D:

The ultimate goal is to use the two regions with RegionDifference to make cutouts.

result=RegionDifference[body,cutouts]


RegionPlot3D[result]


I can make it work by sequentially using RegionDifference with the individual Cuboids, but (at least conceptually) it seems like it should work with the union of them, and doing so would simplify the code significantly. Any suggestions?

Working with mesh regions (i.e., using DiscretizeRegion) instead of region primitives (e.g., Cuboid) will produce objects that can be rendered more easily.

body = RegionUnion[
DiscretizeRegion @ Cylinder[{{2.55,0,0},{4.45,0,0}},0.55],
RegionDifference[
DiscretizeRegion @ Cylinder[{{2.5,0,0},{4.5,0,0}},0.6],
DiscretizeRegion @ Cylinder[{{2.4,0,0},{4.6,0,0}},0.5]
]
];
cutouts = RegionUnion[
DiscretizeRegion @ Cuboid[{3.4,-1,-0.25},{3.6,1,0.25}],
DiscretizeRegion @ Cuboid[{2.8,-1,-0.25},{3.0,1,0.25}],
DiscretizeRegion @ Cuboid[{4.0,-1,-0.25},{4.2,1,0.25}]
];
RegionDifference[body, cutouts]


• Hmmm. I was hoping to continue to use the primitives so that I could specify the polycount at the end rather than at earlier steps (such as during calls to DiscretizeRegion). I am playing with generating 3D regions for use in 3D printing, and debugging the forms at low polycounts, but then changing the polycount in one place at the end for production was extremely appealing. I'll see if I can make this approach work for me, though. – Kevin Ausman Nov 26 '19 at 22:50