| 1 | function 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
|
|---|
| 10 | subplot(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);
|
|---|
| 15 |
|
|---|
| 16 | %plot
|
|---|
| 17 | pos=getfieldvalue(options,'highlight',[]);
|
|---|
| 18 | if is2d
|
|---|
| 19 | %plot mesh
|
|---|
| 20 | A=elements(:,1); B=elements(:,2); C=elements(:,3);
|
|---|
| 21 | patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
|
|---|
| 22 |
|
|---|
| 23 | %Highlight
|
|---|
| 24 | pos=getfieldvalue(options,'highlight',[]);
|
|---|
| 25 | A=elements(pos,1); B=elements(pos,2); C=elements(pos,3);
|
|---|
| 26 | patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 27 | else
|
|---|
| 28 | if size(elements,2)==6, %prisms
|
|---|
| 29 | %plot mesh
|
|---|
| 30 | A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
|
|---|
| 31 | patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
|
|---|
| 32 | patch( 'Faces', [D E F], 'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
|
|---|
| 33 | patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
|
|---|
| 34 | patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
|
|---|
| 35 | patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [1 1 1],'FaceColor','none','EdgeColor','black');
|
|---|
| 36 |
|
|---|
| 37 | %Highlight
|
|---|
| 38 | A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4); E=elements(pos,5); F=elements(pos,6);
|
|---|
| 39 | patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 40 | patch( 'Faces', [D E F], 'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 41 | patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 42 | patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 43 | patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData', [0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 44 | elseif size(elements,2)==4, %tetras
|
|---|
| 45 | A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4);
|
|---|
| 46 | patch( 'Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor','black');
|
|---|
| 47 | patch( 'Faces',[A B D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor','black');
|
|---|
| 48 | patch( 'Faces',[B C D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor','black');
|
|---|
| 49 | patch( 'Faces',[C A D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor','black');
|
|---|
| 50 | %Highlight
|
|---|
| 51 | A=elements(pos,1); B=elements(pos,2); C=elements(pos,3); D=elements(pos,4);
|
|---|
| 52 | patch( 'Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 53 | patch( 'Faces',[A B D],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 54 | patch( 'Faces',[B C D],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 55 | patch( 'Faces',[C A D],'Vertices', [x y z],'FaceVertexCData',[0.9 0.5 0.5],'FaceColor','flat','EdgeColor','black');
|
|---|
| 56 | else
|
|---|
| 57 | error('Not supported');
|
|---|
| 58 | end
|
|---|
| 59 | end
|
|---|
| 60 |
|
|---|
| 61 | %apply options
|
|---|
| 62 | if ~exist(options,'highlight')
|
|---|
| 63 | disp('highlightelements warning : highlight option empty, not element highlighted');
|
|---|
| 64 | end
|
|---|
| 65 | options=addfielddefault(options,'title','Highlighted Elements');
|
|---|
| 66 | options=addfielddefault(options,'colorbar',0);
|
|---|
| 67 | applyoptions(md,[],options);
|
|---|