1 // Voro++, a 3D cell-based Voronoi library
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
8 * \brief Header file for the 2D voro_compute template and related classes. */
10 #ifndef VOROPP_V_COMPUTE_2D_HH
11 #define VOROPP_V_COMPUTE_2D_HH
20 #include "worklist_2d.hh"
22 #include "cell_nc_2d.hh"
26 /** \brief Structure for holding information about a particle.
28 * This small structure holds information about a single particle, and is used
29 * by several of the routines in the voro_compute template for passing
30 * information by reference between functions. */
31 struct particle_record_2d
{
32 /** The index of the block that the particle is within. */
34 /** The number of particle within its block. */
36 /** The x-index of the block. */
38 /** The y-index of the block. */
42 /** \brief Template for carrying out Voronoi cell computations. */
43 template <class c_class_2d
>
44 class voro_compute_2d
{
46 /** A reference to the container class on which to carry out*/
48 /** The size of an internal computational block in the x
51 /** The size of an internal computational block in the y
54 /** The inverse box length in the x direction, set to
57 /** The inverse box length in the y direction, set to
60 /** The number of boxes in the x direction for the searching mask. */
62 /** The number of boxes in the y direction for the searching mask. */
64 /** A constant, set to the value of hx multiplied by hy, which
65 * is used in the routines which step through mask boxes in
68 /** The number of floating point entries to store for each
71 /** This array holds the numerical IDs of each particle in each
72 * computational box. */
74 /** A two dimensional array holding particle positions. For the
75 * derived container_poly class, this also holds particle
78 /** An array holding the number of particles within each
79 * computational box of the container. */
81 voro_compute_2d(c_class_2d
&con_
,int hx_
,int hy_
);
82 /** The class destructor frees the dynamically allocated memory
83 * for the mask and queue. */
88 template<class v_cell_2d
>
89 bool compute_cell(v_cell_2d
&c
,int ij
,int s
,int ci
,int cj
);
90 void find_voronoi_cell(double x
,double y
,int ci
,int cj
,int ij
,particle_record_2d
&w
,double &mrs
);
92 /** A constant set to boxx*boxx+boxy*boxy+boxz*boxz, which is
93 * frequently used in the computation. */
95 /** This sets the current value being used to mark tested blocks
98 /** The current size of the search list. */
100 /** A pointer to the array of worklists. */
101 const unsigned int *wl
;
102 /** An pointer to the array holding the minimum distances
103 * associated with the worklists. */
105 /** This array is used during the cell computation to determine
106 * which blocks have been considered. */
108 /** An array is used to store the queue of blocks to test
109 * during the Voronoi cell computation. */
111 /** A pointer to the end of the queue array, used to determine
112 * when the queue is full. */
114 template<class v_cell_2d
>
115 inline bool corner_test(v_cell_2d
&c
,double xl
,double yl
,double xh
,double yh
);
116 template<class v_cell_2d
>
117 inline bool edge_x_test(v_cell_2d
&c
,double xl
,double y0
,double y1
);
118 template<class v_cell_2d
>
119 inline bool edge_y_test(v_cell_2d
&c
,double x0
,double yl
,double x1
);
120 bool compute_min_max_radius(int di
,int dj
,double fx
,double fy
,double gx
,double gy
,double& crs
,double mrs
);
121 bool compute_min_radius(int di
,int dj
,double fx
,double fy
,double mrs
);
122 inline void add_to_mask(int ei
,int ej
,int *&qu_e
);
123 inline void scan_bits_mask_add(unsigned int q
,unsigned int *mij
,int ei
,int ej
,int *&qu_e
);
124 inline void scan_all(int ij
,double x
,double y
,int di
,int dj
,particle_record_2d
&w
,double &mrs
);
125 void add_list_memory(int*& qu_s
,int*& qu_e
);
126 /** Resets the mask in cases where the mask counter wraps
128 inline void reset_mask() {
129 for(unsigned int *mp
=mask
;mp
<mask
+hxy
;mp
++) *mp
=0;