00001
00002
00003
00004
00005
00006
00007 #ifndef VOROPP_CONTAINER_HH
00008 #define VOROPP_CONTAINER_HH
00009
00010 #include "config.hh"
00011 #include <cstdio>
00012 #include <iostream>
00013 #include <fstream>
00014 #include <cmath>
00015 using namespace std;
00016
00017 class facets_loop;
00018 class radius_poly;
00019 class wall;
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 template<class r_option>
00030 class container_base {
00031 public:
00032 container_base(fpoint xa,fpoint xb,fpoint ya,fpoint yb,fpoint za,fpoint zb,int xn,int yn,int zn,bool xper,bool yper,bool zper,int memi);
00033 ~container_base();
00034 void draw_particles(const char *filename);
00035 void draw_particles();
00036 void draw_particles(ostream &os);
00037 void draw_particles_pov(const char *filename);
00038 void draw_particles_pov();
00039 void draw_particles_pov(ostream &os);
00040 void import(istream &is);
00041 inline void import();
00042 inline void import(const char *filename);
00043 void region_count();
00044 void clear();
00045 void draw_cells_gnuplot(const char *filename,fpoint xmin,fpoint xmax,fpoint ymin,fpoint ymax,fpoint zmin,fpoint zmax);
00046 inline void draw_cells_gnuplot(const char *filename);
00047 void draw_cells_pov(const char *filename,fpoint xmin,fpoint xmax,fpoint ymin,fpoint ymax,fpoint zmin,fpoint zmax);
00048 inline void draw_cells_pov(const char *filename);
00049 void store_cell_volumes(fpoint *bb);
00050 fpoint packing_fraction(fpoint *bb,fpoint cx,fpoint cy,fpoint cz,fpoint r);
00051 fpoint packing_fraction(fpoint *bb,fpoint xmin,fpoint xmax,fpoint ymin,fpoint ymax,fpoint zmin,fpoint zmax);
00052 fpoint sum_cell_volumes();
00053 void compute_all_cells();
00054 void print_all(ostream &os);
00055 void print_all();
00056 void print_all(const char *filename);
00057 void print_all_neighbor(ostream &os);
00058 void print_all_neighbor();
00059 void print_all_neighbor(const char *filename);
00060 template<class n_option>
00061 inline bool compute_cell_sphere(voronoicell_base<n_option> &c,int i,int j,int k,int ijk,int s);
00062 template<class n_option>
00063 bool compute_cell_sphere(voronoicell_base<n_option> &c,int i,int j,int k,int ijk,int s,fpoint x,fpoint y,fpoint z);
00064 template<class n_option>
00065 inline bool compute_cell(voronoicell_base<n_option> &c,int i,int j,int k,int ijk,int s);
00066 template<class n_option>
00067 bool compute_cell(voronoicell_base<n_option> &c,int i,int j,int k,int ijk,int s,fpoint x,fpoint y,fpoint z);
00068 void put(int n,fpoint x,fpoint y,fpoint z);
00069 void put(int n,fpoint x,fpoint y,fpoint z,fpoint r);
00070 void add_wall(wall &w);
00071 bool point_inside(fpoint x,fpoint y,fpoint z);
00072 bool point_inside_walls(fpoint x,fpoint y,fpoint z);
00073 protected:
00074
00075 const fpoint ax;
00076
00077 const fpoint bx;
00078
00079 const fpoint ay;
00080
00081 const fpoint by;
00082
00083 const fpoint az;
00084
00085 const fpoint bz;
00086
00087
00088 const fpoint xsp;
00089
00090
00091 const fpoint ysp;
00092
00093
00094 const fpoint zsp;
00095
00096 const int nx;
00097
00098 const int ny;
00099
00100 const int nz;
00101
00102
00103
00104 const int nxy;
00105
00106
00107 const int nxyz;
00108
00109 const int hx;
00110
00111 const int hy;
00112
00113 const int hz;
00114
00115
00116
00117 const int hxy;
00118
00119
00120 const int hxyz;
00121
00122
00123 const bool xperiodic;
00124
00125
00126 const bool yperiodic;
00127
00128
00129 const bool zperiodic;
00130
00131
00132 int *co;
00133
00134
00135
00136
00137
00138 int *mem;
00139
00140
00141 int **id;
00142
00143 unsigned int *mask;
00144
00145
00146 int *sl;
00147
00148
00149 unsigned int mv;
00150
00151
00152 int s_start;
00153
00154
00155 int s_end;
00156
00157 int s_size;
00158
00159
00160
00161 fpoint **p;
00162
00163
00164 wall **walls;
00165
00166 int wall_number;
00167
00168 int current_wall_size;
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 r_option radius;
00179
00180
00181
00182
00183
00184
00185 int sz;
00186
00187
00188
00189 fpoint *mrad;
00190
00191 template<class n_option>
00192 inline void print_all(ostream &os,voronoicell_base<n_option> &c);
00193 template<class n_option>
00194 inline bool initialize_voronoicell(voronoicell_base<n_option> &c,fpoint x,fpoint y,fpoint z);
00195 void add_particle_memory(int i);
00196 void add_list_memory();
00197 private:
00198 #include "worklist.hh"
00199 template<class n_option>
00200 inline bool corner_test(voronoicell_base<n_option> &c,fpoint xl,fpoint yl,fpoint zl,fpoint xh,fpoint yh,fpoint zh);
00201 template<class n_option>
00202 inline bool edge_x_test(voronoicell_base<n_option> &c,fpoint x0,fpoint yl,fpoint zl,fpoint x1,fpoint yh,fpoint zh);
00203 template<class n_option>
00204 inline bool edge_y_test(voronoicell_base<n_option> &c,fpoint xl,fpoint y0,fpoint zl,fpoint xh,fpoint y1,fpoint zh);
00205 template<class n_option>
00206 inline bool edge_z_test(voronoicell_base<n_option> &c,fpoint xl,fpoint yl,fpoint z0,fpoint xh,fpoint yh,fpoint z1);
00207 template<class n_option>
00208 inline bool face_x_test(voronoicell_base<n_option> &c,fpoint xl,fpoint y0,fpoint z0,fpoint y1,fpoint z1);
00209 template<class n_option>
00210 inline bool face_y_test(voronoicell_base<n_option> &c,fpoint x0,fpoint yl,fpoint z0,fpoint x1,fpoint z1);
00211 template<class n_option>
00212 inline bool face_z_test(voronoicell_base<n_option> &c,fpoint x0,fpoint y0,fpoint zl,fpoint x1,fpoint y1);
00213 inline void initialize_radii();
00214 inline void compute_minimum(fpoint &minr,fpoint &xlo,fpoint &xhi,fpoint &ylo,fpoint &yhi,fpoint &zlo,fpoint &zhi,int ti,int tj,int tk);
00215 inline bool compute_min_max_radius(int di,int dj,int dk,fpoint fx,fpoint fy,fpoint fz,fpoint gx,fpoint gy,fpoint gz,fpoint& crs,fpoint mrs);
00216 friend class facets_loop;
00217 friend class radius_poly;
00218 };
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 class radius_mono {
00229 public:
00230
00231
00232
00233 const int mem_size;
00234
00235
00236
00237 radius_mono(container_base<radius_mono> *icc) : mem_size(3), cc(icc) {};
00238 inline void import(istream &is);
00239
00240 inline void store_radius(int i,int j,fpoint r) {};
00241
00242 inline void clear_max() {};
00243
00244 inline void init(int s,int i) {};
00245 inline fpoint volume(int ijk,int s);
00246 inline fpoint cutoff(fpoint lrs);
00247 inline fpoint scale(fpoint rs,int t,int q);
00248
00249 inline void print(ostream &os,int ijk,int q) {};
00250 inline void rad(ostream &os,int l,int c);
00251 private:
00252 container_base<radius_mono> *cc;
00253 };
00254
00255
00256
00257
00258
00259
00260
00261
00262 class radius_poly {
00263 public:
00264
00265
00266
00267 const int mem_size;
00268
00269
00270
00271 radius_poly(container_base<radius_poly> *icc) : mem_size(4), cc(icc) {};
00272 inline void import(istream &is);
00273 inline void store_radius(int i,int j,fpoint r);
00274 inline void clear_max();
00275 inline void init(int ijk,int s);
00276 inline fpoint volume(int ijk,int s);
00277 inline fpoint cutoff(fpoint lrs);
00278 inline fpoint scale(fpoint rs,int t,int q);
00279 inline void print(ostream &os,int ijk,int q);
00280 inline void rad(ostream &os,int l,int c);
00281 private:
00282 container_base<radius_poly> *cc;
00283 fpoint max_radius,crad,mul;
00284 };
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 class facets_loop {
00297 public:
00298 template<class r_option>
00299 facets_loop(container_base<r_option> *q);
00300 inline int init(fpoint vx,fpoint vy,fpoint vz,fpoint r,fpoint &px,fpoint &py,fpoint &pz);
00301 inline int init(fpoint xmin,fpoint xmax,fpoint ymin,fpoint ymax,fpoint zmin,fpoint zmax,fpoint &px,fpoint &py,fpoint &pz);
00302 inline int inc(fpoint &px,fpoint &py,fpoint &pz);
00303
00304
00305 int ip;
00306
00307
00308 int jp;
00309
00310
00311 int kp;
00312 private:
00313 int i,j,k,ai,bi,aj,bj,ak,bk,s;
00314 int aip,ajp,akp,inc1,inc2;
00315 inline int step_mod(int a,int b);
00316 inline int step_div(int a,int b);
00317 inline int step_int(fpoint a);
00318 fpoint apx,apy,apz;
00319 const fpoint sx,sy,sz,xsp,ysp,zsp,ax,ay,az;
00320 const int nx,ny,nz,nxy,nxyz;
00321 const bool xperiodic,yperiodic,zperiodic;
00322 };
00323
00324
00325
00326
00327
00328
00329 class wall {
00330 public:
00331 virtual ~wall() {};
00332
00333
00334 virtual bool point_inside(fpoint x,fpoint y,fpoint z) = 0;
00335
00336
00337 virtual bool cut_cell(voronoicell_base<neighbor_none> &c,fpoint x,fpoint y,fpoint z) = 0;
00338
00339
00340 virtual bool cut_cell(voronoicell_base<neighbor_track> &c,fpoint x,fpoint y,fpoint z) = 0;
00341 };
00342
00343
00344 typedef container_base<radius_mono> container;
00345
00346
00347 typedef container_base<radius_poly> container_poly;
00348 #endif