Changeset 178 for cpp/frams/genetics
 Timestamp:
 03/17/14 00:57:50 (9 years ago)
 Location:
 cpp/frams/genetics/fF
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

cpp/frams/genetics/fF/conv_fF.cpp
r177 r178 16 16 cosines = new double[fF_LATITUDE_NUM]; 17 17 sines = new double[fF_LATITUDE_NUM]; 18 fill_cos_and_sin();18 precompute_cos_and_sin(); 19 19 } 20 20 … … 159 159 pun = find_hole(which, pzx, pzy, pzz, chambers, kx_, ky_, kz_); 160 160 161 chambers[which]>holeX = (float)chambers[which]>points[pun] [0];162 chambers[which]>holeY = (float)chambers[which]>points[pun] [1];163 chambers[which]>holeZ = (float)chambers[which]>points[pun] [2];164 } 165 } 166 167 void GenoConv_fF0:: fill_cos_and_sin()161 chambers[which]>holeX = (float)chambers[which]>points[pun].x; 162 chambers[which]>holeY = (float)chambers[which]>points[pun].y; 163 chambers[which]>holeZ = (float)chambers[which]>points[pun].z; 164 } 165 } 166 167 void GenoConv_fF0::precompute_cos_and_sin() 168 168 { 169 169 int i; … … 177 177 } 178 178 179 double** GenoConv_fF0::generate_points(fF_chamber3d *chamber, int which, double kx_, double ky_, double kz_)179 fF_point* GenoConv_fF0::generate_points(fF_chamber3d *chamber, int which, double kx_, double ky_, double kz_) 180 180 { 181 181 float radius = chamber>radius; … … 210 210 double rz = all_k_ones ? radius : kz; 211 211 212 double **points = new double*[fF_SIZE]; 213 for (int i = 0; i < fF_SIZE; i++) 214 { 215 points[i] = new double[4]; 216 } 212 fF_point *points = new fF_point[fF_SIZE]; 217 213 218 214 for (int i = 0; i < fF_LONGITUDE_NUM; i++) … … 224 220 double x = cenx + rx * cosines[j] * sines[i]; 225 221 double z = cenz + rz * sines[j] * sines[i]; 226 double *p = points[(i * fF_LATITUDE_NUM) + j];227 p [0]= x;228 p [1]= y;229 p [2]= z;230 p [3] = 1.0;222 fF_point &p = points[(i * fF_LATITUDE_NUM) + j]; 223 p.x = x; 224 p.y = y; 225 p.z = z; 226 p.inside = false; 231 227 232 228 if (x < minX) minX = x; … … 267 263 for (int j = 0; j < fF_AMOUNT; j++) 268 264 { 269 double *p = spheres[nr]>points[j]; 270 double X = p[0]; 271 double Y = p[1]; 272 double Z = p[2]; 273 274 double up1 = (X  srX0) * (X  srX0); 275 double up2 = (Y  srY0) * (Y  srY0); 276 double up3 = (Z  srZ0) * (Z  srZ0); 265 fF_point &p = spheres[nr]>points[j]; 266 267 double up1 = (p.x  srX0) * (p.x  srX0); 268 double up2 = (p.y  srY0) * (p.y  srY0); 269 double up3 = (p.z  srZ0) * (p.z  srZ0); 277 270 278 271 double exp1 = up1 / a2; … … 284 277 if (result < fF_THICK_RATIO) 285 278 { 286 p [3] = 0.0;279 p.inside = true; 287 280 } 288 281 } … … 301 294 for (int i = 0; i < fF_AMOUNT; i++) 302 295 { 303 double *p = chambers[which]>points[i];304 if ( p[3] != 0) //it is not inside another chamber305 { 306 double distancesq = (p [0]  x)*(p[0]  x) + (p[1]  y)*(p[1]  y) + (p[2]  z)*(p[2] z);296 fF_point &p = chambers[which]>points[i]; 297 if (!p.inside) //it is not inside another chamber 298 { 299 double distancesq = (p.x  x)*(p.x  x) + (p.y  y)*(p.y  y) + (p.z  z)*(p.z  z); 307 300 if (found < 0) 308 301 { … … 314 307 if (which != 0) 315 308 { 316 double X = p[0];317 double Y = p[1];318 double Z = p[2];319 309 bool good = true; 320 310 for (int j = 0; j < which && good; j++) … … 330 320 double c2 = kzsq * radsq; 331 321 332 double up1 = ( X  srX0) * (X srX0);333 double up2 = ( Y  srY0) * (Y srY0);334 double up3 = ( Z  srZ0) * (Z srZ0);322 double up1 = (p.x  srX0) * (p.x  srX0); 323 double up2 = (p.y  srY0) * (p.y  srY0); 324 double up3 = (p.z  srZ0) * (p.z  srZ0); 335 325 336 326 double exp1 = up1 / a2; 
cpp/frams/genetics/fF/conv_fF.h
r176 r178 24 24 #include "fF_chamber3d.h" 25 25 26 27 //A point on the surface of a chamber 28 struct fF_point 29 { 30 double x, y, z; 31 bool inside; //helper field used when computing whether this point is inside some chamber 32 }; 33 34 26 35 // The f9>f0 converter 27 36 class GenoConv_fF0 : public GenoConverter { … … 33 42 34 43 protected: 35 double* cosines;36 double* sines;37 44 void createSphere(int ktora, fF_chamber3d **chambers, double radius, double div_radius_length, double div_vector_length, 38 45 double alpha, double gamma, double kx, double ky, double kz); 39 double** generate_points(fF_chamber3d *chamber, int which, double kx, double ky, double kz); 40 void fill_cos_and_sin(); 46 fF_point* generate_points(fF_chamber3d *chamber, int which, double kx, double ky, double kz); 41 47 double dist(double x1, double y1, double z1, double x2, double y2, double z2); 42 48 void search_hid(int nr, fF_chamber3d **spheres, double kx_, double ky_, double kz_); 43 49 int find_hole(int which, double x, double y, double z, fF_chamber3d **chambers, double kx_, double ky_, double kz_); 50 51 private: 52 double* cosines; 53 double* sines; 54 void precompute_cos_and_sin(); 44 55 }; 45 56 
cpp/frams/genetics/fF/fF_chamber3d.cpp
r176 r178 9 9 fF_chamber3d::~fF_chamber3d() 10 10 { 11 for (int i = 0; i < fF_SIZE; i++)12 delete[] points[i];13 11 delete[] points; 14 12 } 
cpp/frams/genetics/fF/fF_chamber3d.h
r176 r178 5 5 #ifndef CHAMBER3D_H 6 6 #define CHAMBER3D_H 7 8 struct fF_point; 7 9 8 10 //Chamber parameters; see http://www.framsticks.com/foraminifera … … 22 24 float beta; 23 25 float phi; 24 double **points;26 fF_point *points; 25 27 26 28 ~fF_chamber3d();
Note: See TracChangeset
for help on using the changeset viewer.