Changeset 6dd8d3 for molecuilder/src/linkedcell.cpp
- Timestamp:
- Apr 9, 2010, 9:55:39 AM (16 years ago)
- Children:
- bd8561
- Parents:
- 6250e5
- File:
-
- 1 edited
-
molecuilder/src/linkedcell.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/linkedcell.cpp
r6250e5 r6dd8d3 220 220 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds. 221 221 */ 222 const Linked Nodes* LinkedCell::GetCurrentCell() const222 const LinkedCell::LinkedNodes* LinkedCell::GetCurrentCell() const 223 223 { 224 224 if (CheckBounds()) { … … 234 234 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds. 235 235 */ 236 const Linked Nodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const236 const LinkedCell::LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const 237 237 { 238 238 if (CheckBounds(relative)) { … … 302 302 }; 303 303 304 /** Returns a list with all neighbours from the current LinkedCell::index. 305 * \param distance (if no distance, then adjacent cells are taken) 306 * \return list of tesselpoints 307 */ 308 LinkedCell::LinkedNodes* LinkedCell::GetallNeighbours(const double distance = 0) const 309 { 310 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; 311 TesselPoint *Walker = NULL; 312 LinkedNodes *TesselList = new LinkedNodes; 313 314 // then go through the current and all neighbouring cells and check the contained points for possible candidates 315 //Log() << Verbose(1) << "LC Intervals:"; 316 const int step = (distance == 0) ? 1 : (int)floor(distance/RADIUS)+1; 317 for (int i=0;i<NDIM;i++) { 318 Nlower[i] = ((N[i]-step) >= 0) ? N[i]-step : 0; 319 Nupper[i] = ((N[i]+step) < N[i]) ? N[i]+step : N[i]-step; 320 //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "; 321 } 322 //Log() << Verbose(0) << endl; 323 for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++) 324 for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++) 325 for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) { 326 const LinkedNodes *List = GetCurrentCell(); 327 //Log() << Verbose(1) << "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl; 328 if (List != NULL) { 329 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 330 Walker = *Runner; 331 TesselList->push_back(Walker); 332 } 333 } 334 } 335 return TesselList; 336 }; 337 338 339 /** Returns a list of all TesselPoint with distance less than \a radius to \a *Center. 340 * \param radius radius of sphere 341 * \param *center center of sphere 342 * \return list of all points inside sphere 343 */ 344 LinkedCell::LinkedNodes* LinkedCell::GetPointsInsideSphere(const double radius, const Vector * const center) const 345 { 346 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; 347 const double radiusSquared = radius*radius; 348 TesselPoint *Walker = NULL; 349 LinkedNodes *TesselList = new LinkedNodes; 350 351 if (SetIndexToVector(center)) { 352 for(int i=0;i<NDIM;i++) // store indices of this cell 353 N[i] = n[i]; 354 //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << index << "." << endl; 355 } else { 356 DoeLog(1) && (eLog()<< Verbose(1) << "Vector " << *center << " is outside of LinkedCell's bounding box." << endl); 357 return TesselList; 358 } 359 // then go through the current and all neighbouring cells and check the contained points for possible candidates 360 //Log() << Verbose(1) << "LC Intervals:"; 361 for (int i=0;i<NDIM;i++) { 362 Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0; 363 Nupper[i] = ((N[i]+1) < N[i]) ? N[i]+1 : N[i]-1; 364 //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "; 365 } 366 //Log() << Verbose(0) << endl; 367 for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++) 368 for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++) 369 for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) { 370 const LinkedNodes *List = GetCurrentCell(); 371 //Log() << Verbose(1) << "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl; 372 if (List != NULL) { 373 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 374 Walker = *Runner; 375 if ((center->DistanceSquared(Walker->node) - radiusSquared) > MYEPSILON) { 376 TesselList->push_back(Walker); 377 } 378 } 379 } 380 } 381 return TesselList; 382 };
Note:
See TracChangeset
for help on using the changeset viewer.
