~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to bindings/f95/sc3d.c

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: sc3d.c,v 1.3 2006/05/13 07:09:48 airwin Exp $
 
2
 
 
3
        Stub routines for 3d plots.
 
4
 
 
5
   Copyright (C) 2004  Alan W. Irwin
 
6
 
 
7
   This file is part of PLplot.
 
8
 
 
9
   PLplot is free software; you can redistribute it and/or modify
 
10
   it under the terms of the GNU General Library Public License as published
 
11
   by the Free Software Foundation; either version 2 of the License, or
 
12
   (at your option) any later version.
 
13
 
 
14
   PLplot is distributed in the hope that it will be useful,
 
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
   GNU Library General Public License for more details.
 
18
 
 
19
   You should have received a copy of the GNU Library General Public License
 
20
   along with PLplot; if not, write to the Free Software
 
21
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
22
 
 
23
*/
 
24
 
 
25
#include "plstubs.h"
 
26
 
 
27
void
 
28
PLOT3DC(PLFLT *x, PLFLT *y, PLFLT *z,
 
29
        PLINT *nx, PLINT *ny, PLINT *opt,
 
30
        PLFLT *clevel, PLINT *nlevel, PLINT *lx)
 
31
{
 
32
   PLFLT ** a;
 
33
   int i,j;
 
34
 
 
35
/* Create a vectored a array from transpose of the fortran z array. */
 
36
   plAlloc2dGrid(&a, *nx, *ny);
 
37
   for (i = 0; i < *nx; i++) {
 
38
      for (j = 0; j < *ny; j++) {
 
39
         a[i][j] = z[i +j * *lx];
 
40
      }
 
41
   }
 
42
 
 
43
   c_plot3dc(x, y, a, *nx, *ny, *opt, clevel, *nlevel);
 
44
 
 
45
/* Clean up memory allocated for a */
 
46
   plFree2dGrid(a, *nx, *ny);
 
47
 
 
48
}
 
49
 
 
50
void
 
51
PLSURF3D(PLFLT *x, PLFLT *y, PLFLT *z,
 
52
       PLINT *nx, PLINT *ny, PLINT *opt,
 
53
       PLFLT *clevel, PLINT *nlevel, PLINT *lx)
 
54
{
 
55
    int i, j;
 
56
    PLFLT **temp;
 
57
 
 
58
    /* Create the vectored C matrix from the Fortran matrix */
 
59
    /* To make things easy we save a temporary copy of the transpose of the
 
60
       Fortran matrix, so that the first dimension of z corresponds to the x
 
61
       direction. */
 
62
 
 
63
    if ( ! (temp = (PLFLT **) malloc((size_t) * nx * sizeof(PLFLT *)))) {
 
64
        plabort("PLSURF3D: Out of memory");
 
65
        return;
 
66
    }
 
67
 
 
68
    for (i = 0; i < *nx; i++) {
 
69
        if ( ! (temp[i] = (PLFLT *) malloc((size_t) * ny * sizeof(PLFLT)))) {
 
70
            int ii;
 
71
 
 
72
            for (ii = 0; ii < i-1; ii++)
 
73
                free((void *) temp[i]);
 
74
            free((void *) temp);
 
75
            plabort("PLSURF3D: Out of memory");
 
76
            return;
 
77
        }
 
78
    }
 
79
 
 
80
    for (i = 0; i < *nx; i++)
 
81
        for (j = 0; j < *ny; j++)
 
82
            temp[i][j] = *(z + j * *lx + i);
 
83
 
 
84
    c_plsurf3d(x, y, temp, *nx, *ny, *opt, clevel, *nlevel);
 
85
 
 
86
    for (i = 0; i < *nx; i++)
 
87
        free((void *) temp[i]);
 
88
 
 
89
    free((void *) temp);
 
90
}
 
91
 
 
92
void
 
93
PLMESH(PLFLT *x, PLFLT *y, PLFLT *z,
 
94
       PLINT *nx, PLINT *ny, PLINT *opt, PLINT *lx)
 
95
{
 
96
   PLINT optlocal, nlevel = 0;
 
97
   PLFLT clevel = 0.;
 
98
 
 
99
   optlocal = *opt | MESH;
 
100
   PLOT3DC(x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx);
 
101
}
 
102
 
 
103
void
 
104
PLMESHC(PLFLT *x, PLFLT *y, PLFLT *z,
 
105
       PLINT *nx, PLINT *ny, PLINT *opt,
 
106
       PLFLT *clevel, PLINT *nlevel, PLINT *lx)
 
107
{
 
108
   PLINT optlocal;
 
109
   optlocal = *opt | MESH;
 
110
   PLOT3DC(x, y, z, nx, ny, &optlocal, clevel, nlevel, lx);
 
111
}
 
112
 
 
113
 
 
114
void
 
115
PLOT3D(PLFLT *x, PLFLT *y, PLFLT *z,
 
116
       PLINT *nx, PLINT *ny, PLINT *opt, PLBOOL *side, PLINT *lx)
 
117
{
 
118
   PLINT optlocal, nlevel = 0;
 
119
   PLFLT clevel = 0.;
 
120
 
 
121
   optlocal = *opt | (*side != 0 ? DRAW_SIDES : 0);
 
122
   PLOT3DC(x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx);
 
123
}
 
124