source: issm/trunk-jpl/src/m/plot/plot_highlightelements.m@ 27675

Last change on this file since 27675 was 27675, checked in by Mathieu Morlighem, 2 years ago

CHG: edge color should be an option

File size: 3.8 KB
Line 
1function plot_highlightelements(md,options,width,i)
2%PLOT_HIGHLIGHTELEMENTS - plot selected elements
3%
4% Usage:
5% plot_highlightelements(md,options,width,i);
6%
7% See also: PLOTMODEL
8
9%plot mesh boundaries
10subplot(width,width,i);
11
12%process data and model
13[x y z elements is2d isplanet]=processmesh(md,[],options);
14[elementnumbers datatype]=processdata(md,[1:md.mesh.numberofelements]',options);
15edgecolor = getfieldvalue(options,'EdgeColor','black');
16
17%plot
18pos=getfieldvalue(options,'highlight',[]);
19if is2d
20 %plot mesh
21 A=elements(:,1); B=elements(:,2); C=elements(:,3);
22 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor',edgecolor);
23
24 %Highlight
25 pos=getfieldvalue(options,'highlight',[]);
26 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
27 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
28else
29 if size(elements,2)==6, %prisms
30 %plot mesh
31 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
32 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor',edgecolor);
33 patch( 'Faces', [D E F], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor',edgecolor);
34 patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor',edgecolor);
35 patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor',edgecolor);
36 patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor',edgecolor);
37
38 %Highlight
39 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
40 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
41 patch( 'Faces', [D E F], 'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
42 patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
43 patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
44 patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
45 elseif size(elements,2)==4, %tetras
46 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4);
47 patch( 'Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor);
48 patch( 'Faces',[A B D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor);
49 patch( 'Faces',[B C D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor);
50 patch( 'Faces',[C A D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor);
51 %Highlight
52 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4);
53 patch( 'Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
54 patch( 'Faces',[A B D],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
55 patch( 'Faces',[B C D],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
56 patch( 'Faces',[C A D],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
57 else
58 error('Not supported');
59 end
60end
61
62%apply options
63if ~exist(options,'highlight')
64 disp('highlightelements warning : highlight option empty, not element highlighted');
65end
66options=addfielddefault(options,'title','Highlighted Elements');
67options=addfielddefault(options,'colorbar',0);
68applyoptions(md,[],options);
Note: See TracBrowser for help on using the repository browser.