## Use NaNs to hide faces in matlab trisurf/patch renderings

I recently (re)discovered that if you set the ‘CData’ value of a face to nan the face will be hidden. This can sometimes be useful if you want to use the wireframe of a model to give context but focus on just a few faces. Here’s an example:

% selected faces
I = sparse(125,1,1,size(F,1),1);
while true
% Set all but selected to nan
tsurf(F,V,'CData',sparse(find(~I),1,nan,size(F,1),1));
view(-48,4); set(gca,'Visible','off');apply_ambient_occlusion();
drawnow;
if nnz(I)==size(F,1);
break;
end
I = A*I;
end


Tags: , , , , ,

### 2 Responses to “Use NaNs to hide faces in matlab trisurf/patch renderings”

1. sbobet says:

I recently (re)discovered that if you set the ‘CData’ value of a face to nan the face will be hidden.

2. sbobet says:

I recently (re)discovered that if you set the ‘CData’ value of a face to nan the face wil