File: sc3d.c

package info (click to toggle)
plplot 5.9.9-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 84,772 kB
  • sloc: ansic: 86,290; xml: 26,754; ada: 17,685; cpp: 15,530; php: 11,938; tcl: 11,125; ml: 6,825; perl: 6,736; f90: 6,709; python: 6,237; java: 6,215; sh: 2,042; makefile: 192; lisp: 75; fortran: 64; sed: 52
file content (136 lines) | stat: -rw-r--r-- 3,711 bytes parent folder | download
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// $Id: sc3d.c 11680 2011-03-27 17:57:51Z airwin $
//
//      Stub routines for 3d plots.
//
// Copyright (C) 2004  Alan W. Irwin
//
// This file is part of PLplot.
//
// PLplot is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as published
// by the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// PLplot 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 Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with PLplot; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
//

#include "plstubs.h"

void
PLOT3DC__( PLFLT *x, PLFLT *y, PLFLT *z,
           PLINT *nx, PLINT *ny, PLINT *opt,
           PLFLT *clevel, PLINT *nlevel, PLINT *lx )
{
    PLFLT ** a;
    int   i, j;

// Create a vectored a array from transpose of the fortran z array.
    plAlloc2dGrid( &a, *nx, *ny );
    for ( i = 0; i < *nx; i++ )
    {
        for ( j = 0; j < *ny; j++ )
        {
            a[i][j] = z[i + j * *lx];
        }
    }

    c_plot3dc( x, y, (const PLFLT **) a, *nx, *ny, *opt, clevel, *nlevel );

// Clean up memory allocated for a
    plFree2dGrid( a, *nx, *ny );
}

void
PLOT3DC( PLFLT *x, PLFLT *y, PLFLT *z,
         PLINT *nx, PLINT *ny, PLINT *opt,
         PLFLT *clevel, PLINT *nlevel, PLINT *lx )
{
    PLOT3DC__( x, y, z, nx, ny, opt, clevel, nlevel, lx );
}

void
PLSURF3D( PLFLT *x, PLFLT *y, PLFLT *z,
          PLINT *nx, PLINT *ny, PLINT *opt,
          PLFLT *clevel, PLINT *nlevel, PLINT *lx )
{
    int   i, j;
    PLFLT **temp;

    // Create the vectored C matrix from the Fortran matrix
    // To make things easy we save a temporary copy of the transpose of the
    // Fortran matrix, so that the first dimension of z corresponds to the x
    // direction.

    if ( !( temp = (PLFLT **) malloc( (size_t) *nx * sizeof ( PLFLT * ) ) ) )
    {
        plabort( "PLSURF3D: Out of memory" );
        return;
    }

    for ( i = 0; i < *nx; i++ )
    {
        if ( !( temp[i] = (PLFLT *) malloc( (size_t) *ny * sizeof ( PLFLT ) ) ) )
        {
            int ii;

            for ( ii = 0; ii < i - 1; ii++ )
                free( (void *) temp[i] );
            free( (void *) temp );
            plabort( "PLSURF3D: Out of memory" );
            return;
        }
    }

    for ( i = 0; i < *nx; i++ )
        for ( j = 0; j < *ny; j++ )
            temp[i][j] = *( z + j * *lx + i );

    c_plsurf3d( x, y, (const PLFLT **) temp, *nx, *ny, *opt, clevel, *nlevel );

    for ( i = 0; i < *nx; i++ )
        free( (void *) temp[i] );

    free( (void *) temp );
}

void
PLMESH( PLFLT *x, PLFLT *y, PLFLT *z,
        PLINT *nx, PLINT *ny, PLINT *opt, PLINT *lx )
{
    PLINT optlocal, nlevel = 0;
    PLFLT clevel = 0.;

    optlocal = *opt | MESH;
    PLOT3DC__( x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx );
}

void
PLMESHC( PLFLT *x, PLFLT *y, PLFLT *z,
         PLINT *nx, PLINT *ny, PLINT *opt,
         PLFLT *clevel, PLINT *nlevel, PLINT *lx )
{
    PLINT optlocal;
    optlocal = *opt | MESH;
    PLOT3DC__( x, y, z, nx, ny, &optlocal, clevel, nlevel, lx );
}


void
PLOT3D( PLFLT *x, PLFLT *y, PLFLT *z,
        PLINT *nx, PLINT *ny, PLINT *opt, PLBOOL *side, PLINT *lx )
{
    PLINT optlocal, nlevel = 0;
    PLFLT clevel = 0.;

    optlocal = *opt | ( *side != 0 ? DRAW_SIDES : 0 );
    PLOT3DC__( x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx );
}