0001 function demo_surface(arg)
0002
0003
0004
0005
0006
0007
0008
0009
0010 if nargin>0
0011 feval(arg);
0012 return;
0013 end
0014
0015 fig = figure;
0016 surf(peaks); drawnow;
0017 zoom(4);
0018 axis manual;
0019
0020 set(gca,'projection','o');
0021
0022
0023 selection_marker = line('marker','o','markerfacecolor','k','erasemode','xor','visible','off');
0024 selection_vertex = line('marker','o','markerfacecolor','k','erasemode','xor','visible','off');
0025 selection_face = line('marker','o','markerfacecolor','k','erasemode','xor','visible','off');
0026
0027 setappdata(0,'selection_marker',selection_marker);
0028 setappdata(0,'selection_vertex',selection_vertex);
0029 setappdata(0,'selection_face',selection_face);
0030
0031 set(fig,'windowbuttondownfcn','demo_surface(''update'')');
0032
0033
0034 function update
0035
0036 [p v vi face facei] = select3d(gco);
0037
0038 if isempty(p)
0039 return
0040 end
0041
0042 selection_marker = getappdata(0,'selection_marker');
0043 selection_vertex = getappdata(0,'selection_vertex');
0044 selection_face = getappdata(0,'selection_face');
0045
0046 set(selection_marker,'visible','on','xdata',p(1),'ydata',p(2),'zdata',p(3));
0047
0048 set(selection_vertex,'visible','on','xdata',v(1),'ydata',v(2),'zdata',v(3));
0049 disp(sprintf('\nX: %.2f\nY: %.2f\nZ: %.2f',p(1),p(2),p(3)'))