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

molshape.h

00001 //
00002 // molshape.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifndef _chemistry_molecule_molshape_h
00029 #define _chemistry_molecule_molshape_h
00030 
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034 
00035 #include <util/misc/formio.h>
00036 
00037 #include <math/isosurf/shape.h>
00038 #include <chemistry/molecule/atominfo.h>
00039 #include <chemistry/molecule/molecule.h>
00040 
00045 class VDWShape: public UnionShape {
00046  private:
00047     Ref<AtomInfo> atominfo_;
00048  public:
00049     VDWShape(const Ref<Molecule>&);
00050     VDWShape(const Ref<KeyVal>&);
00051     ~VDWShape();
00052     void initialize(const Ref<Molecule>&);
00053 };  
00054 
00059 class DiscreteConnollyShape: public UnionShape {
00060   private:
00061     double radius_scale_factor_;
00062     Ref<AtomInfo> atominfo_;
00063  public:
00064     DiscreteConnollyShape(const Ref<KeyVal>&);
00065     ~DiscreteConnollyShape();
00066     void initialize(const Ref<Molecule>&,double probe_radius);
00067 };
00068 
00069 #ifndef COUNT_CONNOLLY
00070 # define COUNT_CONNOLLY 1
00071 #endif
00072 
00073 // This is a utility class needed by ConnollyShape2
00074 class CS2Sphere
00075 {
00076     SCVector3 _v;
00077     double _radius;
00078 
00079   public:
00080 #if COUNT_CONNOLLY
00081     static int n_no_spheres_;
00082     static int n_probe_enclosed_by_a_sphere_;
00083     static int n_probe_center_not_enclosed_;
00084     static int n_surface_of_s0_not_covered_;
00085     static int n_plane_totally_covered_;
00086     static int n_internal_edge_not_covered_;
00087     static int n_totally_covered_;
00088 #endif
00089 
00090     CS2Sphere(const SCVector3& v, double rad):
00091     _v(v),_radius(rad){}
00092     CS2Sphere(double x, double y, double z, double rad):
00093     _v(x,y,z),_radius(rad){}
00094     CS2Sphere(void) {};
00095     void initialize(SCVector3& v, double rad) {
00096         _v = v; _radius = rad; }
00097 
00098     CS2Sphere& operator=(const CS2Sphere&s) {
00099         _v = s._v; _radius = s._radius; return *this; }
00100     
00101     // Return the distance between the centers of the two
00102     // spheres
00103     double distance(CS2Sphere &asphere)
00104     { return sqrt((_v[0]-asphere._v[0])*(_v[0]-asphere._v[0])+
00105                   (_v[1]-asphere._v[1])*(_v[1]-asphere._v[1])+
00106                   (_v[2]-asphere._v[2])*(_v[2]-asphere._v[2]));}  
00107 
00108     // Return the radius of the circle intersecting the two spheres
00109     // Note that this assumes the spheres do overlap!
00110     double common_radius(CS2Sphere &asphere);
00111 
00112     // Return the center
00113     const SCVector3& center(void) const { return _v; }
00114     double x() const { return _v[0]; }
00115     double y() const { return _v[1]; }
00116     double z() const { return _v[2]; }
00117 
00118     // Return the vector3d connecting the two centers
00119     SCVector3 center_vec(const CS2Sphere &asphere) { return _v - asphere._v; }
00120 
00121     double radius(void) const {return _radius;}
00122 
00123     void recenter(const SCVector3 &v) { _v -= v; }
00124     void print(std::ostream& os=ExEnv::out()) const
00125     {
00126       os << node0 << indent
00127          << scprintf("Rad=%lf, Center=(%lf,%lf,%lf), From origin=%lf\n",
00128                      _radius, _v[0], _v[1], _v[2], _v.norm());
00129     }
00130 
00131     // Function to determine if there is any portion of this that 
00132     // is not inside one or more of the spheres in s[].  Returns
00133     // 1 if the intersection is empty, otherwise 0 is returned.
00134     // Warning: the spheres in s are modified.
00135     int intersect(CS2Sphere *s,
00136                   int n_spheres) const;
00137 
00138     static void print_counts(std::ostream& = ExEnv::out());
00139 };
00140 
00141 #define CONNOLLYSHAPE_N_WITH_NSPHERE_DIM 10
00142 
00146 class ConnollyShape: public Shape {
00147   private:
00148     CS2Sphere* sphere;
00149     double probe_r;
00150     double radius_scale_factor_;
00151     int n_spheres;
00152     Ref<AtomInfo> atominfo_;
00153 
00154     Arrayint ***box_;
00155     double l_;
00156     int xmax_;
00157     int ymax_;
00158     int zmax_;
00159     SCVector3 lower_;
00160 
00161     int get_box(const SCVector3 &v, int &x, int &y, int &z) const;
00162 
00163 #if COUNT_CONNOLLY
00164     static int n_total_;
00165     static int n_inside_vdw_;
00166     static int n_with_nsphere_[CONNOLLYSHAPE_N_WITH_NSPHERE_DIM];
00167 #endif
00168 
00169   public:
00170     ConnollyShape(const Ref<KeyVal>&);
00171     ~ConnollyShape();
00172     void initialize(const Ref<Molecule>&,double probe_radius);
00173     void clear();
00174     double distance_to_surface(const SCVector3&r,
00175                                SCVector3*grad=0) const;
00176     void boundingbox(double valuemin,
00177                      double valuemax,
00178                      SCVector3& p1, SCVector3& p2);
00179 
00180     static void print_counts(std::ostream& = ExEnv::out());
00181 };
00182 
00183 #endif
00184 
00185 // Local Variables:
00186 // mode: c++
00187 // c-file-style: "CLJ"
00188 // End:

Generated at Thu Oct 4 18:08:46 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.