Changeset a8c8ba for molecuilder/src
- Timestamp:
- Jul 9, 2009, 1:33:39 PM (16 years ago)
- Children:
- 6fb785, b65771
- Parents:
- 8bbe43
- File:
-
- 1 edited
-
molecuilder/src/boundary.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/boundary.cpp
r8bbe43 ra8c8ba 2248 2248 } 2249 2249 // then go through the current and all neighbouring cells and check the contained atoms for possible candidates 2250 cout << Verbose( 2) << "LC Intervals from [";2250 cout << Verbose(3) << "LC Intervals from ["; 2251 2251 for (int i=0;i<NDIM;i++) { 2252 2252 cout << " " << N[i] << "<->" << LC->N[i]; … … 2296 2296 angle = AngleCheck.Angle(&Oben); 2297 2297 if (angle < Storage[0]) { 2298 //cout << Verbose( 1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);2299 cout << Verbose( 2) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";2298 //cout << Verbose(3) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 2299 cout << Verbose(3) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n"; 2300 2300 Opt_Candidate = Candidate; 2301 2301 Storage[0] = angle; 2302 //cout << Verbose( 1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]);2302 //cout << Verbose(3) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]); 2303 2303 } else { 2304 //cout << Verbose( 2) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *Opt_Candidate << endl;2304 //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *Opt_Candidate << endl; 2305 2305 } 2306 2306 } else { 2307 //cout << Verbose( 2) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl;2307 //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl; 2308 2308 } 2309 2309 } else { 2310 //cout << Verbose( 2) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl;2310 //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl; 2311 2311 } 2312 2312 } 2313 2313 } else { 2314 cout << "Linked cell list is empty." << endl;2314 cout << Verbose(3) << "Linked cell list is empty." << endl; 2315 2315 } 2316 2316 } … … 2371 2371 cout << i << ": " << *MaxAtom[i] << "\t"; 2372 2372 cout << endl; 2373 const int k = 1; // arbitrary choice 2374 Oben.x[k] = 1.; 2375 FirstPoint = MaxAtom[k]; 2376 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << "." << endl; 2377 2378 double ShortestAngle; 2379 atom* Opt_Candidate = NULL; 2380 ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant. 2381 2382 Find_second_point_for_Tesselation(FirstPoint, NULL, Oben, Opt_Candidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_... 2383 SecondPoint = Opt_Candidate; 2384 cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n"; 2385 2386 helper.CopyVector(&(FirstPoint->x)); 2387 helper.SubtractVector(&(SecondPoint->x)); 2388 helper.Normalize(); 2389 Oben.ProjectOntoPlane(&helper); 2390 Oben.Normalize(); 2391 helper.VectorProduct(&Oben); 2392 ShortestAngle = 2.*M_PI; // This will indicate the quadrant. 2393 2394 Chord.CopyVector(&(FirstPoint->x)); // bring into calling function 2395 Chord.SubtractVector(&(SecondPoint->x)); 2396 double radius = Chord.ScalarProduct(&Chord); 2397 double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.); 2398 helper.CopyVector(&Oben); 2399 helper.Scale(CircleRadius); 2400 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 2401 2402 // look in one direction of baseline for initial candidate 2373 2374 BTS = NULL; 2403 2375 CandidateList *Opt_Candidates = new CandidateList(); 2404 SearchDirection.MakeNormalVector(&Chord, &Oben); // whether we look "left" first or "right" first is not important ... 2405 2406 // adding point 1 and point 2 and the line between them 2407 AddTrianglePoint(FirstPoint, 0); 2408 AddTrianglePoint(SecondPoint, 1); 2409 AddTriangleLine(TPS[0], TPS[1], 0); 2410 2411 //cout << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n"; 2412 Find_third_point_for_Tesselation( 2413 Oben, SearchDirection, helper, BLS[0], NULL, *&Opt_Candidates, &ShortestAngle, RADIUS, LC 2414 ); 2415 cout << Verbose(1) << "List of third Points is "; 2416 for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) { 2417 cout << " " << *(*it)->point; 2418 } 2419 cout << endl; 2420 2421 for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) { 2422 // add third triangle point 2423 AddTrianglePoint((*it)->point, 2); 2424 // add the second and third line 2425 AddTriangleLine(TPS[1], TPS[2], 1); 2426 AddTriangleLine(TPS[0], TPS[2], 2); 2427 // ... and triangles to the Maps of the Tesselation class 2428 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2429 AddTriangle(); 2430 // ... and calculate its normal vector (with correct orientation) 2431 (*it)->OptCenter.Scale(-1.); 2432 cout << Verbose(2) << "Anti-Oben is currently " << (*it)->OptCenter << "." << endl; 2433 BTS->GetNormalVector((*it)->OptCenter); // vector to compare with should point inwards 2434 cout << Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and " 2435 << *(*it)->point << " with normal vector " << BTS->NormalVector << ".\n"; 2436 2437 // if we do not reach the end with the next step of iteration, we need to setup a new first line 2438 if (it != Opt_Candidates->end()--) { 2439 FirstPoint = (*it)->BaseLine->endpoints[0]->node; 2440 SecondPoint = (*it)->point; 2441 // adding point 1 and point 2 and the line between them 2442 AddTrianglePoint(FirstPoint, 0); 2443 AddTrianglePoint(SecondPoint, 1); 2444 AddTriangleLine(TPS[0], TPS[1], 0); 2445 } 2446 } 2376 for (int k=0;k<NDIM;k++) { 2377 Oben.x[k] = 1.; 2378 FirstPoint = MaxAtom[k]; 2379 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << "." << endl; 2380 2381 double ShortestAngle; 2382 atom* Opt_Candidate = NULL; 2383 ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant. 2384 2385 Find_second_point_for_Tesselation(FirstPoint, NULL, Oben, Opt_Candidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_... 2386 SecondPoint = Opt_Candidate; 2387 if (SecondPoint == NULL) // have we found a second point? 2388 continue; 2389 else 2390 cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n"; 2391 2392 helper.CopyVector(&(FirstPoint->x)); 2393 helper.SubtractVector(&(SecondPoint->x)); 2394 helper.Normalize(); 2395 Oben.ProjectOntoPlane(&helper); 2396 Oben.Normalize(); 2397 helper.VectorProduct(&Oben); 2398 ShortestAngle = 2.*M_PI; // This will indicate the quadrant. 2399 2400 Chord.CopyVector(&(FirstPoint->x)); // bring into calling function 2401 Chord.SubtractVector(&(SecondPoint->x)); 2402 double radius = Chord.ScalarProduct(&Chord); 2403 double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.); 2404 helper.CopyVector(&Oben); 2405 helper.Scale(CircleRadius); 2406 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 2407 2408 // look in one direction of baseline for initial candidate 2409 SearchDirection.MakeNormalVector(&Chord, &Oben); // whether we look "left" first or "right" first is not important ... 2410 2411 // adding point 1 and point 2 and the line between them 2412 AddTrianglePoint(FirstPoint, 0); 2413 AddTrianglePoint(SecondPoint, 1); 2414 AddTriangleLine(TPS[0], TPS[1], 0); 2415 2416 //cout << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n"; 2417 Find_third_point_for_Tesselation( 2418 Oben, SearchDirection, helper, BLS[0], NULL, *&Opt_Candidates, &ShortestAngle, RADIUS, LC 2419 ); 2420 cout << Verbose(1) << "List of third Points is "; 2421 for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) { 2422 cout << " " << *(*it)->point; 2423 } 2424 cout << endl; 2425 2426 for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) { 2427 // add third triangle point 2428 AddTrianglePoint((*it)->point, 2); 2429 // add the second and third line 2430 AddTriangleLine(TPS[1], TPS[2], 1); 2431 AddTriangleLine(TPS[0], TPS[2], 2); 2432 // ... and triangles to the Maps of the Tesselation class 2433 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2434 AddTriangle(); 2435 // ... and calculate its normal vector (with correct orientation) 2436 (*it)->OptCenter.Scale(-1.); 2437 cout << Verbose(2) << "Anti-Oben is currently " << (*it)->OptCenter << "." << endl; 2438 BTS->GetNormalVector((*it)->OptCenter); // vector to compare with should point inwards 2439 cout << Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and " 2440 << *(*it)->point << " with normal vector " << BTS->NormalVector << ".\n"; 2441 2442 // if we do not reach the end with the next step of iteration, we need to setup a new first line 2443 if (it != Opt_Candidates->end()--) { 2444 FirstPoint = (*it)->BaseLine->endpoints[0]->node; 2445 SecondPoint = (*it)->point; 2446 // adding point 1 and point 2 and the line between them 2447 AddTrianglePoint(FirstPoint, 0); 2448 AddTrianglePoint(SecondPoint, 1); 2449 AddTriangleLine(TPS[0], TPS[1], 0); 2450 } 2451 cout << Verbose(2) << "Projection is " << BTS->NormalVector.Projection(&Oben) << "." << endl; 2452 } 2453 if (BTS != NULL) // we have created one starting triangle 2454 break; 2455 else { 2456 // remove all candidates from the list and then the list itself 2457 class CandidateForTesselation *remover = NULL; 2458 for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) { 2459 remover = *it; 2460 delete(remover); 2461 } 2462 Opt_Candidates->clear(); 2463 } 2464 } 2465 2447 2466 // remove all candidates from the list and then the list itself 2448 2467 class CandidateForTesselation *remover = NULL; … … 2452 2471 } 2453 2472 delete(Opt_Candidates); 2454 cout << Verbose(2) << "Projection is " << BTS->NormalVector.Projection(&Oben) << "." << endl;2455 2473 cout << Verbose(1) << "End of Find_starting_triangle\n"; 2456 2474 };
Note:
See TracChangeset
for help on using the changeset viewer.
