I understand a method of using the stencil buffer to cap a clipped convex shell. The process is to create a stencil by drawing the back facing polygons and then removing the forward facing polygons. Then use the stencil to draw a polygon over the hole left by the clipping plane.

This does not seem to work for more complex objects because forward facing polygons are removed even if they are behind rearward facing polygons.

Is there a way to extend this technique so that it works on concave geometries, or perhaps another way to cap a complex shape?