| MESH toolbox 0.1 Matlab/Octave mesh utils

- Main Page
- Related Pages
- Modules
- Files

- File List
- File Members

All Files Functions Groups Pages
PlotBounds.m
Go to the documentation of this file.
1 function RGBcolors=PlotBounds(varargin)
2 % function RGBcolors=PlotBounds(varargin)
3 % Plot mesh boundaries
4 %
5 % parameters:
6 % Th : mesh structure
7 % RGBcolors : set boundaries colors
8 % colormap : set colormap value to \'Jet\', \'HSV\', \'Gray\', \'colorcube\',\'Cool\',\'Spring\',\'Summer\',...
9 % Legend : set legend visible at true or false
10 % FontSize : set legend font size
11 % LineWidth : set boundaries lines width
12 %
13 % Example:
14 % @verbatim
15 % PlotBounds(Th,'LineWidth',2);@endverbatim
16 % \image html images/PlotBounds.png "figure : PlotBounds(Th,\'LineWidth\',2);"
17 p = inputParser;
18 p.addRequired('Th', @isstruct);
19 %
20 p.addParamValue('colormap', 'Jet', @isstr );
21 p.addParamValue('RGBcolors', [], @isnumeric );
22 p.addParamValue('LineWidth', 2.0 , @isnumeric );
23 p.addParamValue('Legend', true , @islogical );
24 p.addParamValue('FontSize', 10 , @isnumeric );
25
26 %p.addParamValue('EdgeNumber', false , @islogical );
27 p.parse(varargin{:});
28
29 Th=p.Results.Th;
30
31 stringMat=[];
32 LB=unique(Th.bel);
33 amax=length(LB);
34 cmap=colormap(p.Results.colormap);
35 if amax ==1
36 t=0;
37 else
38 t=0:1/(amax-1):1;
39 end
40 if (isempty(p.Results.RGBcolors))
41 RGBcolors=RGB(t(randperm(amax)),cmap);
42 else
43 RGBcolors=p.Results.RGBcolors;
44 end
45 PrevHold=SetHoldOn(true);
46 if p.Results.Legend
47 cLegend='';
48 for i=1:amax
49 if i==amax
50 cLegend=sprintf('%s''\\Gamma_{%d}''',cLegend,LB(i));
51 else
52 cLegend=sprintf('%s''\\Gamma_{%d}'',',cLegend,LB(i));
53 end
54 %stringMat=[stringMat ;'\Gamma_',num2str(LB(i))];
55 I=find(Th.bel == LB(i));
56 h(i)=plot([Th.q(1,Th.be(1,I(1))) Th.q(1,Th.be(2,I(1)))], ...
57 [Th.q(2,Th.be(1,I(1))) Th.q(2,Th.be(2,I(1)))]);
58 set(h(i),'Color',RGBcolors(i,:),'LineWidth',p.Results.LineWidth);
59 end
60 eval(sprintf('H=legend(h,%s);',cLegend));
61 set(H,'FontSize',p.Results.FontSize);
62 end
63
64 % On trace enfin les bords
65 for i=1:amax
66 I=find(Th.bel == LB(i));
67 for k=I
68 h=plot([Th.q(1,Th.be(1,k)) Th.q(1,Th.be(2,k))], ...
69 [Th.q(2,Th.be(1,k)) Th.q(2,Th.be(2,k))]);
70 set(h,'Color',RGBcolors(i,:),'LineWidth',p.Results.LineWidth);
71 end
72 end
73 RestoreHold(PrevHold)
74 axis off
75 axis equal