File: __pl_mesh.m

package info (click to toggle)
plplot 5.10.0%2Bdfsg2-0.4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 25,792 kB
  • ctags: 13,517
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,208; makefile: 210; lisp: 75; sed: 25; fortran: 7
file content (106 lines) | stat: -rw-r--r-- 3,019 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
## Copyright (C) 1998-2003 Joao Cardoso.
## 
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2 of the License, or (at your
## option) any later version.
## 
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## This file is part of plplot_octave.

function __pl_mesh(caller, varargin)

  global __pl
  global DRAW_LINEXY MAG_COLOR BASE_CONT
  global TOP_CONT SURF_CONT DRAW_SIDES FACETED MESH

  strm = __pl_init;
  
  switch (caller)
    case ("mesh")
      __pl.type(strm) = 100;
    case ("meshc")
      __pl.type(strm) = 101;
    case ("meshz")
      __pl.type(strm) = 102;
    case ("surf")
      __pl.type(strm) = 103;
    case ("surfc")
      __pl.type(strm) = 104;
    case ("surfl")
      __pl.type(strm) = 105;     
    otherwise
      error("__pl_mesh: FIXME")
  endswitch

  if (nargin == 2)
    z = varargin{1};
    if (ismatrix (z))
      [rz, cz] = size(z);
      x = (1:cz)'; 
      y = (1:rz)'; 
    else
      error ("mesh: argument must be a matrix.\n");
    endif
  elseif (nargin == 4 )
    x = varargin{1};
    y = varargin{2};
    z = varargin{3};
    if (isvector (x) && isvector (y) && ismatrix (z))
      xlen = length (x);
      ylen = length (y);
      if (xlen == columns (z) && ylen == rows (z))
        if (rows (y) == 1)
          y = y';
        endif
        if (rows (x) == 1)
          x = x';
        endif
      else
        msg = "mesh: rows (z) must be the same as length (x) and";
        msg = sprintf ("%s\ncolumns (z) must be the same as length (y).\n", msg);
        error (msg);
      endif
    elseif (ismatrix (x) && ismatrix (y) && ismatrix (z))			
      error("x,y and z all matrices not yet implemented.\n")
    else
      error ("mesh: x and y must be vectors and z must be a matrix.\n");
    endif
  else
    help (caller);
    return
  endif

  if (!ishold)
    __pl.items(strm) = 1;
    __pl.lxm(strm) = __pl.lym(strm) = __pl.lzm(strm) = realmax;
    __pl.lxM(strm) = __pl.lyM(strm) = __pl.lzM(strm) = -realmax;
  endif

  items = __pl.items(strm);

  ## find the max/min x/y values. Currently reset at ??
  __pl.lxm(strm) = min([__pl.lxm(strm), min(min(x))]);
  __pl.lxM(strm) = max([__pl.lxM(strm), max(max(x))]);

  __pl.lym(strm) = min([__pl.lym(strm), min(min(y))]);
  __pl.lyM(strm) = max([__pl.lyM(strm), max(max(y))]);

  __pl.lzm(strm) = min([__pl.lzm(strm), min(min(z))]);
  __pl.lzM(strm) = max([__pl.lzM(strm), max(max(z))]);

  ## kludge, use "fmt" as plot type. But __pl_plotit still uses __pl.type
    __pl.x{items, strm} = x;
    __pl.y{items, strm} = y;
    __pl.z{items, strm} = z;
    __pl.fmt{items, strm} = __pl.type(strm);

  __pl.items(strm) = __pl.items(strm) + 1;

  __pl_meshplotit;

endfunction