MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
shape.h
1//
2// shape.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 _math_isosurf_shape_h
29#define _math_isosurf_shape_h
30
31#include <set>
32
33#include <math/isosurf/volume.h>
34#include <math/scmat/matrix.h>
35#include <math/scmat/vector3.h>
36
37namespace sc {
38
44class Shape: public Volume {
45 public:
46 Shape();
47 Shape(const Ref<KeyVal>&keyval);
48 virtual double distance_to_surface(const SCVector3&r,
49 SCVector3*grad=0) const = 0;
50 virtual int is_outside(const SCVector3&r) const;
51 virtual ~Shape();
52 void compute();
53 void interpolate(const SCVector3& p1,
54 const SCVector3& p2,
55 double val,
56 SCVector3& result);
57
58 int value_implemented() const;
59};
60
61
62
63class SphereShape: public Shape {
64 private:
65 SCVector3 _origin;
66 double _radius;
67 public:
68 SphereShape(const SCVector3&,double);
72 void boundingbox(double minvalue, double maxvalue,
73 SCVector3& p1, SCVector3&p2);
74 double radius() const { return _radius; }
75 const SCVector3& origin() const { return _origin; }
76 double distance_to_surface(const SCVector3&r,SCVector3*grad=0) const;
77 void print(std::ostream&o=ExEnv::out0()) const;
78
79 // these are used to update the parameters describing the sphere
80 double radius(double r);
81 const SCVector3& origin(const SCVector3& o);
82
84};
85
86inline double
87SphereShape::radius(double r)
88{
89 obsolete();
90 return _radius = r;
91}
92
93inline const SCVector3&
94SphereShape::origin(const SCVector3& o)
95{
96 obsolete();
97 _origin = o;
98 return _origin;
99}
100
102{
103 private:
104 SphereShape _s1;
105 SphereShape _s2;
106 double _r;
107 protected:
108 void in_plane_sphere(const SCVector3& point,
109 SCVector3& origin) const;
110 UncappedTorusHoleShape(double r,const SphereShape&,const SphereShape&);
111 public:
113 newUncappedTorusHoleShape(double r,
114 const SphereShape&,
115 const SphereShape&);
116 inline ~UncappedTorusHoleShape() {};
117 inline const SphereShape& sphere(int i) const { return (i?_s2:_s1); };
118 inline const SCVector3 A() const { SCVector3 v(_s1.origin()); return v; }
119 inline const SCVector3 B() const { SCVector3 v(_s2.origin()); return v; }
120 inline double radius() const { return _r; };
121 void print(std::ostream&o=ExEnv::out0()) const;
122 void boundingbox(double valuemin, double valuemax,
123 SCVector3& p1, SCVector3&p2);
124
126};
127
129{
130 private:
131 double rAP;
132 double rBP;
133 SCVector3 BA;
134 public:
136 const SphereShape&,
137 const SphereShape&);
139 double distance_to_surface(const SCVector3&r,SCVector3*grad=0) const;
140
142};
143
145{
146 private:
147 double rAP;
148 double rBP;
149 SCVector3 BA;
150 SCVector3 I[2]; // the intersect points
151 public:
153 const SphereShape&,
154 const SphereShape&);
156 int is_outside(const SCVector3&r) const;
157 double distance_to_surface(const SCVector3&r,SCVector3*grad=0) const;
158
160};
161
163{
164 private:
165 int _solution_exists;
166 int _reentrant;
167 int _folded;
168 SphereShape _s1;
169 SphereShape _s2;
170 SphereShape _s3;
171 SCVector3 D[2];
172 double BDxCDdotAD[2];
173 SCVector3 BDxCD[2];
174 double CDxADdotBD[2];
175 SCVector3 CDxAD[2];
176 double ADxBDdotCD[2];
177 SCVector3 ADxBD[2];
178 double _r;
179
180 // these are needed for folded shapes
181 // F1 and F2 are the two points of A, B, and C that are closed to M
182 SCVector3 F1;
183 SCVector3 F2;
184
185 // these are needed for reentrant surfaces to compute distances
186 SCVector3 M; // projection of D onto ABC plane
187 SCVector3 MD[2]; // M - D
188 double theta_intersect; // angle M - D - intersect_point
189 double r_intersect; // the radius of the intersect circle
190 int _intersects_AB;
191 SCVector3 IABD[2][2];
192 int _intersects_BC;
193 SCVector3 IBCD[2][2];
194 int _intersects_CA;
195 SCVector3 ICAD[2][2];
196
197 protected:
199 const SphereShape&,
200 const SphereShape&,
201 const SphereShape&);
202 public:
204 newUncapped5SphereExclusionShape(double r,
205 const SphereShape&,
206 const SphereShape&,
207 const SphereShape&);
209 inline const SCVector3 A() const { SCVector3 v(_s1.origin()); return v; }
210 inline const SCVector3 B() const { SCVector3 v(_s2.origin()); return v; }
211 inline const SCVector3 C() const { SCVector3 v(_s3.origin()); return v; }
212 inline double rA() const { return _s1.radius(); };
213 inline double rB() const { return _s2.radius(); };
214 inline double rC() const { return _s3.radius(); };
215 inline double r() const { return _r; };
216 inline int solution_exists() const { return _solution_exists; };
217 double distance_to_surface(const SCVector3&r,SCVector3*grad=0) const;
218 int is_outside(const SCVector3&) const;
219 void boundingbox(double valuemin, double valuemax,
220 SCVector3& p1, SCVector3&p2);
221
223};
224
226class UnionShape: public Shape {
227 protected:
228 std::set<Ref<Shape> > _shapes;
229 public:
230 void add_shape(Ref<Shape>);
231 UnionShape();
232 ~UnionShape();
233 double distance_to_surface(const SCVector3&r,SCVector3*grad=0) const;
234 int is_outside(const SCVector3&r) const;
235 void boundingbox(double valuemin, double valuemax,
236 SCVector3& p1, SCVector3& p2);
237
239};
240
241}
242
243#endif
244
245// Local Variables:
246// mode: c++
247// c-file-style: "CLJ"
248// End:
virtual void obsolete()
Marks all results as being out of date.
static std::ostream & out0()
Return an ostream that writes from node 0.
A template class that maintains references counts.
Definition ref.h:361
a 3-element version of SCVector
Definition vector3.h:44
A Shape is a Volume represents an 3D solid.
Definition shape.h:44
int value_implemented() const
void compute()
Recompute at least the results that have compute true and are not already computed.
Definition shape.h:63
void print(std::ostream &o=ExEnv::out0()) const
Print information about the object.
int gradient_implemented() const
Definition shape.h:163
Definition shape.h:102
void print(std::ostream &o=ExEnv::out0()) const
Print information about the object.
int gradient_implemented() const
A UnionShape is volume enclosed by a set of Shape's.
Definition shape.h:226
int gradient_implemented() const
A Volume is a Function of three variables.
Definition volume.h:38
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.