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