• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

sc3d.c

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

Generated on Wed Oct 12 2011 20:42:23 for PLplot by  doxygen 1.7.1