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

Voltool.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2019 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: Voltool.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.12 $      $Date: 2020/10/15 07:27:09 $
00015  *
00016  ***************************************************************************/
00027 #ifndef VOLTOOL_H
00028 #define VOLTOOL_H
00029 
00030 #include <stdio.h>
00031 #include "VolumetricData.h"
00032 #include "VMDApp.h"
00033 #include <stdint.h>
00034 #define MIN(X,Y) (((X)<(Y))? (X) : (Y))
00035 #define MAX(X,Y) (((X)>(Y))? (X) : (Y))
00036 
00037 static inline int myisnan(float f) {
00038   union { float f; uint32_t x; } u = { f };
00039   return (u.x << 1) > 0xff000000u;
00040 }
00041 
00043 inline float cubic_interp(float y0, float y1, float y2, float y3, float mu) {
00044   float mu2 = mu*mu;
00045   float a0 = y3 - y2 - y0 + y1;
00046   float a1 = y0 - y1 - a0;
00047   float a2 = y2 - y0;
00048   float a3 = y1;
00049 
00050   return (a0*mu*mu2+a1*mu2+a2*mu+a3);
00051 }
00052 
00053 
00055 inline void voxel_coord(int x, int y, int z, 
00056                         float &gx, float &gy, float &gz, 
00057                         VolumetricData *vol) {
00058   float xdelta[3], ydelta[3], zdelta[3];
00059   vol->cell_axes(xdelta, ydelta, zdelta);
00060   
00061   gx = float(vol->origin[0] + (x * xdelta[0]) + (y * ydelta[0]) + (z * zdelta[0]));
00062   gy = float(vol->origin[1] + (x * xdelta[1]) + (y * ydelta[1]) + (z * zdelta[1]));
00063   gz = float(vol->origin[2] + (x * xdelta[2]) + (y * ydelta[2]) + (z * zdelta[2]));
00064 }
00065 
00066 
00068 inline void voxel_coord(int i, float &x, float &y, float &z, 
00069                         VolumetricData *vol) {
00070   float xdelta[3], ydelta[3], zdelta[3];
00071   vol->cell_axes(xdelta, ydelta, zdelta);
00072   int xsize = vol->xsize;
00073   int ysize = vol->ysize;
00074   
00075   int gz = i / (ysize*xsize);
00076   int gy = (i / xsize) % ysize;
00077   int gx = i % xsize;
00078 
00079   x = float(vol->origin[0] + (gx * xdelta[0]) + (gy * ydelta[0]) + (gz * zdelta[0]));
00080   y = float(vol->origin[1] + (gx * xdelta[1]) + (gy * ydelta[1]) + (gz * zdelta[1]));
00081   z = float(vol->origin[2] + (gx * xdelta[2]) + (gy * ydelta[2]) + (gz * zdelta[2]));
00082 }
00083 
00084 //
00085 //--binary ops--
00086 //
00087 
00089 void add(VolumetricData *mapA, VolumetricData *mapB, VolumetricData *newvol, bool interp, bool USE_UNION);
00090 
00092 void subtract(VolumetricData *mapA, VolumetricData *mapB, VolumetricData *newvol, bool interp, bool USE_UNION);
00093 
00095 void multiply(VolumetricData *mapA, VolumetricData *mapB, VolumetricData *newvol, bool interp, bool USE_UNION);
00096 
00099 void average(VolumetricData *mapA, VolumetricData  *mapB, VolumetricData *newvol, bool interp, bool USE_UNION);
00100 
00101 //
00102 //--volumetric data utilities--
00103 // 
00104 
00106 void vol_com(VolumetricData *vol, float *com);
00107 
00110 void vol_moveto(VolumetricData *vol, float *com, float *pos);
00111 
00113 void vol_move(VolumetricData *vol,  float *mat);
00114 
00116 void init_from_union(VolumetricData *mapA, const VolumetricData *mapB, VolumetricData *newvol);
00117 
00119 void init_from_intersection(VolumetricData *mapA, const VolumetricData *mapB, VolumetricData *newvol);
00120 
00122 VolumetricData * init_new_volume();
00123 
00125 int init_new_volume_molecule(VMDApp *app, VolumetricData *newvol, const char *name);
00126   
00130 void histogram( VolumetricData *vol, int nbins, long *bins, float *midpts);
00131 
00133 int write_file(VMDApp *app, Molecule *volmol, int volid, const char* filename);
00134 
00135 #endif
00136 

Generated on Tue Apr 16 02:46:30 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002