MPQC  2.3.1
molshape.h
1 //
2 // molshape.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _chemistry_molecule_molshape_h
29 #define _chemistry_molecule_molshape_h
30 
31 #ifdef __GNUC__
32 #pragma interface
33 #endif
34 
35 #include <util/misc/formio.h>
36 
37 #include <math/isosurf/shape.h>
38 #include <chemistry/molecule/atominfo.h>
39 #include <chemistry/molecule/molecule.h>
40 
41 namespace sc {
42 
47 class VDWShape: public UnionShape {
48  private:
49  Ref<AtomInfo> atominfo_;
50  public:
51  VDWShape(const Ref<Molecule>&);
52  VDWShape(const Ref<KeyVal>&);
53  ~VDWShape();
54  void initialize(const Ref<Molecule>&);
55 };
56 
62  private:
63  double radius_scale_factor_;
64  Ref<AtomInfo> atominfo_;
65  public:
68  void initialize(const Ref<Molecule>&,double probe_radius);
69 };
70 
71 #ifndef COUNT_CONNOLLY
72 # define COUNT_CONNOLLY 1
73 #endif
74 
75 // This is a utility class needed by ConnollyShape2
76 class CS2Sphere
77 {
78  SCVector3 _v;
79  double _radius;
80 
81  public:
82 #if COUNT_CONNOLLY
83  static int n_no_spheres_;
84  static int n_probe_enclosed_by_a_sphere_;
85  static int n_probe_center_not_enclosed_;
86  static int n_surface_of_s0_not_covered_;
87  static int n_plane_totally_covered_;
88  static int n_internal_edge_not_covered_;
89  static int n_totally_covered_;
90 #endif
91 
92  CS2Sphere(const SCVector3& v, double rad):
93  _v(v),_radius(rad){}
94  CS2Sphere(double x, double y, double z, double rad):
95  _v(x,y,z),_radius(rad){}
96  CS2Sphere(void) {};
97  void initialize(SCVector3& v, double rad) {
98  _v = v; _radius = rad; }
99 
100  CS2Sphere& operator=(const CS2Sphere&s) {
101  _v = s._v; _radius = s._radius; return *this; }
102 
103  // Return the distance between the centers of the two
104  // spheres
105  double distance(CS2Sphere &asphere)
106  { return sqrt((_v[0]-asphere._v[0])*(_v[0]-asphere._v[0])+
107  (_v[1]-asphere._v[1])*(_v[1]-asphere._v[1])+
108  (_v[2]-asphere._v[2])*(_v[2]-asphere._v[2]));}
109 
110  // Return the radius of the circle intersecting the two spheres
111  // Note that this assumes the spheres do overlap!
112  double common_radius(CS2Sphere &asphere);
113 
114  // Return the center
115  const SCVector3& center(void) const { return _v; }
116  double x() const { return _v[0]; }
117  double y() const { return _v[1]; }
118  double z() const { return _v[2]; }
119 
120  // Return the vector3d connecting the two centers
121  SCVector3 center_vec(const CS2Sphere &asphere) { return _v - asphere._v; }
122 
123  double radius(void) const {return _radius;}
124 
125  void recenter(const SCVector3 &v) { _v -= v; }
126  void print(std::ostream& os=ExEnv::out0()) const
127  {
128  os << indent
129  << scprintf("Rad=%lf, Center=(%lf,%lf,%lf), From origin=%lf\n",
130  _radius, _v[0], _v[1], _v[2], _v.norm());
131  }
132 
133  // Function to determine if there is any portion of this that
134  // is not inside one or more of the spheres in s[]. Returns
135  // 1 if the intersection is empty, otherwise 0 is returned.
136  // Warning: the spheres in s are modified.
137  int intersect(CS2Sphere *s,
138  int n_spheres) const;
139 
140  static void print_counts(std::ostream& = ExEnv::out0());
141 };
142 
143 #define CONNOLLYSHAPE_N_WITH_NSPHERE_DIM 10
144 
148 class ConnollyShape: public Shape {
149  private:
150  CS2Sphere* sphere;
151  double probe_r;
152  double radius_scale_factor_;
153  int n_spheres;
154  Ref<AtomInfo> atominfo_;
155 
156  std::vector<int> ***box_;
157  double l_;
158  int xmax_;
159  int ymax_;
160  int zmax_;
161  SCVector3 lower_;
162 
163  int get_box(const SCVector3 &v, int &x, int &y, int &z) const;
164 
165 #if COUNT_CONNOLLY
166  static int n_total_;
167  static int n_inside_vdw_;
168  static int n_with_nsphere_[CONNOLLYSHAPE_N_WITH_NSPHERE_DIM];
169 #endif
170 
171  public:
172  ConnollyShape(const Ref<KeyVal>&);
173  ~ConnollyShape();
174  void initialize(const Ref<Molecule>&,double probe_radius);
175  void clear();
176  double distance_to_surface(const SCVector3&r,
177  SCVector3*grad=0) const;
178  void boundingbox(double valuemin,
179  double valuemax,
180  SCVector3& p1, SCVector3& p2);
181 
182  static void print_counts(std::ostream& = ExEnv::out0());
183 };
184 
185 }
186 
187 #endif
188 
189 // Local Variables:
190 // mode: c++
191 // c-file-style: "CLJ"
192 // End:
sc::Shape
A Shape is a Volume represents an 3D solid.
Definition: shape.h:48
sc::ConnollyShape
DiscreteConnollyShape and ConnollyShape should produce the same result.
Definition: molshape.h:148
sc::DiscreteConnollyShape
DiscreteConnollyShape and ConnollyShape should produce the same result.
Definition: molshape.h:61
sc::Ref
A template class that maintains references counts.
Definition: ref.h:332
sc::UnionShape
A UnionShape is volume enclosed by a set of Shape's.
Definition: shape.h:230
sc::SCVector3
Definition: vector3.h:45
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::VDWShape
The VDWShape class describes the surface of a molecule as the union of atom centered spheres,...
Definition: molshape.h:47
sc::CS2Sphere
Definition: molshape.h:76
sc::scprintf
This class allows printf like output to put sent to an ostream.
Definition: formio.h:96

Generated at Sun Jan 26 2020 23:33:04 for MPQC 2.3.1 using the documentation package Doxygen 1.8.16.