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
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
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
00104
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
00111
00112 double common_radius(CS2Sphere &asphere);
00113
00114
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
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
00134
00135
00136
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 std::vector<int> ***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
00190
00191
00192