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

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

CHG: edge color should be an option

File size: 3.8 KB
RevLine 
[13730]1function plot_highlightelements(md,options,width,i)
[1]2%PLOT_HIGHLIGHTELEMENTS - plot selected elements
3%
4% Usage:
[2439]5% plot_highlightelements(md,options,width,i);
[1]6%
7% See also: PLOTMODEL
8
9%plot mesh boundaries
10subplot(width,width,i);
11
12%process data and model
[8472]13[x y z elements is2d isplanet]=processmesh(md,[],options);
[9725]14[elementnumbers datatype]=processdata(md,[1:md.mesh.numberofelements]',options);
[27675]15edgecolor = getfieldvalue(options,'EdgeColor','black');
[1]16
17%plot
[17474]18pos=getfieldvalue(options,'highlight',[]);
[1]19if is2d
20 %plot mesh
21 A=elements(:,1); B=elements(:,2); C=elements(:,3);
[27675]22 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor',edgecolor);
[5616]23
24 %Highlight
25 pos=getfieldvalue(options,'highlight',[]);
26 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
[27675]27 patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor',edgecolor);
[1]28else
[17474]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);
[27675]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);
[5616]37
[17474]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);
[27675]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);
[17474]45 elseif size(elements,2)==4, %tetras
46 A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4);
[27675]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);
[17474]51 %Highlight
52 A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4);
[27675]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);
[17474]57 else
58 error('Not supported');
59 end
[1]60end
61
62%apply options
[2439]63if ~exist(options,'highlight')
[1]64 disp('highlightelements warning : highlight option empty, not element highlighted');
65end
[2439]66options=addfielddefault(options,'title','Highlighted Elements');
67options=addfielddefault(options,'colorbar',0);
68applyoptions(md,[],options);
Note: See TracBrowser for help on using the repository browser.