00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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
00102
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
00109
00110 double common_radius(CS2Sphere &asphere);
00111
00112
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
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
00132
00133
00134
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
00186
00187
00188