Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

VolumetricData.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2008 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: VolumetricData.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.22 $       $Date: 2008/04/30 00:04:15 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * Base class for storing volumetric data and associated gradient data
00020  *
00021  ***************************************************************************/
00022 
00024 class VolumetricData {
00025 public:
00026   char *name;              
00027   double origin[3];        
00028   double xaxis[3];         
00029   double yaxis[3];         
00030   double zaxis[3];         
00031   int xsize, ysize, zsize; 
00032   float *data;             
00033   float *gradient;         
00034   float datamin, datamax;  
00035 
00037   VolumetricData(const char *name, const float *origin, 
00038                  const float *xaxis, const float *yaxis, const float *zaxis,
00039                  int xs, int ys, int zs, float *dataptr);
00040 
00042   ~VolumetricData();
00043 
00045   void cell_lengths(float *xl, float *yl, float *zl) const;
00046 
00048   void cell_axes(float *xax, float *yax, float *zax) const;
00049 
00051   void cell_dirs(float *xax, float *yax, float *zax) const;
00052 
00054   void voxel_coord_from_cartesian_coord(const float *carcoord, float *voxcoord, int shiftflag) const;
00055 
00057   int voxel_index_from_coord(float xpos, float ypos, float zpos) const;
00058 
00060   inline float voxel_value(int x, int y, int z) const {
00061     return data[z*xsize*ysize + y*xsize + x];
00062   }
00063 
00065   float voxel_value_safe(int x, int y, int z) const;
00066 
00068   float voxel_value_interpolate(float xv, float yv, float zv) const;
00069 
00071   float voxel_value_from_coord(float xpos, float ypos, float zpos) const;
00072   float voxel_value_interpolate_from_coord(float xpos, float ypos, float zpos) const;
00073 
00074 
00076   void compute_volume_gradient(void);
00077 
00079   void voxel_gradient_fast(int x, int y, int z, float *grad) const {
00080     int index = (z*xsize*ysize + y*xsize + x) * 3;
00081     grad[0] = gradient[index    ];
00082     grad[1] = gradient[index + 1];
00083     grad[2] = gradient[index + 2];
00084   }
00085 
00087   void voxel_gradient_safe(int x, int y, int z, float *grad) const;
00088 
00090   void voxel_gradient_interpolate(const float *voxcoord, float *gradient) const;
00091 
00093   void voxel_gradient_from_coord(const float *coord, float *gradient) const;
00094   void voxel_gradient_interpolate_from_coord(const float *coord, float *gradient) const;
00095 
00096 };
00097 
00098 
00099 //
00100 // Fast and loose accessor macros, don't use unless you have to
00101 // 
00102 
00104 #define VOXEL_GRADIENT_FAST(v, x, y, z, grad) \
00105   { int index = ((z)*v->xsize*v->ysize + (y)*v->xsize + (x)) * 3; \
00106     (grad)[0] = v->gradient[index    ]; \
00107     (grad)[1] = v->gradient[index + 1]; \
00108     (grad)[2] = v->gradient[index + 2]; \
00109   }
00110 
00111 

Generated on Fri Sep 5 01:25:22 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002