]> Creatis software - CreaPhase.git/blob - octave_packages/fpl-1.2.0/FPL2ptcquiver.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / fpl-1.2.0 / FPL2ptcquiver.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} {} FPL2ptcquiver (@var{mesh1}, @var{color1}
32 ## @var{vx1}, @var{vy1}, [ @var{mesh2}, @var{color2}, @var{vx2}, @var{vy2} ...])
33 ## 
34 ## Plots the 2D vector fields @var{vx}, @var{vy} 
35 ## defined on the triangulations @var{mesh} using opendx.
36 ##
37 ##
38 ## @seealso{FPL2pdesurf, FPL2ptcsurf, FPL2pdequiver}
39 ## @end deftypefn
40
41 function FPL2ptcquiver(varargin) 
42   
43   colorlist = "";
44   datalist  = "";
45   
46   for ii = 1:4:nargin
47     dataname{ii} = mktemp("/tmp",".dx");
48     JX = sum(varargin{ii+2},1)'/3;
49     JY = sum(varargin{ii+3},1)'/3;
50     FPL2dxoutputdata(dataname{ii},varargin{ii}.p,varargin{ii}.t,[ JX JY],'J',1,2,1);
51     datalist = strcat (datalist, """", dataname{ii} , """");
52     colorlist= strcat (colorlist, """", varargin{ii+1} , """");
53   endfor
54   
55   scriptname = mktemp("/tmp",".net");
56   
57   view       = file_in_path(path,"FPL2ptcquiver.net");
58   
59   system (["cp " view " " scriptname]);
60   system (["sed -i \'s|""FILELIST""|" datalist "|g\' " scriptname]);
61   system (["sed -i \'s|""COLORLIST""|" colorlist "|g\' " scriptname]);
62
63   command = ["dx  -noConfirmedQuit -program " scriptname " -execute -image  >& /dev/null & "];  
64   system(command);
65   
66 endfunction
67
68 function filename = mktemp (direct,ext);
69   
70   if (~exist(direct,"dir"))
71     error("trying to save temporary file to non existing directory")
72   endif
73   
74   done=false;
75   
76   while ~done
77     filename = [direct,"/FPL.",num2str(floor(rand*1e7)),ext];
78     if ~exist(filename,"file")
79       done =true;
80     endif
81   endwhile
82
83 endfunction