Main Page   Namespace List   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-2011 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.29 $       $Date: 2011/10/05 21:12:43 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * Base class for storing volumetric data and associated gradient data
00020  *
00021  ***************************************************************************/
00022 
00023 #ifndef VOLUMETRICDATA_H
00024 #define VOLUMETRICDATA_H
00025 
00027 class VolumetricData {
00028 public:
00029   char *name;              
00030   double origin[3];        
00031   double xaxis[3];         
00032   double yaxis[3];         
00033   double zaxis[3];         
00034   int xsize, ysize, zsize; 
00035   float *data;             
00036   float *gradient;         
00037   float datamin, datamax;  
00038 
00040   VolumetricData(const char *name, const float *origin, 
00041                  const float *xaxis, const float *yaxis, const float *zaxis,
00042                  int xs, int ys, int zs, float *dataptr);
00043 
00045   ~VolumetricData();
00046 
00048   int gridsize() const { return xsize*ysize*zsize; }
00049 
00051   void set_name(const char* name);
00052 
00054   void cell_lengths(float *xl, float *yl, float *zl) const;
00055 
00057   void cell_axes(float *xax, float *yax, float *zax) const;
00058 
00060   void cell_dirs(float *xax, float *yax, float *zax) const;
00061 
00063   void voxel_coord_from_cartesian_coord(const float *carcoord, float *voxcoord, int shiftflag) const;
00064 
00066   int voxel_index_from_coord(float xpos, float ypos, float zpos) const;
00067 
00069   inline float voxel_value(int x, int y, int z) const {
00070     return data[z*xsize*ysize + y*xsize + x];
00071   }
00072 
00074   float voxel_value_safe(int x, int y, int z) const;
00075 
00077   float voxel_value_interpolate(float xv, float yv, float zv) const;
00078 
00080   float voxel_value_from_coord(float xpos, float ypos, float zpos) const;
00081   float voxel_value_interpolate_from_coord(float xpos, float ypos, float zpos) const;
00082 
00083 
00085   void compute_volume_gradient(void);
00086 
00088   void voxel_gradient_fast(int x, int y, int z, float *grad) const {
00089     int index = (z*xsize*ysize + y*xsize + x) * 3;
00090     grad[0] = gradient[index    ];
00091     grad[1] = gradient[index + 1];
00092     grad[2] = gradient[index + 2];
00093   }
00094 
00096   void voxel_gradient_safe(int x, int y, int z, float *grad) const;
00097 
00099   void voxel_gradient_interpolate(const float *voxcoord, float *gradient) const;
00100 
00102   void voxel_gradient_from_coord(const float *coord, float *gradient) const;
00103   void voxel_gradient_interpolate_from_coord(const float *coord, float *gradient) const;
00104 
00105 };
00106 
00107 
00108 //
00109 // Fast and loose accessor macros, don't use unless you have to
00110 // 
00111 
00113 #define VOXEL_GRADIENT_FAST_IDX(v, index, grad) \
00114   { (grad)[0] = v->gradient[index    ]; \
00115     (grad)[1] = v->gradient[index + 1]; \
00116     (grad)[2] = v->gradient[index + 2]; \
00117   }
00118 
00120 #define VOXEL_GRADIENT_FAST(v, x, y, z, grad) \
00121   { int index = ((z)*v->xsize*v->ysize + (y)*v->xsize + (x)) * 3; \
00122     (grad)[0] = v->gradient[index    ]; \
00123     (grad)[1] = v->gradient[index + 1]; \
00124     (grad)[2] = v->gradient[index + 2]; \
00125   }
00126 
00127 #endif // VOLUMETRICDATA_H

Generated on Sat May 26 01:48:39 2012 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002