PLplot  5.10.0
sc3d.c
Go to the documentation of this file.
00001 //      Stub routines for 3d plots.
00002 //
00003 // Copyright (C) 2004-2014 Alan W. Irwin
00004 //
00005 // This file is part of PLplot.
00006 //
00007 // PLplot is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU Library General Public License as published
00009 // by the Free Software Foundation; either version 2 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // PLplot is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU Library General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU Library General Public License
00018 // along with PLplot; if not, write to the Free Software
00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020 //
00021 //
00022 
00023 #include "plstubs.h"
00024 
00025 // Function prototypes
00026 void PLOT3DC__( PLFLT *x, PLFLT *y, PLFLT *z,
00027                 PLINT *nx, PLINT *ny, PLINT *opt,
00028                 PLFLT *clevel, PLINT *nlevel, PLINT *lx );
00029 void PLOT3DC( PLFLT *x, PLFLT *y, PLFLT *z,
00030               PLINT *nx, PLINT *ny, PLINT *opt,
00031               PLFLT *clevel, PLINT *nlevel, PLINT *lx );
00032 void PLSURF3D( PLFLT *x, PLFLT *y, PLFLT *z,
00033                PLINT *nx, PLINT *ny, PLINT *opt,
00034                PLFLT *clevel, PLINT *nlevel, PLINT *lx );
00035 void PLMESH( PLFLT *x, PLFLT *y, PLFLT *z,
00036              PLINT *nx, PLINT *ny, PLINT *opt, PLINT *lx );
00037 void PLMESHC( PLFLT *x, PLFLT *y, PLFLT *z,
00038               PLINT *nx, PLINT *ny, PLINT *opt,
00039               PLFLT *clevel, PLINT *nlevel, PLINT *lx );
00040 void PLOT3D( PLFLT *x, PLFLT *y, PLFLT *z,
00041              PLINT *nx, PLINT *ny, PLINT *opt, PLBOOL *side, PLINT *lx );
00042 
00043 void
00044 PLOT3DC__( PLFLT *x, PLFLT *y, PLFLT *z,
00045            PLINT *nx, PLINT *ny, PLINT *opt,
00046            PLFLT *clevel, PLINT *nlevel, PLINT *lx )
00047 {
00048     PLFLT ** a;
00049     int   i, j;
00050 
00051 // Create a vectored a array from transpose of the fortran z array.
00052     plAlloc2dGrid( &a, *nx, *ny );
00053     for ( i = 0; i < *nx; i++ )
00054     {
00055         for ( j = 0; j < *ny; j++ )
00056         {
00057             a[i][j] = z[i + j * *lx];
00058         }
00059     }
00060 
00061     c_plot3dc( x, y, (const PLFLT * const *) a, *nx, *ny, *opt, clevel, *nlevel );
00062 
00063 // Clean up memory allocated for a
00064     plFree2dGrid( a, *nx, *ny );
00065 }
00066 
00067 void
00068 PLOT3DC( PLFLT *x, PLFLT *y, PLFLT *z,
00069          PLINT *nx, PLINT *ny, PLINT *opt,
00070          PLFLT *clevel, PLINT *nlevel, PLINT *lx )
00071 {
00072     PLOT3DC__( x, y, z, nx, ny, opt, clevel, nlevel, lx );
00073 }
00074 
00075 void
00076 PLSURF3D( PLFLT *x, PLFLT *y, PLFLT *z,
00077           PLINT *nx, PLINT *ny, PLINT *opt,
00078           PLFLT *clevel, PLINT *nlevel, PLINT *lx )
00079 {
00080     int   i, j;
00081     PLFLT **temp;
00082 
00083     // Create the vectored C matrix from the Fortran matrix
00084     // To make things easy we save a temporary copy of the transpose of the
00085     // Fortran matrix, so that the first dimension of z corresponds to the x
00086     // direction.
00087 
00088     if ( !( temp = (PLFLT **) malloc( (size_t) *nx * sizeof ( PLFLT * ) ) ) )
00089     {
00090         plabort( "PLSURF3D: Out of memory" );
00091         return;
00092     }
00093 
00094     for ( i = 0; i < *nx; i++ )
00095     {
00096         if ( !( temp[i] = (PLFLT *) malloc( (size_t) *ny * sizeof ( PLFLT ) ) ) )
00097         {
00098             int ii;
00099 
00100             for ( ii = 0; ii < i - 1; ii++ )
00101                 free( (void *) temp[i] );
00102             free( (void *) temp );
00103             plabort( "PLSURF3D: Out of memory" );
00104             return;
00105         }
00106     }
00107 
00108     for ( i = 0; i < *nx; i++ )
00109         for ( j = 0; j < *ny; j++ )
00110             temp[i][j] = *( z + j * *lx + i );
00111 
00112     c_plsurf3d( x, y, (const PLFLT * const *) temp, *nx, *ny, *opt, clevel, *nlevel );
00113 
00114     for ( i = 0; i < *nx; i++ )
00115         free( (void *) temp[i] );
00116 
00117     free( (void *) temp );
00118 }
00119 
00120 void
00121 PLMESH( PLFLT *x, PLFLT *y, PLFLT *z,
00122         PLINT *nx, PLINT *ny, PLINT *opt, PLINT *lx )
00123 {
00124     PLINT optlocal, nlevel = 0;
00125     PLFLT clevel = 0.;
00126 
00127     optlocal = *opt | MESH;
00128     PLOT3DC__( x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx );
00129 }
00130 
00131 void
00132 PLMESHC( PLFLT *x, PLFLT *y, PLFLT *z,
00133          PLINT *nx, PLINT *ny, PLINT *opt,
00134          PLFLT *clevel, PLINT *nlevel, PLINT *lx )
00135 {
00136     PLINT optlocal;
00137     optlocal = *opt | MESH;
00138     PLOT3DC__( x, y, z, nx, ny, &optlocal, clevel, nlevel, lx );
00139 }
00140 
00141 
00142 void
00143 PLOT3D( PLFLT *x, PLFLT *y, PLFLT *z,
00144         PLINT *nx, PLINT *ny, PLINT *opt, PLBOOL *side, PLINT *lx )
00145 {
00146     PLINT optlocal, nlevel = 0;
00147     PLFLT clevel = 0.;
00148 
00149     optlocal = *opt | ( *side != 0 ? DRAW_SIDES : 0 );
00150     PLOT3DC__( x, y, z, nx, ny, &optlocal, &clevel, &nlevel, lx );
00151 }
00152 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines