-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathplot_surface_mesh.m
116 lines (91 loc) · 3.59 KB
/
plot_surface_mesh.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
%% Plot the cortical surface emphasising mesh.
%
% ARGUMENTS:
% Surface -- triangulation object of cortical surface.
%
% OUTPUT:
% ThisFigure -- Handle to overall figure object.
% SurfaceHandle -- Handle to patch object, cortical surface.
%
% REQUIRES:
% triangulation -- A Matlab object, not yet available in Octave.
%
% USAGE:
%{
ThisSurface = '213';
load(['Cortex_' ThisSurface '.mat'], 'Vertices', 'Triangles', 'VertexNormals');
tr = triangulation(Triangles, Vertices);
SurfaceCurvature = GetSurfaceCurvature(tr, VertexNormals);
SurfaceMesh(tr, SurfaceCurvature)
%}
%
% MODIFICATION HISTORY:
% SAK(13-01-2011) -- Original.
% SAK(Nov 2013) -- Move to git, future modification history is
% there...
% PSL(Jul 2015) -- TAG: MatlabR2015a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [figure_handle, surf_handle] = plot_surface_mesh(surfobj, surf_shading, fig_title)
if nargin < 4
fig_title = 'plot_surface_mesh';
end
if isstruct(surfobj)
surfobj = triangulation(surfobj.faces, surfobj.vertices);
end
% Display info
ThisScreenSize = get(0,'ScreenSize');
FigureWindowSize = ThisScreenSize + [ThisScreenSize(3)./4 ,ThisScreenSize(4)./16, -ThisScreenSize(3)./2 , -ThisScreenSize(4)./8];
% Initialise figure
figure_handle = figure('Name', fig_title);
set(figure_handle,'Position',FigureWindowSize);
% Colours
EdgeColour = [0.5, 0.5, 0.5];
cmap = parula(256);
MAP = colormap(cmap);
% ColourSteps = size(MAP,1);
% SurfaceShading = max(fix(((SurfaceShading-MinData) ./ (MaxData-MinData)) .* ColourSteps), 1);
%% Colour Surface by Region
if nargin<2
SurfaceHandle = patch('Faces', surfobj.ConnectivityList(1:1:end,:) , 'Vertices', surfobj.Points, ...
'Edgecolor', EdgeColour, 'FaceColor', [0.8 0.8 0.8]);
else
switch length(unique(surf_shading)),
case size(surfobj.Points,1)
SurfaceHandle = patch('Faces', surfobj.ConnectivityList(1:1:end,:) , 'Vertices', surfobj.Points, ...
'Edgecolor', EdgeColour, 'FaceColor', 'flat', 'FaceVertexCData', surf_shading.'); %
case size(surfobj.ConnectivityList,1)
SurfaceHandle = patch('Faces', surfobj.ConnectivityList(1:1:end,:) , 'Vertices', surfobj.Points, ...
'Edgecolor', EdgeColour, 'FaceColor', 'flat', 'FaceVertexCData', surf_shading.'); %
otherwise
SurfaceHandle = patch('Faces', surfobj.ConnectivityList(1:1:end,:) , 'Vertices', surfobj.Points, ...
'Edgecolor', EdgeColour, 'FaceColor', 'flat', 'FaceVertexCData', surf_shading.');
end
%title(['T:' num2str(Title) ' ms'], 'interpreter', 'none');
end
% Axes and Mesh plotting properties
material shiny
set(SurfaceHandle,'FaceLighting','gouraud','AmbientStrength',0.3, 'SpecularStrength', 0.2)
%lightangle(-90, 20)
view([-90, 0])
daspect([1 1 1])
%ColorBarHandle = colorbar;
%set(ColorBarHandle, 'location', 'southoutside')
%set(ColorBarHandle,'ytick',linspace(1,ColourSteps,2))
%set(ColorBarHandle, 'yticklabel', linspace(MinData, MaxData,2))
%colormap(brewermap([256], 'Reds'))
%caxis(ThisFigure, 'manual');
%caxis([1 ColourSteps]);
xlabel('X (mm)');
ylabel('Y (mm)');
zlabel('Z (mm)');
% set(gca, 'CameraViewAngle', 7);
% %set(gca, 'CameraUpVector', [-0.25 0.44 0.86]);
% %set(gca, 'CameraPosition', [664 -1238 768]);
% view(3)
% grid on;
% light;
% lighting phong;
% camlight('left');
% daspect([1 1 1])
%keyboard
end %function SurfaceMesh()