Skip to main content
1 of 5
Simon Woods
  • 85.9k
  • 8
  • 183
  • 332

This is based on Rahul's ideas, but a different implementation:

contourRegionPlot3D[region_, {x_, x0_, x1_}, {y_, y0_, y1_}, {z_, z0_, z1_}, opts : OptionsPattern[]] := Module[{reg, preds}, reg = LogicalExpand[region && x0 <= x <= x1 && y0 <= y <= y1 && z0 <= z <= z1]; preds = Union@Cases[reg, _Greater | _GreaterEqual | _Less | _LessEqual, -1]; Show @ Table[ContourPlot3D[ Evaluate[Equal @@ p], {x, x0, x1}, {y, y0, y1}, {z, z0, z1}, RegionFunction -> Function @@ {{x, y, z}, Refine[reg, p] && ! Refine[reg, ! p]}, opts], {p, preds}]] 

Examples:

contourRegionPlot3D[ (x < 0 || y > 0) && 0.5 <= x^2 + y^2 + z^2 <= 0.99, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> None] 

enter image description here

contourRegionPlot3D[ x^2 + y^2 + z^2 <= 2 && x^2 + y^2 <= (z - 1)^2 && Abs@x >= 1/4, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> None] 

enter image description here

contourRegionPlot3D[ x^2 + y^2 + z^2 <= 0.4 || 0.01 <= x^2 + y^2 <= 0.05, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> None, PlotPoints -> 50] 

enter image description here

Simon Woods
  • 85.9k
  • 8
  • 183
  • 332