Bugfix in search_for_outside_edge routine.
[voro++.git] / trunk / src / wall.hh
blob59343af09e6cb50e25090bbb49e1b4ba9f05415e
1 // Voro++, a 3D cell-based Voronoi library
2 //
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
7 /** \file wall.hh
8 * \brief Header file for the derived wall classes. */
10 #ifndef VOROPP_WALL_HH
11 #define VOROPP_WALL_HH
13 #include "cell.hh"
14 #include "container.hh"
16 namespace voro {
18 /** \brief A class representing a spherical wall object.
20 * This class represents a spherical wall object. */
21 struct wall_sphere : public wall {
22 public:
23 /** Constructs a spherical wall object.
24 * \param[in] w_id_ an ID number to associate with the wall for
25 * neighbor tracking.
26 * \param[in] (xc_,yc_,zc_) a position vector for the sphere's
27 * center.
28 * \param[in] rc_ the radius of the sphere. */
29 wall_sphere(double xc_,double yc_,double zc_,double rc_,int w_id_=-99)
30 : w_id(w_id_), xc(xc_), yc(yc_), zc(zc_), rc(rc_) {}
31 bool point_inside(double x,double y,double z);
32 template<class v_cell>
33 bool cut_cell_base(v_cell &c,double x,double y,double z);
34 bool cut_cell(voronoicell &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
35 bool cut_cell(voronoicell_neighbor &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
36 private:
37 const int w_id;
38 const double xc,yc,zc,rc;
41 /** \brief A class representing a plane wall object.
43 * This class represents a single plane wall object. */
44 struct wall_plane : public wall {
45 public:
46 /** Constructs a plane wall object.
47 * \param[in] (xc_,yc_,zc_) a normal vector to the plane.
48 * \param[in] ac_ a displacement along the normal vector.
49 * \param[in] w_id_ an ID number to associate with the wall for
50 * neighbor tracking. */
51 wall_plane(double xc_,double yc_,double zc_,double ac_,int w_id_=-99)
52 : w_id(w_id_), xc(xc_), yc(yc_), zc(zc_), ac(ac_) {}
53 bool point_inside(double x,double y,double z);
54 template<class v_cell>
55 bool cut_cell_base(v_cell &c,double x,double y,double z);
56 bool cut_cell(voronoicell &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
57 bool cut_cell(voronoicell_neighbor &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
58 private:
59 const int w_id;
60 const double xc,yc,zc,ac;
63 /** \brief A class representing a cylindrical wall object.
65 * This class represents a open cylinder wall object. */
66 struct wall_cylinder : public wall {
67 public:
68 /** Constructs a cylinder wall object.
69 * \param[in] (xc_,yc_,zc_) a point on the axis of the
70 * cylinder.
71 * \param[in] (xa_,ya_,za_) a vector pointing along the
72 * direction of the cylinder.
73 * \param[in] rc_ the radius of the cylinder
74 * \param[in] w_id_ an ID number to associate with the wall for
75 * neighbor tracking. */
76 wall_cylinder(double xc_,double yc_,double zc_,double xa_,double ya_,double za_,double rc_,int w_id_=-99)
77 : w_id(w_id_), xc(xc_), yc(yc_), zc(zc_), xa(xa_), ya(ya_), za(za_),
78 asi(1/(xa_*xa_+ya_*ya_+za_*za_)), rc(rc_) {}
79 bool point_inside(double x,double y,double z);
80 template<class v_cell>
81 bool cut_cell_base(v_cell &c,double x,double y,double z);
82 bool cut_cell(voronoicell &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
83 bool cut_cell(voronoicell_neighbor &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
84 private:
85 const int w_id;
86 const double xc,yc,zc,xa,ya,za,asi,rc;
89 /** \brief A class representing a conical wall object.
91 * This class represents a cone wall object. */
92 struct wall_cone : public wall {
93 public:
94 /** Constructs a cone wall object.
95 * \param[in] (xc_,yc_,zc_) the apex of the cone.
96 * \param[in] (xa_,ya_,za_) a vector pointing along the axis of
97 * the cone.
98 * \param[in] ang the angle (in radians) of the cone, measured
99 * from the axis.
100 * \param[in] w_id_ an ID number to associate with the wall for
101 * neighbor tracking. */
102 wall_cone(double xc_,double yc_,double zc_,double xa_,double ya_,double za_,double ang,int w_id_=-99)
103 : w_id(w_id_), xc(xc_), yc(yc_), zc(zc_), xa(xa_), ya(ya_), za(za_),
104 asi(1/(xa_*xa_+ya_*ya_+za_*za_)),
105 gra(tan(ang)), sang(sin(ang)), cang(cos(ang)) {}
106 bool point_inside(double x,double y,double z);
107 template<class v_cell>
108 bool cut_cell_base(v_cell &c,double x,double y,double z);
109 bool cut_cell(voronoicell &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
110 bool cut_cell(voronoicell_neighbor &c,double x,double y,double z) {return cut_cell_base(c,x,y,z);}
111 private:
112 const int w_id;
113 const double xc,yc,zc,xa,ya,za,asi,gra,sang,cang;
118 #endif