PLplot: sc3d.c Source File

PLplot 5.10.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
sc3d.c
Go to the documentation of this file.
1 // $Id: sc3d.c 12095 2011-12-03 08:56:15Z andrewross $
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 Library General 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 // Function prototypes
28 void PLOT3DC__( PLFLT *x, PLFLT *y, PLFLT *z,
29 PLINT *nx, PLINT *ny, PLINT *opt,
30 PLFLT *clevel, PLINT *nlevel, PLINT *lx );
31 void PLOT3DC( PLFLT *x, PLFLT *y, PLFLT *z,
32 PLINT *nx, PLINT *ny, PLINT *opt,
33 PLFLT *clevel, PLINT *nlevel, PLINT *lx );
34 void PLSURF3D( PLFLT *x, PLFLT *y, PLFLT *z,
35 PLINT *nx, PLINT *ny, PLINT *opt,
36 PLFLT *clevel, PLINT *nlevel, PLINT *lx );
37 void PLMESH( PLFLT *x, PLFLT *y, PLFLT *z,
38 PLINT *nx, PLINT *ny, PLINT *opt, PLINT *lx );
39 void PLMESHC( PLFLT *x, PLFLT *y, PLFLT *z,
40 PLINT *nx, PLINT *ny, PLINT *opt,
41 PLFLT *clevel, PLINT *nlevel, PLINT *lx );
42 void PLOT3D( PLFLT *x, PLFLT *y, PLFLT *z,
43 PLINT *nx, PLINT *ny, PLINT *opt, PLBOOL *side, PLINT *lx );
44
45 void
46 PLOT3DC__( PLFLT *x, PLFLT *y, PLFLT *z,
47 PLINT *nx, PLINT *ny, PLINT *opt,
48 PLFLT *clevel, PLINT *nlevel, PLINT *lx )
49 {
50 PLFLT ** a;
51 int i, j;
52
53 // Create a vectored a array from transpose of the fortran z array.
54 plAlloc2dGrid( &a, *nx, *ny );
55 for ( i = 0; i < *nx; i++ )
56 {
57 for ( j = 0; j < *ny; j++ )
58 {
59 a[i][j] = z[i + j * *lx];
60 }
61 }
62
63 c_plot3dc( x, y, (const PLFLT * const *) a, *nx, *ny, *opt, clevel, *nlevel );
64
65 // Clean up memory allocated for a
66 plFree2dGrid( a, *nx, *ny );
67 }
68
69 void
70 PLOT3DC( PLFLT *x, PLFLT *y, PLFLT *z,
71 PLINT *nx, PLINT *ny, PLINT *opt,
72 PLFLT *clevel, PLINT *nlevel, PLINT *lx )
73 {
74 PLOT3DC__( x, y, z, nx, ny, opt, clevel, nlevel, lx );
75 }
76
77 void
78 PLSURF3D( PLFLT *x, PLFLT *y, PLFLT *z,
79 PLINT *nx, PLINT *ny, PLINT *opt,
80 PLFLT *clevel, PLINT *nlevel, PLINT *lx )
81 {
82 int i, j;
83 PLFLT **temp;
84
85 // Create the vectored C matrix from the Fortran matrix
86 // To make things easy we save a temporary copy of the transpose of the
87 // Fortran matrix, so that the first dimension of z corresponds to the x
88 // direction.
89
90 if ( !( temp = (PLFLT **) malloc( (size_t) *nx * sizeof ( PLFLT * ) ) ) )
91 {
92 plabort( "PLSURF3D: Out of memory" );
93 return;
94 }
95
96 for ( i = 0; i < *nx; i++ )
97 {
98 if ( !( temp[i] = (PLFLT *) malloc( (size_t) *ny * sizeof ( PLFLT ) ) ) )
99 {
100 int ii;
101
102 for ( ii = 0; ii < i - 1; ii++ )
103 free( (void *) temp[i] );
104 free( (void *) temp );
105 plabort( "PLSURF3D: Out of memory" );
106 return;
107 }
108 }
109
110 for ( i = 0; i < *nx; i++ )
111 for ( j = 0; j < *ny; j++ )
112 temp[i][j] = *( z + j * *lx + i );
113
114 c_plsurf3d( x, y, (const PLFLT * const *) temp, *nx, *ny, *opt, clevel, *nlevel );
115
116 for ( i = 0; i < *nx; i++ )
117 free( (void *) temp[i] );
118
119 free( (void *) temp );
120 }
121
122 void
123 PLMESH( PLFLT *x, PLFLT *y, PLFLT *z,
124 PLINT *nx, PLINT *ny, PLINT *opt, PLINT *lx )
125 {
126 PLINT optlocal, nlevel = 0;
127 PLFLT clevel = 0.;
128
129 optlocal = *opt | MESH;
130 PLOT3DC__( x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx );
131 }
132
133 void
134 PLMESHC( PLFLT *x, PLFLT *y, PLFLT *z,
135 PLINT *nx, PLINT *ny, PLINT *opt,
136 PLFLT *clevel, PLINT *nlevel, PLINT *lx )
137 {
138 PLINT optlocal;
139 optlocal = *opt | MESH;
140 PLOT3DC__( x, y, z, nx, ny, &optlocal, clevel, nlevel, lx );
141 }
142
143
144 void
145 PLOT3D( PLFLT *x, PLFLT *y, PLFLT *z,
146 PLINT *nx, PLINT *ny, PLINT *opt, PLBOOL *side, PLINT *lx )
147 {
148 PLINT optlocal, nlevel = 0;
149 PLFLT clevel = 0.;
150
151 optlocal = *opt | ( *side != 0 ? DRAW_SIDES : 0 );
152 PLOT3DC__( x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx );
153 }
154