# Probable Bug in HighlightMesh with 2D Convex Hulls created via ConvexHullMesh

Bug introduced in 10.0 and fixed in 10.2

One nice way to view the new and exciting Mesh objects introduced in Version 10 is by utilizing the function HighlightMesh, so I've been using it heavily. Problem is, when trying to visualize 2D convex hull regions (3D case works fine) created using ConvexHullMesh, HighlightMesh essentially ignores the Options for styling the face of the 2D polygon region. Here is an example:

SeedRandom[0];
pts = RandomReal[4, {200, 2}];
chull = ConvexHullMesh[pts]


Now let's Style it using HighlightMesh

HighlightMesh[chull, {Style[0, Directive[PointSize[0.02], Red]],
Style[1, Thin, Green], Style[2, Directive[Yellow]]}]


Notice the Yellow Color under Style[2, ..], that's for the Polygon face. This is obviously ignored for the Default color used above. Can anyone reproduce this on Windows 8.1 and other operating systems and is there an easy workaround for this?

-
There are no 2-dimensional mesh elements in chull, only lines and points (examine chull // InputForm). I had the same problem here. I did not explain the difficulty, but I did come up with a workaround. –  Michael E2 Jul 30 '14 at 20:00
@MichaelE2 So why does MeshCells[chull, 2] give an output - a Polygon? –  RunnyKine Jul 30 '14 at 20:02
I don't know. I'm not sure at this point I'm able to give an authoritative answer to any "why" about mesh objects. It looks like an inconsistency to me. –  Michael E2 Jul 30 '14 at 20:04
@MichaelE2, I saw your answer but you didn't use HighlightMesh to Style it, which is designed specifically to do this. I think it's an omission. And I agree, the Mesh objects weren't fully fleshed out. –  RunnyKine Jul 30 '14 at 20:07
I didn't use it because it didn't work. Also MeshCell[..., 2] does not seem to work on it either. –  Michael E2 Jul 30 '14 at 20:09

An alternative workaround is to convert the BoundaryMeshRegion into a MeshRegion from the MeshCoordinates and MeshCells. This lets you use HighlightMesh as desired:

SeedRandom[0];
pts = RandomReal[4, {200, 2}];
chull = ConvexHullMesh[pts];
styles = MapThread[Style, {{0, 1, 2}, {Red, Green, Yellow}}];

fullmesh[bm_] := MeshRegion[MeshCoordinates[bm], MeshCells[bm, All]]

HighlightMesh[chull, styles]
HighlightMesh[fullmesh @ chull, styles]


Note that this won't work for higher dimensional regions:

MeshCells[ConvexHullMesh[RandomReal[1, {4, 3}]], 3]


MeshCells::cnorep: There is no simple cell representation for the specified cells of the BoundaryMeshRegion in dimension 3.

-
Nice workaround. Thanks. –  RunnyKine Jul 31 '14 at 15:12

Here is a workaround that's easy enough since it makes use of the already created Mesh region:

Graphics[GraphicsComplex[
MeshCoordinates[chull], {Green, MeshCells[chull, 1], Red,
PointSize[0.02], MeshCells[chull, 0], Opacity[0.6], Yellow,
MeshCells[chull, 2]}]]


-