]> Creatis software - CreaPhase.git/blob - octave_packages/fpl-1.2.0/FPL2ptcshowmesh.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / fpl-1.2.0 / FPL2ptcshowmesh.m
1 ## Copyright (C) 2004-2008  Carlo de Falco, Massimiliano Culpo
2 ##
3 ##  This file is part of 
4 ##
5 ##                   FPL - Fem PLotting package for octave
6 ## 
7 ##  FPL is free software; you can redistribute it and/or modify
8 ##  it under the terms of the GNU General Public License as published by
9 ##  the Free Software Foundation; either version 2 of the License, or
10 ##  (at your option) any later version.
11 ## 
12 ##  FPL is distributed in the hope that it will be useful,
13 ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ##  GNU General Public License for more details.
16 ## 
17 ##  You should have received a copy of the GNU General Public License
18 ##  along with FPL; If not, see <http://www.gnu.org/licenses/>.
19 ##
20 ##
21 ##  AUTHORS:
22 ##  Carlo de Falco <cdf _AT_ users.sourceforge.net>
23 ##
24 ##  Culpo Massimiliano
25 ##  Bergische Universitaet Wuppertal
26 ##  Fachbereich C - Mathematik und Naturwissenschaften
27 ##  Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal  Gaussstr. 20 
28 ##  D-42119 Wuppertal, Germany
29
30 ## -*- texinfo -*-
31 ## @deftypefn {Function File} {} FPL2ptcshowmesh (@var{mesh1}, @
32 ## @var{color1}, @ [@var{mesh2}, @var{color2}, ...])
33 ## 
34 ## Displays two or more 2-D triangulations using opendx
35 ##
36 ## @seealso{FPL2pdeshowmesh}
37 ## @end deftypefn
38
39 function FPL2ptcshowmesh (varargin)
40
41   datalist = "";
42   colorlist= "";
43
44   for ii=1:2:nargin
45     dataname{ii} = mktemp("/tmp",".dx");
46     FPL2dxoutputdata(dataname{ii},varargin{ii}.p,varargin{ii}.t,...
47                      varargin{ii}.p(1,:)','x',0,1,1);
48     datalist = strcat (datalist, """", dataname{ii} ,"""");
49     colorlist= strcat (colorlist, """", varargin{ii+1} ,"""");
50   endfor
51   
52   scriptname = mktemp("/tmp",".net");
53   
54   showmesh = file_in_path(path,"FPL2ptcshowmesh.net");
55   
56   system (["cp " showmesh " " scriptname]);
57   system (["sed -i \'s|""FILELIST""|" datalist "|g\' " scriptname]);
58   system (["sed -i \'s|""COLORLIST""|" colorlist "|g\' " scriptname]);
59
60   command = ["dx  -noConfirmedQuit -program " scriptname " -execute -image  >& /dev/null & "];  
61   system(command);
62   
63 endfunction
64
65 function filename = mktemp (direct,ext);
66   
67   if (~exist(direct,"dir"))
68     error("trying to save temporary file to non existing directory")
69   endif
70
71   done=false;
72   
73   while ~done
74     filename = [direct,"/FPL.",num2str(floor(rand*1e7)),ext];
75     if ~exist(filename,"file")
76       done =true;
77     endif
78   endwhile
79
80 endfunction