\section{Envelope  Class Reference}
\label{class_Envelope}\index{Envelope@{Envelope}}
{\tt \#include $<$envelope.h$>$}

Collaboration diagram for Envelope:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=109pt]{class_Envelope_coll_graph}
\end{center}
\end{figure}
\subsection*{Public Methods}
\begin{CompactItemize}
\item 
{\bf Envelope} ()
\begin{CompactList}\small\item\em constructor.\item\end{CompactList}\item 
{\bf Envelope} (const Envelope \&e)
\begin{CompactList}\small\item\em copy constructor.\item\end{CompactList}\item 
{\bf $\sim$Envelope} ()
\begin{CompactList}\small\item\em destructor.\item\end{CompactList}\item 
const double {\bf operator()} (int x, int y, int {\bf z}) const
\begin{CompactList}\small\item\em access density by cell.\item\end{CompactList}\item 
const double {\bf operator()} (const {\bf j\-Vector} \&J) const
\begin{CompactList}\small\item\em access density by position.\item\end{CompactList}\item 
const {\bf j\-Vector}\& {\bf gradient} (int x, int y, int {\bf z}) const
\begin{CompactList}\small\item\em access gradient by cell.\item\end{CompactList}\item 
const {\bf j\-Vector}\& {\bf gradient} ({\bf j\-Vector} J) const
\begin{CompactList}\small\item\em access gradient.\item\end{CompactList}\item 
int {\bf Build} (const {\bf Molecule} \&Mol, double IW\_\-in=DEFAULT\_\-CUBE\_\-WIDTH)
\begin{CompactList}\small\item\em create envelope from current molecule.\item\end{CompactList}\item 
void {\bf Get\_\-Eigenvectors} ({\bf Matrix} \&Eig\-Vec, {\bf Matrix} \&Eig\-Val) const
\begin{CompactList}\small\item\em writes Eigenvalues and Eigenvectors matricies by reference.\item\end{CompactList}\item 
int {\bf Write\-Density} (ostream \&out\-Stream, const {\bf Molecule} \&Mol) const
\begin{CompactList}\small\item\em write out a list of atoms and their density in the env.\item\end{CompactList}\item 
int {\bf Write\-Avs\-Txt} (ostream \&out\-Stream) const
\begin{CompactList}\small\item\em write AVS density format(as text).\item\end{CompactList}\item 
int {\bf Write\-VRML} (ostream \&out\-Stream) const
\begin{CompactList}\small\item\em write VRML 1.0 format.\item\end{CompactList}\item 
int {\bf Write\-VRMLgr} (ostream \&out\-Stream) const
\begin{CompactList}\small\item\em write VRML 1.0 format with gradient arrows.\item\end{CompactList}\item 
void {\bf Diff\-Report} (ostream \&out\-Stream, const Envelope \&E)
\begin{CompactList}\small\item\em Report on differences to another env.\item\end{CompactList}\item 
int {\bf Compare} (const Envelope \&ec) const
\begin{CompactList}\small\item\em default compare function.\item\end{CompactList}\item 
{\bf MAKECOMPARISONS\_\-WITH\_\-COMPARE} (Envelope)
\item 
int {\bf Read} (istream \&is)
\item 
int {\bf Read\-Binary} (istream \&is)
\item 
int {\bf Output} (ostream \&os) const
\item 
int {\bf Output\-Binary} (ostream \&os) const
\item 
void {\bf Calc\_\-Eigenvectors} ()
\begin{CompactList}\small\item\em internal call to calc and store Eigenvectors.\item\end{CompactList}\item 
void {\bf Calc\-Gradient} (int d=1)
\begin{CompactList}\small\item\em uses the current density\_\-array to calculate the gradient\_\-field.\item\end{CompactList}\item 
void {\bf Upsize} (int k)
\begin{CompactList}\small\item\em increases the box size by a factor k'.\item\end{CompactList}\item 
void {\bf Blur} (int k)
\begin{CompactList}\small\item\em performs flat kernel convolution of 3D size (2$\ast$kernel\-Size+1) per side.\item\end{CompactList}\item 
void {\bf Normalize\-Max} ()
\begin{CompactList}\small\item\em max max density = def's MAX\_\-ENV\_\-DEN' value and scale all cells accordingly.\item\end{CompactList}\item 
double {\bf Query\-Density} (const {\bf j\-Vector} \&pos) const
\begin{CompactList}\small\item\em returns density at `pos.\item\end{CompactList}\item 
{\bf j\-Vector} {\bf Query\-Gradient} (const {\bf j\-Vector} \&pos) const
\item 
double\& {\bf operator()} (int x, int y, int {\bf z})
\begin{CompactList}\small\item\em lvalue (for assigning density).\item\end{CompactList}\item 
{\bf j\-Vector}\& {\bf gradient} (int x, int y, int {\bf z})
\begin{CompactList}\small\item\em lvalue (for assigning gradient).\item\end{CompactList}\item 
int {\bf Read\-Avs\-Txt} (istream \&in)
\begin{CompactList}\small\item\em read text-converted AVS density format.\item\end{CompactList}\item 
void {\bf Env\_\-Setup1} ()
\begin{CompactList}\small\item\em allocates memory.\item\end{CompactList}\item 
void {\bf Env\_\-Setup2} ()
\begin{CompactList}\small\item\em calculates meta information about data.\item\end{CompactList}\item 
void {\bf Center} (void)
\begin{CompactList}\small\item\em adjust the max[xyz] and min[xyz] of the envelope to position the center of mass at the origin.\item\end{CompactList}\end{CompactItemize}
\subsection*{Public Attributes}
\begin{CompactItemize}
\item 
double$\ast$ {\bf density\_\-array}
\begin{CompactList}\small\item\em Array of doubles storing density.\item\end{CompactList}\item 
{\bf j\-Vector}$\ast$ {\bf gradient\_\-field}
\begin{CompactList}\small\item\em Array of j\-Vectors storing gradient.\item\end{CompactList}\item 
int {\bf num\-Points}
\begin{CompactList}\small\item\em Number of cubes in Envelope.\item\end{CompactList}\item 
int {\bf xdim}
\begin{CompactList}\small\item\em Dimensions in number of cubes.\item\end{CompactList}\item 
int {\bf ydim}
\begin{CompactList}\small\item\em Dimensions in number of cubes.\item\end{CompactList}\item 
int {\bf zdim}
\begin{CompactList}\small\item\em Dimensions in number of cubes.\item\end{CompactList}\item 
double {\bf Input\-Width}
\begin{CompactList}\small\item\em Real width of cubes (e.g. 3.7A).\item\end{CompactList}\item 
double {\bf minx}
\begin{CompactList}\small\item\em Real position of min edges of region.\item\end{CompactList}\item 
double {\bf miny}
\begin{CompactList}\small\item\em Real position of min edges of region.\item\end{CompactList}\item 
double {\bf minz}
\begin{CompactList}\small\item\em Real position of min edges of region.\item\end{CompactList}\item 
double {\bf maxx}
\begin{CompactList}\small\item\em Real position of max edges of region.\item\end{CompactList}\item 
double {\bf maxy}
\begin{CompactList}\small\item\em Real position of max edges of region.\item\end{CompactList}\item 
double {\bf maxz}
\begin{CompactList}\small\item\em Real position of max edges of region.\item\end{CompactList}\item 
double {\bf cm\_\-x}
\begin{CompactList}\small\item\em Center of mass, weighted by probabilities, (as blocks).\item\end{CompactList}\item 
double {\bf cm\_\-y}
\begin{CompactList}\small\item\em Center of mass, weighted by probabilities, (as blocks).\item\end{CompactList}\item 
double {\bf cm\_\-z}
\begin{CompactList}\small\item\em Center of mass, weighted by probabilities, (as blocks).\item\end{CompactList}\item 
double {\bf r\_\-cm\_\-x}
\begin{CompactList}\small\item\em Center of mass, weighted by probabilities, (Real postition!).\item\end{CompactList}\item 
double {\bf r\_\-cm\_\-y}
\begin{CompactList}\small\item\em Center of mass, weighted by probabilities, (Real postition!).\item\end{CompactList}\item 
double {\bf r\_\-cm\_\-z}
\begin{CompactList}\small\item\em Center of mass, weighted by probabilities, (Real postition!).\item\end{CompactList}\item 
double {\bf total\-Density}
\begin{CompactList}\small\item\em Total of all the density numbers in the cubes.\item\end{CompactList}\item 
int {\bf filled\-Points}
\begin{CompactList}\small\item\em Number of non-zero cubes in Envelope.\item\end{CompactList}\item 
{\bf Matrix} {\bf my\_\-Eig\-Val}
\begin{CompactList}\small\item\em Eigenvalues for the envelope.\item\end{CompactList}\item 
{\bf Matrix} {\bf my\_\-Eig\-Vec}
\begin{CompactList}\small\item\em Eigenvectors for the envelope.\item\end{CompactList}\item 
const {\bf j\-Vector} {\bf JVzero3}
\begin{CompactList}\small\item\em useful null vector.\item\end{CompactList}\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf Envelope\-Constraint}
\end{CompactItemize}


\subsection{Constructor \& Destructor Documentation}
\index{Envelope@{Envelope}!Envelope@{Envelope}}
\index{Envelope@{Envelope}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Envelope::Envelope ()}\label{class_Envelope_a0}


constructor.



Definition at line 3 of file envelope.C.\footnotesize\begin{verbatim}00005 {
00006   // this is an unititialized envelope.  
00007 
00008   xdim = ydim = zdim = -1;
00009   minx = miny = minz = maxx = maxy = maxz = 0;
00010 
00011   density_array = 0;
00012   gradient_field = 0;
00013   
00014   numPoints = 0;
00015   InputWidth = -1;
00016 
00017 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Envelope@{Envelope}}
\index{Envelope@{Envelope}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Envelope::Envelope (const Envelope \& {\em env\_\-in})}\label{class_Envelope_a1}


copy constructor.



Definition at line 20 of file envelope.C.\footnotesize\begin{verbatim}00021 {
00022 
00023   xdim = env_in.xdim;
00024   ydim = env_in.ydim;
00025   zdim = env_in.zdim;
00026 
00027   minx = env_in.minx;
00028   miny = env_in.miny;
00029   minz = env_in.minz;
00030 
00031   maxx = env_in.maxx;
00032   maxy = env_in.maxy;
00033   maxz = env_in.maxz;
00034 
00035   InputWidth = env_in.InputWidth;
00036   numPoints = env_in.numPoints;
00037 
00038   // allocate
00039   this->Env_Setup1();
00040 
00041   // copy data
00042   for (int c = 0; c<numPoints; c++){
00043     density_array[c] = env_in.density_array[c];
00044     gradient_field[c] = env_in.gradient_field[c];
00045   }
00046 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!~Envelope@{$\sim$Envelope}}
\index{~Envelope@{$\sim$Envelope}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Envelope::$\sim$Envelope ()}\label{class_Envelope_a2}


destructor.



Definition at line 52 of file envelope.C.\footnotesize\begin{verbatim}00052                     {
00053 
00054   if (density_array)
00055     delete [] density_array;
00056   
00057   if (gradient_field){
00058     delete [] gradient_field;
00059   }
00060 \end{verbatim}\normalsize 


\subsection{Member Function Documentation}
\index{Envelope@{Envelope}!Blur@{Blur}}
\index{Blur@{Blur}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Blur (int {\em k})}\label{class_Envelope_a23}


performs flat kernel convolution of 3D size (2$\ast$kernel\-Size+1) per side.



Definition at line 714 of file envelope.C.

Referenced by Envelope\-Constraint::Pre\-Setup().\footnotesize\begin{verbatim}00714                      {
00715 
00716   //  cerr << "------------ Blur Envelope Start    --------" << endl;
00717   
00718   if (k < 1){
00719     DIE("kernel size must be > 0");
00720   }
00721     
00722   int k2 = 2 * k;
00723   int kernelsize = (k2+1)*(k2+1)*(k2+1); // number of cells in the kernel
00724 
00725   int new_numPoints = (xdim+k2)*(ydim+k2)*(zdim+k2);  
00726   int new_xdim = xdim + k2;
00727   int new_ydim = ydim + k2;
00728   int new_zdim = zdim + k2;
00729   
00730   double o_kernelsize = 1./(double)kernelsize;
00731   double d = InputWidth * k;
00732   double * new_density_array = new double[new_numPoints]; // not sparse -- saving lots of zeros here. mem wasted.  FIX
00733   for (int l=0;l<new_numPoints;l++){new_density_array[l] =0;}
00734   jVector * new_gradient_field = new jVector[new_numPoints];
00735             // need to fix gradients after resize on blur. -- consider RESIZE function.
00736 
00737   double spread_val;  // density value to be "spread" to its neighbors
00738 
00739   // cycle over old array, processing cells with data
00740   int zh,yh,xh;
00741   for (zh =0;zh<zdim ;zh++){
00742     for (yh =0;yh<ydim ;yh++){
00743       for (xh =0;xh<xdim ;xh++){
00744         spread_val = ($\ast$this)(xh,yh,zh);
00745                 
00746         if (spread_val > 0) {
00747           
00748           // spread out value in cell across kernel (normalized to o_kernelsize)
00749           if (spread_val == 1) {
00750             spread_val = o_kernelsize;      
00751           } else {
00752             spread_val = spread_val * o_kernelsize;
00753           }
00754 
00755           for (int kz = 0; kz<(k2+1);kz++){
00756             for (int ky = 0; ky<(k2+1);ky++){
00757               for (int kx = 0; kx<(k2+1);kx++){
00758                 new_density_array[\
00759                                  (xh+kx)  \
00760                                  +  ((yh*new_xdim)+(ky*new_xdim))  \
00761                                  +  ((zh*new_xdim*new_ydim)+(kz*new_ydim*new_xdim)) \
00762                 ] += spread_val;
00763                 
00764               }  //kernel x
00765             }    //kernel y
00766           }      //kernel z
00767         } // skip 0 cells in old matrix.
00768       }   //x
00769     }     //y    
00770   }       //z
00771   
00772   //  resize to fit k more cells per side (d is the real size)
00773 
00774   minx -= d;
00775   miny -= d;
00776   minz -= d;
00777 
00778   maxx += d;
00779   maxy += d;
00780   maxz += d;
00781   
00782 
00783   xdim = new_xdim;
00784   ydim = new_ydim;
00785   zdim = new_zdim;
00786 
00787   if (density_array && gradient_field) {
00788     delete [] density_array;
00789     density_array = new_density_array; 
00790 
00791     delete [] gradient_field;
00792     gradient_field = new_gradient_field;  // empty
00793     
00794     numPoints = new_numPoints;
00795     
00796   } else {
00797     DIE("Called Blur on Envelope without intializing internal datastructures.");
00798   }
00799 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Build@{Build}}
\index{Build@{Build}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Build (const {\bf Molecule} \& {\em Mol}, double {\em IW\_\-in} = DEFAULT\_\-CUBE\_\-WIDTH)}\label{class_Envelope_a7}


create envelope from current molecule.



Definition at line 248 of file envelope.C.

Referenced by jd\-Occ\_\-Count::run().\footnotesize\begin{verbatim}00249 {
00250 
00251    //  here we need to build an envelope to describe the CM current molecule
00252 
00253   InputWidth = IW_in;
00254   Mol.Bounds(minx,miny,minz,maxx,maxy,maxz);
00255   // figure out dimensions
00256 
00257   xdim = 1 + int ((maxx-minx)/InputWidth); 
00258   ydim = 1 + int ((maxy-miny)/InputWidth); 
00259   zdim = 1 + int ((maxz-minz)/InputWidth); 
00260 
00261   maxx = minx + InputWidth*xdim; // reset to match
00262   maxy = miny + InputWidth*ydim;
00263   maxz = minz + InputWidth*zdim;
00264 
00265   numPoints = xdim*ydim*zdim;
00266 
00267   this->Env_Setup1();
00268   
00269   int zh, yh, xh;
00270   for (zh =0;zh<zdim ;zh++){
00271     for (yh =0;yh<ydim ;yh++){
00272       for (xh =0;xh<xdim ;xh++){
00273         ($\ast$this)(xh,yh,zh) = 0;     
00274       }
00275     }
00276   }
00277   
00278   int n = Mol.Number();
00279   jVector center;
00280   double radius;
00281   
00282   RanDbl RD;
00283   //  double cenx, ceny, cenz;
00284   double cenx, ceny, cenz;
00285   register double x, y, z;
00286   int x_cell,y_cell,z_cell;
00287   int N = 100000;
00288   
00289   // what we really want to count is how much "atom" there
00290   // is overlapping each box.
00291 
00292   // we exect 1/frac points per atom to be counted
00293   double frac = 6.02/(N * PI);
00294 
00295   // except in cases where the box size is smaller then the atom size
00296   // in this case we want these boxes to have density of 1 so we have
00297   // to adjust the 'frac' accordingly
00298 
00299   // assuming carbon VDW radius of 1.4 A here:
00300   if (InputWidth < 2.8) {
00301     cerr << "Envelope::Build->adjusting fraction for small gridsize" << endl;
00302     double temp1 = (1.4/InputWidth);
00303     frac = 8 * temp1* temp1* temp1 / N;
00304     
00305   }
00306   WARN_IF(frac > 0.01, "May need to increase counts for good statistics");
00307     //  cerr << "frac = " << frac << endl;
00308   
00309   for (int i =0; i < n; i++){
00310     cerr << ".";
00311     center = Mol(i);
00312     radius = Mol.getAtom(i).VDW();
00313     
00314     cenx = center[0];
00315     ceny = center[1];
00316     cenz = center[2];
00317     
00318     for (int j = 0;j<N;j++){
00319       x = RD.Get(-1,1);       y = RD.Get(-1,1);       z = RD.Get(-1,1);
00320       // XYZ ON (0,1) range
00321       if (x*x+y*y+z*z < 1){
00322         // point is inside unit sphere
00323         x = cenx + (x * radius);
00324         y = ceny + (y * radius);
00325         z = cenz + (z * radius);
00326         
00327         x_cell = (int) floor((x-minx)/InputWidth);
00328         y_cell = (int) floor((y-miny)/InputWidth);
00329         z_cell = (int) floor((z-minz)/InputWidth);
00330   
00331         ($\ast$this)(x_cell,y_cell,z_cell) = ($\ast$this)(x_cell,y_cell,z_cell) + frac;
00332 
00333       }// inside sphere?
00334     } // gen points    
00335   }
00336 
00337   cerr << endl;
00338   
00339   for (zh =0;zh<zdim ;zh++){
00340     for (yh =0;yh<ydim ;yh++){
00341       for (xh =0;xh<xdim ;xh++){
00342         if (($\ast$this)(xh,yh,zh) > MAX_ENV_DEN)
00343           ($\ast$this)(xh,yh,zh) = MAX_ENV_DEN;
00344       }
00345     }
00346   }
00347 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!CalcGradient@{CalcGradient}}
\index{CalcGradient@{CalcGradient}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Calc\-Gradient (int {\em d} = 1)}\label{class_Envelope_a21}


uses the current density\_\-array to calculate the gradient\_\-field.



Definition at line 440 of file envelope.C.

Referenced by Blur(), Read\-Avs\-Txt(), and Upsize().\footnotesize\begin{verbatim}00440                                 {
00441 
00442   if (d < 1){
00443     DIE ("gradient distance must be > 0");
00444   }
00445 
00446   double den;
00447   double val;
00448   jVector direction;
00449   int x,y,z;
00450   jVector J;
00451   int zh,yh,xh;
00452 
00453   for (zh =0;zh<zdim ;zh++){
00454     for (yh =0;yh<ydim ;yh++){
00455       for (xh =0;xh<xdim ;xh++){
00456 
00457         den =($\ast$this)(xh,yh,zh);
00458           
00459         // setting gradient at xh,yh,zh
00460         (($\ast$this).gradient(xh,yh,zh)).zero();
00461         
00462         for (int kz = (-1*d); kz<=d;kz++){
00463           for (int ky = (-1*d); ky<=d;ky++){
00464             for (int kx = (-1*d); kx<=d;kx++){
00465 
00466               
00467               
00468               // add-from coords
00469               x = xh+kx;
00470               y = yh+ky;
00471               z = zh+kz;
00472               
00473               if ((x >= 0) && (x < xdim) &&
00474                   (y >= 0) && (y < ydim) &&
00475                   (z >= 0) && (z < zdim))  {
00476                 // bounds OK
00477 
00478                 J.zero();               
00479                 if ((val = ($\ast$this)(x,y,z))){ //sic
00480                   J[0] = kx*val;
00481                   J[1] = ky*val;
00482                   J[2] = kz*val;
00483                 
00484                   J.norm_unit(); // J div by magnitude squared
00485                 
00486                   (($\ast$this).gradient(xh,yh,zh)) = (($\ast$this).gradient(xh,yh,zh)) + J;
00487                 } // else add nothing -- no density here
00488 
00489               } // bounds ok on add-from box
00490                 
00491               }  //kernel x
00492             }    //kernel y
00493           }      //kernel z
00494 
00495       }   //x
00496     }     //y    
00497   }
00498 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Calc_Eigenvectors@{Calc\_\-Eigenvectors}}
\index{Calc_Eigenvectors@{Calc\_\-Eigenvectors}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Calc\_\-Eigenvectors (void)}\label{class_Envelope_a20}


internal call to calc and store Eigenvectors.



Definition at line 510 of file envelope.C.

Referenced by Env\_\-Setup2().\footnotesize\begin{verbatim}00510                                 {
00511 
00512   Matrix Spread(3,3); // real symmetric
00513   Spread.zero();
00514   
00515   //  jVector tempV;
00516   double val;
00517   // Calc spread
00518   double dx, dy, dz = 0;
00519   
00520 
00521   for (int zh =0;zh<zdim ;zh++){
00522     for (int yh =0;yh<ydim ;yh++){
00523       for (int xh =0;xh<xdim ;xh++){
00524         
00525         val = ($\ast$this)(xh,yh,zh);
00526 
00527         if (val > 0) {
00528 
00529 //        dx = (xh - cm_x)*InputWidth*val/totalDensity;     
00530 //        dy = (yh - cm_y)*InputWidth*val/totalDensity;
00531 //        dz = (zh - cm_z)*InputWidth*val/totalDensity;
00532           dx = (xh - cm_x)*InputWidth*val;          
00533           dy = (yh - cm_y)*InputWidth*val;          
00534           dz = (zh - cm_z)*InputWidth*val;          
00535 
00536   
00537           Spread (1,1) += dx*dx/filledPoints;
00538           Spread (2,1) += dx*dy/filledPoints;
00539           Spread (2,2) += dy*dy/filledPoints;
00540           Spread (3,1) += dx*dz/filledPoints;
00541           Spread (3,2) += dy*dz/filledPoints;
00542           Spread (3,3) += dz*dz/filledPoints;
00543 //        Spread (1,1) += dx*dx;
00544 //        Spread (2,1) += dx*dy;
00545 //        Spread (2,2) += dy*dy;
00546 //        Spread (3,1) += dx*dz;
00547 //        Spread (3,2) += dy*dz;
00548 //        Spread (3,3) += dz*dz;
00549 
00550         } // end if
00551       } // x
00552     } // y
00553   }
00554 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Center@{Center}}
\index{Center@{Center}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Center (void)}\label{class_Envelope_a32}


adjust the max[xyz] and min[xyz] of the envelope to position the center of mass at the origin.



Definition at line 111 of file envelope.C.

Referenced by Envelope\-Constraint::Read().\footnotesize\begin{verbatim}00111                           {
00112     
00113 #ifdef NOISY_CONSTRAINTS
00114   WARN("Centering Envelope data on (0,0,0)");
00115   cerr << "original center_of_mass: (" << r_cm_x << "," << r_cm_y << "," << r_cm_z << ")" << endl;
00116 #endif  
00117   maxx -= r_cm_x;
00118   minx -= r_cm_x;
00119   maxy -= r_cm_y;
00120   miny -= r_cm_y;
00121   maxz -= r_cm_z;
00122   minz -= r_cm_z;
00123 
00124   // re calc metadata
00125   Env_Setup2();
00126   
00127 #ifdef NOISY_CONSTRAINTS
00128   cerr << "new      center_of_mass: (" << r_cm_x << "," << r_cm_y << "," << r_cm_z << ")" << endl;
00129   cerr << "done centering envelope." << endl;
00130 #endif
00131 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Compare@{Compare}}
\index{Compare@{Compare}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Compare (const Envelope \& {\em e}) const\hspace{0.3cm}{\tt  [inline]}}\label{class_Envelope_a14}


default compare function.



Definition at line 190 of file envelope.h.\footnotesize\begin{verbatim}00191 {
00192   DIE("Envelope Compare not Implemented");
00193   return 0;
00194 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!DiffReport@{DiffReport}}
\index{DiffReport@{DiffReport}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Diff\-Report (ostream \& {\em out\-Stream}, const Envelope \& {\em E})}\label{class_Envelope_a13}


Report on differences to another env.



Definition at line 352 of file envelope.C.

Referenced by main().\footnotesize\begin{verbatim}00352                                                                 {
00353 
00354   if (xdim != E.xdim || ydim != E.ydim || zdim != E.zdim ){
00355     outStream << "dimensions differ:\n" << xdim << " " <<ydim << " " <<zdim  << endl
00356               << E.xdim << " " <<E.ydim << " " <<E.zdim  << endl;
00357     outStream << "aborting";
00358     return;
00359   } else {
00360     outStream << "dimensions OK " << endl;
00361   }
00362 
00363   double THRESHOLD = 0.01;
00364 
00365   if (fabs(r_cm_x-E.r_cm_x)>THRESHOLD ||
00366       fabs(r_cm_y-E.r_cm_y)>THRESHOLD ||
00367       fabs(r_cm_z-E.r_cm_z)>THRESHOLD ){
00368     outStream << "COM differs: " << endl
00369               << r_cm_x << " " << r_cm_y << " " << r_cm_z << endl
00370               << E.r_cm_x << " " << E.r_cm_y << " " << E.r_cm_z << endl;  
00371   } else {
00372     outStream << "COM OK " << endl;
00373   }
00374   
00375   if (fabs(totalDensity -E.totalDensity) > 50* THRESHOLD)
00376     outStream << "totalDensity differs: " << totalDensity << "        " << E.totalDensity << endl;
00377   else {
00378     outStream << "totalDensity OK " << endl;
00379   }
00380   
00381   if (abs(filledPoints - E.filledPoints) > 2)
00382     outStream << "filledPoints differs: " << filledPoints << "        " << E.filledPoints << endl;
00383   else {
00384     outStream << "filledPoints OK " << endl;
00385   }
00386   
00387   double totalError = 0;
00388   double maxError = 0;
00389   int diff_count = 0;
00390   double diff;
00391 
00392     
00393   int zh,yh,xh;
00394   
00395   for (zh =0;zh<zdim ;zh++){
00396     for (yh =0;yh<ydim ;yh++){
00397       for (xh =0;xh<xdim ;xh++){
00398         diff = fabs ((*this)(xh,yh,zh) - E(xh,yh,zh)) ;
00399         totalError += diff;
00400         if (diff > maxError)
00401           maxError = diff;
00402         if (diff > THRESHOLD) {
00403           diff_count++;
00404         }       
00405       }
00406     }
00407   }
00408 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Env_Setup1@{Env\_\-Setup1}}
\index{Env_Setup1@{Env\_\-Setup1}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Env\_\-Setup1 ()}\label{class_Envelope_a30}


allocates memory.



Definition at line 63 of file envelope.C.

Referenced by Build(), Envelope(), and Read\-Avs\-Txt().\footnotesize\begin{verbatim}00063                           {
00064 
00065   density_array = new double[numPoints]; // not sparse -- saving lots of zeros here. mem wasted.  FIX
00066   //  cerr << " Allocating Envelope for "<< numPoints << endl;
00067   gradient_field = new jVector[numPoints];
00068 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Env_Setup2@{Env\_\-Setup2}}
\index{Env_Setup2@{Env\_\-Setup2}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Env\_\-Setup2 ()}\label{class_Envelope_a31}


calculates meta information about data.



Definition at line 70 of file envelope.C.

Referenced by Blur(), Center(), Envelope(), Read\-Avs\-Txt(), and Upsize().\footnotesize\begin{verbatim}00070                           {
00071   
00072   double val;
00073   int zh, yh, xh; // blocks
00074     
00076   filledPoints =  0;
00077   totalDensity = cm_z = cm_y = cm_x = 0;
00078 
00079   // first calc in blocks, then translate to real pos.
00080   for ( zh =0;zh<zdim ;zh++){
00081     for ( yh =0;yh<ydim ;yh++){
00082       for ( xh =0;xh<xdim ;xh++){
00083         val = ($\ast$this)(xh,yh,zh) ;
00084 
00085         if (val > 0) {
00086           filledPoints++;
00087           totalDensity += val;
00088 
00089 
00090           cm_x += xh * val;
00091           cm_y += yh * val;
00092           cm_z += zh * val;
00093          
00094         } 
00095       }
00096     }
00097   }
00098 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Get_Eigenvectors@{Get\_\-Eigenvectors}}
\index{Get_Eigenvectors@{Get\_\-Eigenvectors}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Get\_\-Eigenvectors ({\bf Matrix} \& {\em Eig\-Val}, {\bf Matrix} \& {\em Eig\-Vec}) const}\label{class_Envelope_a8}


writes Eigenvalues and Eigenvectors matricies by reference.



Definition at line 502 of file envelope.C.

Referenced by Envelope\-Constraint::Find\-Envelope\-Eigenvectors().\footnotesize\begin{verbatim}00502                                                                {
00503 
00504   EigVec = my_EigVec;
00505   EigVal = my_EigVal;
00506   
00507 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!MAKECOMPARISONS_WITH_COMPARE@{MAKECOMPARISONS\_\-WITH\_\-COMPARE}}
\index{MAKECOMPARISONS_WITH_COMPARE@{MAKECOMPARISONS\_\-WITH\_\-COMPARE}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Envelope::MAKECOMPARISONS\_\-WITH\_\-COMPARE (Envelope)}\label{class_Envelope_a15}


\index{Envelope@{Envelope}!NormalizeMax@{NormalizeMax}}
\index{NormalizeMax@{NormalizeMax}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Normalize\-Max ()}\label{class_Envelope_a24}


max max density = def's MAX\_\-ENV\_\-DEN' value and scale all cells accordingly.



Definition at line 813 of file envelope.C.

Referenced by Blur().\footnotesize\begin{verbatim}00813                         {
00814 
00815   double spread_val;
00816   double max_grid_val = -INF;
00817 
00818   // find max
00819   for (int zh =0;zh<zdim ;zh++){
00820     for (int yh =0;yh<ydim ;yh++){
00821       for (int xh =0;xh<xdim ;xh++){
00822         spread_val = ($\ast$this)(xh,yh,zh);
00823 
00824         if (spread_val > max_grid_val) {
00825           max_grid_val = spread_val;
00826         }
00827       }
00828     }
00829   }
00830 
00831   double o_max_grid_val = MAX_ENV_DEN / max_grid_val;
00832 
00833   // reset
00834   for (int zh =0;zh<zdim ;zh++){
00835     for (int yh =0;yh<ydim ;yh++){
00836       for (int xh =0;xh<xdim ;xh++){
00837         spread_val = ($\ast$this)(xh,yh,zh);
00838 
00839         ($\ast$this)(xh,yh,zh) = spread_val * o_max_grid_val;
00840         //      cerr << spread_val << "   " << spread_val * o_max_grid_val << endl;
00841       }
00842     }
00843   }
00844 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Output@{Output}}
\index{Output@{Output}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Output (ostream \& {\em os}) const}\label{class_Envelope_a18}




Definition at line 215 of file envelope.C.\footnotesize\begin{verbatim}00216 {
00217 
00218   os << "\nxdim = " << xdim
00219      << "\nydim = " << ydim
00220      << "\nzdim = " << zdim
00221 
00222      << "\nminx = " << minx
00223      << "\nminy = " << miny
00224      << "\nminz = " << minz
00225 
00226      << "\nmaxx = " << maxx
00227      << "\nmaxy = " << maxy
00228      << "\nmaxz = " << maxz << endl;
00229 
00230   os <<   "\nnumPoints = "  << numPoints 
00231      <<   "\nInputWidth = " << InputWidth << endl<< endl;
00232 
00233   int zh, yh, xh;
00234   for (zh =0;zh<zdim ;zh++){
00235     for (yh =0;yh<ydim ;yh++){
00236       for (xh =0;xh<xdim ;xh++){
00237         os << ($\ast$this)(xh,yh,zh) << " ";    
00238       }
00239         os << endl;
00240     }
00241     os << "--" << endl;
00242   }
00243 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!OutputBinary@{OutputBinary}}
\index{OutputBinary@{OutputBinary}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Output\-Binary (ostream \& {\em os}) const}\label{class_Envelope_a19}




Definition at line 424 of file envelope.C.\footnotesize\begin{verbatim}00425 {
00426   // NOT IMPLEMENTED
00427   //  os <= supportA <= measured <= variance;
00428   return 2;
00429 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!QueryDensity@{QueryDensity}}
\index{QueryDensity@{QueryDensity}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::Query\-Density (const {\bf j\-Vector} \& {\em pos}) const}\label{class_Envelope_a25}


returns density at `pos.



Definition at line 849 of file envelope.C.\footnotesize\begin{verbatim}00849                                                {
00850 
00851   int xh = (int)((pos[0] - minx)/InputWidth);
00852   int yh = (int)((pos[1] - miny)/InputWidth);
00853   int zh = (int)((pos[2] - minz)/InputWidth);
00854 
00855   return ($\ast$this)(xh,yh,zh);
00856   return 0;
00857 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!QueryGradient@{QueryGradient}}
\index{QueryGradient@{QueryGradient}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf j\-Vector} Envelope::Query\-Gradient (const {\bf j\-Vector} \& {\em pos}) const}\label{class_Envelope_a26}


\index{Envelope@{Envelope}!Read@{Read}}
\index{Read@{Read}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Read (istream \& {\em is})}\label{class_Envelope_a16}




Definition at line 418 of file envelope.C.

Referenced by Envelope\-Constraint::Read(), and main().\footnotesize\begin{verbatim}00419 {
00420   // assume avs file now, later check here and call appropriate read-in function.
00421   return ReadAvsTxt(is);
00422 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!ReadAvsTxt@{ReadAvsTxt}}
\index{ReadAvsTxt@{ReadAvsTxt}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Read\-Avs\-Txt (istream \& {\em in\-Stream})}\label{class_Envelope_a29}


read text-converted AVS density format.



Definition at line 1032 of file envelope.C.

Referenced by Read().\footnotesize\begin{verbatim}01032                                           {
01033 
01034 
01035   //  cerr << "------------ READ Envelope start    --------" << endl;
01036   
01037   if (density_array) {
01038     DIE("Envelope Read Error! It appears you have already read in density data into this envelope!");
01039   }   
01040   
01041   char d[255];  // used for reading header lines
01042 
01043   inStream.getline(d,255); // # AVS
01044   inStream.getline(d,255); // ndim
01045 
01046   //dim1
01047   inStream.ignore(5);
01048   inStream >>  xdim;
01049   //dim2
01050   inStream.ignore(6); // +\n
01051   inStream >>  ydim;
01052   //dim3
01053   inStream.ignore(6); // +\n
01054   inStream >>  zdim;
01055     
01056   //  cerr << "dim: " << xdim << ", "<< ydim << ", "<< zdim << endl;
01057 
01058   inStream.getline(d,255); // \n
01059 
01060   inStream.getline(d,255); // nspace
01061   inStream.getline(d,255); // vclean
01062   inStream.getline(d,255); // data
01063   inStream.getline(d,255); // field
01064   
01065   // mins
01066   inStream.ignore (9);
01067   inStream >>  minx >> miny >> minz;
01068 
01069   //  cerr << "min: " <<  minx << ", " << miny << ", " << minz << endl;
01070   
01071   // maxs
01072   inStream.ignore (10); // +\n
01073   inStream >>  maxx >> maxy >> maxz;
01074   
01075   //  cerr << "max: "  <<  maxx << ", " << maxy << ", " << maxz << endl;
01076 
01077   inStream.getline(d,255); // nspace
01078   inStream.getline(d,255); // # end of header
01079 
01080   InputWidth = (maxx-minx)/xdim;
01081   
01082   if (InputWidth > 50 || InputWidth < 0.01){
01083     cerr << "Input Grid Width is "<< InputWidth << " :Invalid.  Quitting." << endl;
01084     DIE("");
01085   }
01086   
01087   if ((fabs(InputWidth - (maxy-miny)/ydim) > 0.01) ||
01088       (fabs(InputWidth - (maxz-minz)/zdim) > 0.01)) {
01089     cerr << "AVS Input is not cubic" << endl;
01090     cerr << "dim: " << xdim << ", "<< ydim << ", "<< zdim << endl;
01091     cerr << "min: " <<  minx << ", " << miny << ", " << minz << endl;
01092     cerr << "max: "  <<  maxx << ", " << maxy << ", " << maxz << endl;  
01093     DIE("");
01094   }
01095   
01096   double val;
01097   int readCount = 0;
01098   //  jVector Pos(3,0.0);
01099 
01100   numPoints = xdim*ydim*zdim;
01101 
01102   if (numPoints >= INT_MAX || numPoints < 0){
01103     cerr << "Envelope size error!\n\n Envelope Class uses signed ints to index data, so "<< INT_MAX << " is the maximum number of cells possible.  Your number of cells is "<< numPoints << ", which is too large."<< endl;
01104     DIE("");
01105   }
01106 
01107   this->Env_Setup1();  
01108 
01109   int zh, yh, xh;
01110   for ( zh =0;zh<zdim ;zh++){
01111     for ( yh =0;yh<ydim ;yh++){
01112       for ( xh =0;xh<xdim ;xh++){
01113         inStream >> val;
01114 
01115         if (val > 0) {
01116           totalDensity += val;
01117         }
01118         
01119         if (!inStream.good()){
01120           cerr << "Envelope reading error!\n\n read "<< readCount << " entries, expected "<< numPoints << endl;
01121           DIE("");
01122         }
01123 
01124         ($\ast$this)(xh,yh,zh) = val;             // not sparse -- saving lots of zeros here. mem wasted.  FIX
01125         readCount++;    
01126       }
01127     }
01128   }
01129 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!ReadBinary@{ReadBinary}}
\index{ReadBinary@{ReadBinary}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Read\-Binary (istream \& {\em is})}\label{class_Envelope_a17}




Definition at line 431 of file envelope.C.\footnotesize\begin{verbatim}00432 {
00433   // NOT IMPLEMENTED
00434   //  is >= supportA[0] >= supportA[1] >= measured >= variance;
00435   return 2;
00436 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!Upsize@{Upsize}}
\index{Upsize@{Upsize}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Envelope::Upsize (int {\em k})}\label{class_Envelope_a22}


increases the box size by a factor k'.



Definition at line 569 of file envelope.C.

Referenced by Envelope\-Constraint::Pre\-Setup().\footnotesize\begin{verbatim}00569                        {
00570 
00571 //   if (k != 2 && k != 3 && k!=4){
00572 //     DIE("upsize k factor must be 2,3 or 4");
00573 //   }
00574    if (k != 2){
00575      DIE("upsize k factor must be 2");
00576    }  // 3 and 4 require more login in resetting real bounds.
00577   
00578   int new_xdim,new_ydim,new_zdim;
00579   // figure out new bounds
00580 
00581   int err;
00582   err = (xdim%k ? 1: 0);  
00583   new_xdim = xdim/k+err;
00584 
00585   err = (ydim%k ? 1: 0);  
00586   new_ydim = ydim/k+err;
00587 
00588   err = (zdim%k ? 1: 0);  
00589   new_zdim = zdim/k+err;
00590 
00591   
00592   int new_numPoints = new_xdim * new_ydim * new_zdim;
00593   double new_InputWidth = k * InputWidth;
00594 
00595   // begin: this whole section is more complex for k = 3 or 4
00596   //  double new_minx, new_miny, new_minz;  
00597   double new_maxx, new_maxy, new_maxz;
00598 
00599   new_maxx = minx + new_InputWidth*new_xdim;
00600   new_maxy = miny + new_InputWidth*new_ydim;
00601   new_maxz = minz + new_InputWidth*new_zdim;
00602   // end:   this whole section is more complex for k = 3 or 4
00603   
00604   double * new_density_array = new double[new_numPoints]; // not sparse
00605   for (int l=0;l<new_numPoints;l++){new_density_array[l] =0;}
00606   jVector * new_gradient_field = new jVector[new_numPoints];
00607   for (int l=0;l<new_numPoints;l++){new_gradient_field[l].zero();}
00608   
00609   double old_val;  // old density value
00610 
00611   // cycle over old array, processing cells with data
00612   int zh,yh,xh;
00613   int new_index;
00614   int new_index_x, new_index_y, new_index_z;
00615   for (zh =0;zh<zdim ;zh++){
00616     //    new_index_z = (zh/k+(zh%k?1:0))*new_ydim*new_zdim;
00617     new_index_z = (zh/k)*new_ydim*new_xdim;
00618     for (yh =0;yh<ydim ;yh++){
00619       //      new_index_y = (yh/k+(yh%k?1:0))*new_xdim;
00620       new_index_y = (yh/k)*new_xdim;
00621       for (xh =0;xh<xdim ;xh++){
00622         //      new_index_x = xh/k+(xh%k?1:0);
00623         new_index_x = xh/k; 
00624         old_val = ($\ast$this)(xh,yh,zh);
00625 
00626 //      cerr << " xh=" << xh
00627 //           << " yh=" << yh
00628 //           << " zh=" << zh << endl;
00629 // 
00630 //      cerr << " new_index_x=" << new_index_x
00631 //           << " new_index_y=" << new_index_y
00632 //           << " new_index_z=" << new_index_z << endl;
00633 // 
00634 //      int aa = (xh)+(yh)*xdim+(zh)*xdim*ydim ;
00635 //      cerr << " old index = " << aa << " of " << numPoints << endl;
00636 // 
00637         new_index = new_index_x+new_index_y+new_index_z;
00638 //      cerr << " new index = " << new_index << " of " << new_numPoints << endl << endl;
00639 //      
00640         
00641         if (old_val > 0) {
00642           old_val = old_val / (k*k*k);
00643 
00644           if (new_index > new_numPoints) {
00645             DIE ("ACK");
00646           }
00647           new_density_array[new_index] += old_val;                
00648         }
00649       }
00650     }
00651   }
00652   
00653   maxx = new_maxx;
00654   maxy = new_maxy;
00655   maxz = new_maxz;
00656 
00657 //   minx = new_minx;
00658 //   miny = new_miny;
00659 //   minz = new_minz;  
00660   
00661   xdim = new_xdim;
00662   ydim = new_ydim;
00663   zdim = new_zdim;
00664 
00665   if (density_array && gradient_field) {
00666     delete [] density_array;
00667     density_array = new_density_array; 
00668     new_density_array = 0;
00669     
00670     delete [] gradient_field;
00671     gradient_field = new_gradient_field;  // empty
00672     new_gradient_field = 0;
00673     
00674     InputWidth = new_InputWidth;
00675     numPoints = new_numPoints;
00676     
00677   } else {
00678     DIE("Called Upsize on Envelope without intializing internal datastructures.");
00679   }
00680 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!WriteAvsTxt@{WriteAvsTxt}}
\index{WriteAvsTxt@{WriteAvsTxt}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Write\-Avs\-Txt (ostream \& {\em out\-Stream}) const}\label{class_Envelope_a10}


write AVS density format(as text).



Definition at line 1003 of file envelope.C.

Referenced by jd\-Occ\_\-Count::run().\footnotesize\begin{verbatim}01003                                                    {
01004 
01005   outStream << "envelope: # AVS field file" << endl;
01006   outStream << "ndim=3" << endl;
01007   outStream << "xdim= " << xdim << endl;
01008   outStream << "ydim= " << ydim << endl;
01009   outStream << "zdim= " << zdim << endl;
01010   outStream << "nspace=3" << endl;
01011   outStream << "veclen=1" << endl;
01012   outStream << "data=float" << endl;
01013   outStream << "field=uniform" << endl;
01014   outStream << "min_ext= " << minx << " "  << miny  << " " << minz << endl;
01015   outStream << "max_ext= " << maxx  << " " << maxy  << " " << maxz << endl;
01016   outStream << "# end of header" << endl;
01017 
01018   int zh, yh, xh;
01019   for (zh =0;zh<zdim ;zh++){
01020     for (yh =0;yh<ydim ;yh++){
01021       for (xh =0;xh<xdim ;xh++){
01022         outStream << ($\ast$this)(xh,yh,zh) << " ";
01023 
01024       }
01025     }
01026   }
01027 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!WriteDensity@{WriteDensity}}
\index{WriteDensity@{WriteDensity}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Write\-Density (ostream \& {\em out\-Stream}, const {\bf Molecule} \& {\em Mol}) const}\label{class_Envelope_a9}


write out a list of atoms and their density in the env.



Definition at line 988 of file envelope.C.

Referenced by jd\-Occ\_\-Count::run().\footnotesize\begin{verbatim}00988                                                                         {
00989 
00990   jVector center;
00991   
00992   int n = Mol.Number();
00993   for (int i=0;i<n;i++){
00994 
00995     center = Mol(i);
00996     outStream << ($\ast$this)(center)  << ": " << i << endl;
00997     
00998   }
00999 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!WriteVRML@{WriteVRML}}
\index{WriteVRML@{WriteVRML}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Write\-VRML (ostream \& {\em out\-Stream}) const}\label{class_Envelope_a11}


write VRML 1.0 format.



Definition at line 859 of file envelope.C.

Referenced by Envelope\-Constraint::Write\-VRML\_\-Orig\-Data(), and jd\-Occ\_\-Count::run().\footnotesize\begin{verbatim}00859                                                  {
00860 
00861   outStream << "#VRML V1.0 ascii" << endl;
00862 
00863   double x,y,z;
00864   double i_half = InputWidth/2;
00865   double val, t;
00866   
00867   int zh, yh, xh;
00868   for (zh =0;zh<zdim ;zh++){
00869     for (yh =0;yh<ydim ;yh++){
00870       for (xh =0;xh<xdim ;xh++){
00871         val = ($\ast$this)(xh,yh,zh);
00872         
00873         
00874         if (val> 0) {
00875           t  = 0.5-val/2;
00876 
00877           x = minx + i_half + xh * InputWidth; 
00878           y = miny + i_half + yh * InputWidth; 
00879           z = minz + i_half + zh * InputWidth; 
00880 
00881           
00882           
00883           outStream << "Separator{" << endl;
00884           if (val > .9)
00885             outStream << "Material{specularColor 0.8 0.8 0.8 diffuseColor 1 0.2 0.2 transparency 0.1" \
00886                       <<"}" << endl;
00887           else if (val > .5)
00888             outStream << "Material{specularColor 0.5 0.5 0.5 diffuseColor 0.2 0.8 0.2 transparency " \
00889                       << t <<"}" << endl;
00890           else 
00891             outStream << "Material{specularColor 0.2 0.2 0.2 diffuseColor 0.3 0.3 0.3 transparency " \
00892                       << t <<"}" << endl;
00893           
00894           outStream << "Transform{translation "<< x << " " << y << " "\
00895                     << z << " " <<"}" << endl;
00896           outStream << "Cube{width " << InputWidth << " height " \
00897                     << InputWidth << " depth " << InputWidth <<"}" << endl;
00898           outStream << "}" << endl;
00899           
00900         }
00901         
00902       }
00903     }
00904   }
00905 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!WriteVRMLgr@{WriteVRMLgr}}
\index{WriteVRMLgr@{WriteVRMLgr}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::Write\-VRMLgr (ostream \& {\em out\-Stream}) const}\label{class_Envelope_a12}


write VRML 1.0 format with gradient arrows.



Definition at line 910 of file envelope.C.\footnotesize\begin{verbatim}00910                                                    {
00911 
00912   outStream << "#VRML V1.0 ascii\nSeparator{" << endl;
00913 
00914   double x,y,z;
00915   double xr,yr,zr, rad;
00916   double i_half = InputWidth/2;
00917   double val, t;
00918   jVector G;
00919   int scale;
00920   
00921   
00922   int zh, yh, xh;
00923   for (zh =0;zh<zdim ;zh++){
00924     for (yh =0;yh<ydim ;yh++){
00925       for (xh =0;xh<xdim ;xh++){
00926         val = ($\ast$this)(xh,yh,zh);
00927         G = gradient(xh,yh,zh);
00928         
00929         if (val> 0) {
00930           t  = 0.5-val/2;
00931 
00932           x = minx + i_half + xh * InputWidth; 
00933           y = miny + i_half + yh * InputWidth; 
00934           z = minz + i_half + zh * InputWidth; 
00935 
00936           xr = G[2];
00937           yr = 0;
00938           zr = -1 * G[0];
00939           if((rad = G.mag())) // sic
00940             rad =  acos (G[1]/(rad));
00941 
00942           scale = ((int) i_half)+1;
00943           
00944           outStream << " Separator{" << endl;
00945                   
00946           outStream << "  Transform{translation "<< x << " " << y << " "\
00947                     << z << " " <<"}" << endl;
00948 
00949           outStream << "  Separator{" << endl;
00950           if (val > .9)
00951             outStream << "   Material{specularColor 0.8 0.8 0.8 diffuseColor 1 0.2 0.2 transparency 0.1" \
00952                       <<"}" << endl;
00953           else if (val > .5)
00954             outStream << "   Material{specularColor 0.5 0.5 0.5 diffuseColor 0.2 0.8 0.2 transparency " \
00955                       << t <<"}" << endl;
00956           else 
00957             outStream << "   Material{specularColor 0.2 0.2 0.2 diffuseColor 0.3 0.3 0.3 transparency " \
00958                       << t <<"}" << endl;
00959           
00960           outStream << "   Cube{width " << InputWidth << " height " \
00961                     << InputWidth << " depth " << InputWidth <<"}" << endl;
00962           outStream << "  }" << endl;
00963 
00964           outStream << "  Separator{" << endl;
00965           
00966           outStream << "   Material {diffuseColor 0 0 1} " << endl;
00967           outStream << "   Transform {rotation " << xr << " "<< yr << " "<< zr <<" "<< rad <<"}" << endl;   
00968           outStream << "   # gradient vector =" << G   << endl;
00969           outStream << "   Scale {scaleFactor " << scale <<" " << scale <<" " << scale <<"}" << endl;
00970           outStream << "   Cylinder {radius  .2 height  1 }" << endl;
00971           outStream << "   Transform {translation 0 1 0}" << endl;
00972           outStream << "   Cone { parts SIDES bottomRadius .2 height 1}" << endl;
00973 
00974           outStream << "  }" << endl;
00975           
00976           outStream << " }" << endl;
00977           
00978         }
00979         
00980       }
00981     }
00982   }
00983 
00984   outStream << "}
00985 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!gradient@{gradient}}
\index{gradient@{gradient}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf j\-Vector} \& Envelope::gradient (int {\em x}, int {\em y}, int {\em z})}\label{class_Envelope_a28}


lvalue (for assigning gradient).



Definition at line 135 of file envelope.C.\footnotesize\begin{verbatim}00135                                       {
00136   if ((x < 0) || (x >= xdim) ||
00137       (y < 0) || (y >= ydim) ||
00138       (z < 0) || (z >= zdim))  {
00139     cerr << "Envelope gradient access out of bounds.  I got "
00140          << x << ", "<< y << ", "<< z << endl;
00141     raise (SIGQUIT);    
00142    
00143   }
00144 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!gradient@{gradient}}
\index{gradient@{gradient}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf j\-Vector} \& Envelope::gradient ({\bf j\-Vector} {\em J}) const}\label{class_Envelope_a6}


access gradient.



Definition at line 164 of file envelope.C.\footnotesize\begin{verbatim}00164                                   {
00165   int x,y,z;
00166 
00167   // check this
00168   x = (int) floor((J[0]-minx)/InputWidth);
00169   y = (int) floor((J[1]-miny)/InputWidth);
00170   z = (int) floor((J[2]-minz)/InputWidth);
00171   
00172   return gradient(x,y,z);  
00173 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!gradient@{gradient}}
\index{gradient@{gradient}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf j\-Vector} \& Envelope::gradient (int {\em x}, int {\em y}, int {\em z}) const}\label{class_Envelope_a5}


access gradient by cell.



Definition at line 150 of file envelope.C.

Referenced by Write\-VRMLgr(), Envelope\-Constraint::get\-Gradient(), and gradient().\footnotesize\begin{verbatim}00150                                             {
00151   if ((x < 0) || (x >= xdim) ||
00152       (y < 0) || (y >= ydim) ||
00153       (z < 0) || (z >= zdim))  {
00154 //     cerr << "Envelope const gradient access out of bounds.  I got "
00155 //       << x << ", "<< y << ", "<< z << endl;
00156 //     raise (SIGQUIT);
00157     return JVzero3; 
00158   }
00159 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!operator()@{operator()}}
\index{operator()@{operator()}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double \& Envelope::operator() (int {\em x}, int {\em y}, int {\em z})}\label{class_Envelope_a27}


lvalue (for assigning density).



Definition at line 178 of file envelope.C.\footnotesize\begin{verbatim}00178                                         {
00179   if ((x < 0) || (x >= xdim) ||
00180       (y < 0) || (y >= ydim) ||
00181       (z < 0) || (z >= zdim))  {
00182     cerr << "Tried to assign to Envelope out of bounds.  I got "
00183          << x << ", "<< y << ", "<< z << endl;
00184     DIE("");
00185   }
00186 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!operator()@{operator()}}
\index{operator()@{operator()}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const double Envelope::operator() (const {\bf j\-Vector} \& {\em J}) const}\label{class_Envelope_a4}


access density by position.



Definition at line 203 of file envelope.C.\footnotesize\begin{verbatim}00203                                            {
00204   int x,y,z;
00205 
00206   // check this
00207   x = (int) floor((J[0]-minx)/InputWidth);
00208   y = (int) floor((J[1]-miny)/InputWidth);
00209   z = (int) floor((J[2]-minz)/InputWidth);
00210   
00211   return ($\ast$this)(x,y,z);
00212   
00213 \end{verbatim}\normalsize 
\index{Envelope@{Envelope}!operator()@{operator()}}
\index{operator()@{operator()}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const double Envelope::operator() (int {\em x}, int {\em y}, int {\em z}) const}\label{class_Envelope_a3}


access density by cell.



Definition at line 190 of file envelope.C.\footnotesize\begin{verbatim}00190                                               {
00191   if ((x < 0) || (x >= xdim) ||
00192       (y < 0) || (y >= ydim) ||
00193       (z < 0) || (z >= zdim))  {
00194 //     cerr << "Envelope const access out of bounds.  I got "
00195 //       << x << ", "<< y << ", "<< z << endl;
00196 //     raise (SIGQUIT);
00197     return MIN_ENV_DEN;
00198   }
00199 \end{verbatim}\normalsize 


\subsection{Friends And Related Function Documentation}
\index{Envelope@{Envelope}!EnvelopeConstraint@{EnvelopeConstraint}}
\index{EnvelopeConstraint@{EnvelopeConstraint}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}class Envelope\-Constraint\hspace{0.3cm}{\tt  [friend]}}\label{class_Envelope_l0}




Definition at line 34 of file envelope.h.

\subsection{Member Data Documentation}
\index{Envelope@{Envelope}!InputWidth@{InputWidth}}
\index{InputWidth@{InputWidth}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::Input\-Width}\label{class_Envelope_m6}


Real width of cubes (e.g. 3.7A).



Definition at line 106 of file envelope.h.\index{Envelope@{Envelope}!JVzero3@{JVzero3}}
\index{JVzero3@{JVzero3}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf j\-Vector} Envelope::JVzero3}\label{class_Envelope_m23}


useful null vector.



Definition at line 180 of file envelope.h.\index{Envelope@{Envelope}!cm_x@{cm\_\-x}}
\index{cm_x@{cm\_\-x}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::cm\_\-x}\label{class_Envelope_m13}


Center of mass, weighted by probabilities, (as blocks).



Definition at line 119 of file envelope.h.\index{Envelope@{Envelope}!cm_y@{cm\_\-y}}
\index{cm_y@{cm\_\-y}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::cm\_\-y}\label{class_Envelope_m14}


Center of mass, weighted by probabilities, (as blocks).



Definition at line 119 of file envelope.h.\index{Envelope@{Envelope}!cm_z@{cm\_\-z}}
\index{cm_z@{cm\_\-z}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::cm\_\-z}\label{class_Envelope_m15}


Center of mass, weighted by probabilities, (as blocks).



Definition at line 119 of file envelope.h.\index{Envelope@{Envelope}!density_array@{density\_\-array}}
\index{density_array@{density\_\-array}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double $\ast$ Envelope::density\_\-array}\label{class_Envelope_m0}


Array of doubles storing density.



Definition at line 94 of file envelope.h.\index{Envelope@{Envelope}!filledPoints@{filledPoints}}
\index{filledPoints@{filledPoints}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::filled\-Points}\label{class_Envelope_m20}


Number of non-zero cubes in Envelope.



Definition at line 128 of file envelope.h.\index{Envelope@{Envelope}!gradient_field@{gradient\_\-field}}
\index{gradient_field@{gradient\_\-field}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf j\-Vector} $\ast$ Envelope::gradient\_\-field}\label{class_Envelope_m1}


Array of j\-Vectors storing gradient.



Definition at line 97 of file envelope.h.\index{Envelope@{Envelope}!maxx@{maxx}}
\index{maxx@{maxx}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::maxx}\label{class_Envelope_m10}


Real position of max edges of region.



Definition at line 112 of file envelope.h.\index{Envelope@{Envelope}!maxy@{maxy}}
\index{maxy@{maxy}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::maxy}\label{class_Envelope_m11}


Real position of max edges of region.



Definition at line 112 of file envelope.h.\index{Envelope@{Envelope}!maxz@{maxz}}
\index{maxz@{maxz}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::maxz}\label{class_Envelope_m12}


Real position of max edges of region.



Definition at line 112 of file envelope.h.\index{Envelope@{Envelope}!minx@{minx}}
\index{minx@{minx}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::minx}\label{class_Envelope_m7}


Real position of min edges of region.



Definition at line 109 of file envelope.h.\index{Envelope@{Envelope}!miny@{miny}}
\index{miny@{miny}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::miny}\label{class_Envelope_m8}


Real position of min edges of region.



Definition at line 109 of file envelope.h.\index{Envelope@{Envelope}!minz@{minz}}
\index{minz@{minz}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::minz}\label{class_Envelope_m9}


Real position of min edges of region.



Definition at line 109 of file envelope.h.\index{Envelope@{Envelope}!my_EigVal@{my\_\-EigVal}}
\index{my_EigVal@{my\_\-EigVal}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Matrix} Envelope::my\_\-Eig\-Val}\label{class_Envelope_m21}


Eigenvalues for the envelope.



Definition at line 131 of file envelope.h.\index{Envelope@{Envelope}!my_EigVec@{my\_\-EigVec}}
\index{my_EigVec@{my\_\-EigVec}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Matrix} Envelope::my\_\-Eig\-Vec}\label{class_Envelope_m22}


Eigenvectors for the envelope.



Definition at line 134 of file envelope.h.\index{Envelope@{Envelope}!numPoints@{numPoints}}
\index{numPoints@{numPoints}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::num\-Points}\label{class_Envelope_m2}


Number of cubes in Envelope.



Definition at line 100 of file envelope.h.\index{Envelope@{Envelope}!r_cm_x@{r\_\-cm\_\-x}}
\index{r_cm_x@{r\_\-cm\_\-x}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::r\_\-cm\_\-x}\label{class_Envelope_m16}


Center of mass, weighted by probabilities, (Real postition!).



Definition at line 122 of file envelope.h.\index{Envelope@{Envelope}!r_cm_y@{r\_\-cm\_\-y}}
\index{r_cm_y@{r\_\-cm\_\-y}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::r\_\-cm\_\-y}\label{class_Envelope_m17}


Center of mass, weighted by probabilities, (Real postition!).



Definition at line 122 of file envelope.h.\index{Envelope@{Envelope}!r_cm_z@{r\_\-cm\_\-z}}
\index{r_cm_z@{r\_\-cm\_\-z}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::r\_\-cm\_\-z}\label{class_Envelope_m18}


Center of mass, weighted by probabilities, (Real postition!).



Definition at line 122 of file envelope.h.\index{Envelope@{Envelope}!totalDensity@{totalDensity}}
\index{totalDensity@{totalDensity}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Envelope::total\-Density}\label{class_Envelope_m19}


Total of all the density numbers in the cubes.



Definition at line 125 of file envelope.h.\index{Envelope@{Envelope}!xdim@{xdim}}
\index{xdim@{xdim}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::xdim}\label{class_Envelope_m3}


Dimensions in number of cubes.



Definition at line 103 of file envelope.h.\index{Envelope@{Envelope}!ydim@{ydim}}
\index{ydim@{ydim}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::ydim}\label{class_Envelope_m4}


Dimensions in number of cubes.



Definition at line 103 of file envelope.h.\index{Envelope@{Envelope}!zdim@{zdim}}
\index{zdim@{zdim}!Envelope@{Envelope}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Envelope::zdim}\label{class_Envelope_m5}


Dimensions in number of cubes.



Definition at line 103 of file envelope.h.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
{\bf envelope.h}\item 
{\bf envelope.C}\end{CompactItemize}
