Changes in src/tesselation.cpp [112b09:accebe]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tesselation.cpp
r112b09 raccebe 5 5 * Author: heber 6 6 */ 7 8 #include "Helpers/MemDebug.hpp"9 7 10 8 #include <fstream> … … 19 17 #include "triangleintersectionlist.hpp" 20 18 #include "vector.hpp" 21 #include "Line.hpp"22 19 #include "vector_ops.hpp" 23 20 #include "verbose.hpp" … … 444 441 445 442 try { 446 Line centerLine = makeLineThrough(*MolCenter, *x); 447 *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(centerLine); 448 449 DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl); 450 DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl); 451 DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl); 452 453 if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) { 454 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl); 455 return true; 456 } else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) { 457 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl); 458 return true; 459 } else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) { 460 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl); 461 return true; 462 } 463 // Calculate cross point between one baseline and the line from the third endpoint to intersection 464 int i = 0; 465 do { 466 Line line1 = makeLineThrough(*(endpoints[i%3]->node->node),*(endpoints[(i+1)%3]->node->node)); 467 Line line2 = makeLineThrough(*(endpoints[(i+2)%3]->node->node),*Intersection); 468 CrossPoint = line1.getIntersection(line2); 443 *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(*MolCenter, *x); 444 } 445 catch (LinearDependenceException &excp) { 446 Log() << Verbose(1) << excp; 447 DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl); 448 return false; 449 } 450 451 DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl); 452 DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl); 453 DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl); 454 455 if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) { 456 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl); 457 return true; 458 } else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) { 459 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl); 460 return true; 461 } else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) { 462 DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl); 463 return true; 464 } 465 // Calculate cross point between one baseline and the line from the third endpoint to intersection 466 int i = 0; 467 do { 468 try { 469 CrossPoint = GetIntersectionOfTwoLinesOnPlane(*(endpoints[i%3]->node->node), 470 *(endpoints[(i+1)%3]->node->node), 471 *(endpoints[(i+2)%3]->node->node), 472 *Intersection); 469 473 helper = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node); 470 474 CrossPoint -= (*endpoints[i%3]->node->node); // cross point was returned as absolute vector … … 473 477 if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) { 474 478 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl); 475 return false; 479 i=4; 480 break; 476 481 } 477 482 i++; 478 } while (i < 3); 483 } catch (LinearDependenceException &excp){ 484 break; 485 } 486 } while (i < 3); 487 if (i == 3) { 479 488 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl); 480 489 return true; 481 } 482 catch (MathException &excp) { 483 Log() << Verbose(1) << excp; 484 DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl); 490 } else { 491 DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl); 485 492 return false; 486 493 } … … 509 516 GetCenter(&Direction); 510 517 try { 511 Line l = makeLineThrough(*x, Direction); 512 *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(l); 513 } 514 catch (MathException &excp) { 518 *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(*x, Direction); 519 } 520 catch (LinearDependenceException &excp) { 515 521 (*ClosestPoint) = (*x); 516 522 } … … 535 541 Direction = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node); 536 542 // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal); 537 Line l = makeLineThrough(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node)); 538 CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l); 543 CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node)); 539 544 CrossDirection[i] = CrossPoint[i] - InPlane; 540 545 CrossPoint[i] -= (*endpoints[i%3]->node->node); // cross point was returned as absolute vector
Note:
See TracChangeset
for help on using the changeset viewer.