|
molshape.h00001 // 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 00041 namespace sc { 00042 00047 class VDWShape: public UnionShape { 00048 private: 00049 Ref<AtomInfo> atominfo_; 00050 public: 00051 VDWShape(const Ref<Molecule>&); 00052 VDWShape(const Ref<KeyVal>&); 00053 ~VDWShape(); 00054 void initialize(const Ref<Molecule>&); 00055 }; 00056 00061 class DiscreteConnollyShape: public UnionShape { 00062 private: 00063 double radius_scale_factor_; 00064 Ref<AtomInfo> atominfo_; 00065 public: 00066 DiscreteConnollyShape(const Ref<KeyVal>&); 00067 ~DiscreteConnollyShape(); 00068 void initialize(const Ref<Molecule>&,double probe_radius); 00069 }; 00070 00071 #ifndef COUNT_CONNOLLY 00072 # define COUNT_CONNOLLY 1 00073 #endif 00074 00075 // This is a utility class needed by ConnollyShape2 00076 class CS2Sphere 00077 { 00078 SCVector3 _v; 00079 double _radius; 00080 00081 public: 00082 #if COUNT_CONNOLLY 00083 static int n_no_spheres_; 00084 static int n_probe_enclosed_by_a_sphere_; 00085 static int n_probe_center_not_enclosed_; 00086 static int n_surface_of_s0_not_covered_; 00087 static int n_plane_totally_covered_; 00088 static int n_internal_edge_not_covered_; 00089 static int n_totally_covered_; 00090 #endif 00091 00092 CS2Sphere(const SCVector3& v, double rad): 00093 _v(v),_radius(rad){} 00094 CS2Sphere(double x, double y, double z, double rad): 00095 _v(x,y,z),_radius(rad){} 00096 CS2Sphere(void) {}; 00097 void initialize(SCVector3& v, double rad) { 00098 _v = v; _radius = rad; } 00099 00100 CS2Sphere& operator=(const CS2Sphere&s) { 00101 _v = s._v; _radius = s._radius; return *this; } 00102 00103 // Return the distance between the centers of the two 00104 // spheres 00105 double distance(CS2Sphere &asphere) 00106 { return sqrt((_v[0]-asphere._v[0])*(_v[0]-asphere._v[0])+ 00107 (_v[1]-asphere._v[1])*(_v[1]-asphere._v[1])+ 00108 (_v[2]-asphere._v[2])*(_v[2]-asphere._v[2]));} 00109 00110 // Return the radius of the circle intersecting the two spheres 00111 // Note that this assumes the spheres do overlap! 00112 double common_radius(CS2Sphere &asphere); 00113 00114 // Return the center 00115 const SCVector3& center(void) const { return _v; } 00116 double x() const { return _v[0]; } 00117 double y() const { return _v[1]; } 00118 double z() const { return _v[2]; } 00119 00120 // Return the vector3d connecting the two centers 00121 SCVector3 center_vec(const CS2Sphere &asphere) { return _v - asphere._v; } 00122 00123 double radius(void) const {return _radius;} 00124 00125 void recenter(const SCVector3 &v) { _v -= v; } 00126 void print(std::ostream& os=ExEnv::out0()) const 00127 { 00128 os << indent 00129 << scprintf("Rad=%lf, Center=(%lf,%lf,%lf), From origin=%lf\n", 00130 _radius, _v[0], _v[1], _v[2], _v.norm()); 00131 } 00132 00133 // Function to determine if there is any portion of this that 00134 // is not inside one or more of the spheres in s[]. Returns 00135 // 1 if the intersection is empty, otherwise 0 is returned. 00136 // Warning: the spheres in s are modified. 00137 int intersect(CS2Sphere *s, 00138 int n_spheres) const; 00139 00140 static void print_counts(std::ostream& = ExEnv::out0()); 00141 }; 00142 00143 #define CONNOLLYSHAPE_N_WITH_NSPHERE_DIM 10 00144 00148 class ConnollyShape: public Shape { 00149 private: 00150 CS2Sphere* sphere; 00151 double probe_r; 00152 double radius_scale_factor_; 00153 int n_spheres; 00154 Ref<AtomInfo> atominfo_; 00155 00156 Arrayint ***box_; 00157 double l_; 00158 int xmax_; 00159 int ymax_; 00160 int zmax_; 00161 SCVector3 lower_; 00162 00163 int get_box(const SCVector3 &v, int &x, int &y, int &z) const; 00164 00165 #if COUNT_CONNOLLY 00166 static int n_total_; 00167 static int n_inside_vdw_; 00168 static int n_with_nsphere_[CONNOLLYSHAPE_N_WITH_NSPHERE_DIM]; 00169 #endif 00170 00171 public: 00172 ConnollyShape(const Ref<KeyVal>&); 00173 ~ConnollyShape(); 00174 void initialize(const Ref<Molecule>&,double probe_radius); 00175 void clear(); 00176 double distance_to_surface(const SCVector3&r, 00177 SCVector3*grad=0) const; 00178 void boundingbox(double valuemin, 00179 double valuemax, 00180 SCVector3& p1, SCVector3& p2); 00181 00182 static void print_counts(std::ostream& = ExEnv::out0()); 00183 }; 00184 00185 } 00186 00187 #endif 00188 00189 // Local Variables: 00190 // mode: c++ 00191 // c-file-style: "CLJ" 00192 // End: Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14. |