Changes in / [02bfde:196a5a]
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r02bfde r196a5a 2 2 #include "boundary.hpp" 3 3 4 #define DEBUG 14 #define DEBUG 0 5 5 6 6 // ======================================== Points on Boundary ================================= … … 1356 1356 LineMap::iterator LineWalker; 1357 1357 //cout << "Manually checking endpoints for line." << endl; 1358 if ((a->lines.find(b->node->nr)) != a->lines.end()) //->first == b->node->nr)1358 if ((a->lines.find(b->node->nr))->first == b->node->nr) 1359 1359 //If a line is there, how do I recognize that beyond a shadow of a doubt? 1360 1360 { … … 1421 1421 * @param b vector second point of triangle 1422 1422 * @param c vector third point of triangle 1423 * @param *Umkreismittelpunkt new cneter point of circumference1424 1423 * @param Direction vector indicates up/down 1425 1424 * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle … … 1433 1432 */ 1434 1433 1435 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector *NewUmkreismittelpunkt, Vector* Direction, Vector* AlternativeDirection,1434 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector* Direction, Vector* AlternativeDirection, 1436 1435 double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius) 1437 1436 { 1438 1437 Vector TempNormal, helper; 1439 1438 double Restradius; 1440 cout << Verbose(3) << "Begin of Get_center_of_sphere.\n"; 1439 1441 1440 *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ; 1442 1441 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma))); 1443 NewUmkreismittelpunkt->CopyVector(Center);1444 cout << Verbose(4) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n";1445 1442 // Here we calculated center of circumscribing circle, using barycentric coordinates 1446 cout << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";1447 1443 1448 1444 TempNormal.CopyVector(&a); … … 1468 1464 TempNormal.Normalize(); 1469 1465 Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius); 1470 cout << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";1471 1466 TempNormal.Scale(Restradius); 1472 cout << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";1473 1467 1474 1468 Center->AddVector(&TempNormal); 1475 cout << Verbose(4) << "Center of sphere of circumference is " << *Center << ".\n";1476 cout << Verbose(3) << "End of Get_center_of_sphere.\n";1477 1469 } 1478 1470 ; … … 1507 1499 atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol) 1508 1500 { 1509 cout << Verbose(2) << "Begin of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n"; 1510 cout << Verbose(3) << "Candidate is "<< *Candidate << endl; 1511 cout << Verbose(4) << "Baseline vector is " << *Chord << "." << endl; 1512 cout << Verbose(4) << "ReferencePoint is " << ReferencePoint << "." << endl; 1513 cout << Verbose(4) << "Normal of base triangle is " << *OldNormal << "." << endl; 1514 cout << Verbose(4) << "Search direction is " << *direction1 << "." << endl; 1501 //cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl; 1515 1502 /* OldNormal is normal vector on the old triangle 1516 1503 * direction1 is normal on the triangle line, from which we come, as well as on OldNormal. … … 1528 1515 atom *Walker; // variable atom point 1529 1516 1530 Vector NewUmkreismittelpunkt; 1517 1518 dif_a.CopyVector(&(a->x)); 1519 dif_a.SubtractVector(&(Candidate->x)); 1520 dif_b.CopyVector(&(b->x)); 1521 dif_b.SubtractVector(&(Candidate->x)); 1522 AngleCheck.CopyVector(&(Candidate->x)); 1523 AngleCheck.SubtractVector(&(a->x)); 1524 AngleCheck.ProjectOntoPlane(Chord); 1525 1526 SideA = dif_b.Norm(); 1527 SideB = dif_a.Norm(); 1528 SideC = Chord->Norm(); 1529 //Chord->Scale(-1); 1530 1531 alpha = Chord->Angle(&dif_a); 1532 beta = M_PI - Chord->Angle(&dif_b); 1533 gamma = dif_a.Angle(&dif_b); 1531 1534 1532 1535 1533 1536 if (a != Candidate and b != Candidate and c != Candidate) 1534 1537 { 1535 cout << Verbose(3) << "We have a unique candidate!" << endl;1536 dif_a.CopyVector(&(a->x));1537 dif_a.SubtractVector(&(Candidate->x));1538 dif_b.CopyVector(&(b->x));1539 dif_b.SubtractVector(&(Candidate->x));1540 AngleCheck.CopyVector(&(Candidate->x));1541 AngleCheck.SubtractVector(&(a->x));1542 AngleCheck.ProjectOntoPlane(Chord);1543 1544 SideA = dif_b.Norm();1545 SideB = dif_a.Norm();1546 SideC = Chord->Norm();1547 //Chord->Scale(-1);1548 1549 alpha = Chord->Angle(&dif_a);1550 beta = M_PI - Chord->Angle(&dif_b);1551 gamma = dif_a.Angle(&dif_b);1552 1553 cout << Verbose(2) << "Base triangle has sides " << dif_a << ", " << dif_b << ", " << *Chord << " with angles " << alpha/M_PI*180. << ", " << beta/M_PI*180. << ", " << gamma/M_PI*180. << "." << endl;1554 1555 if (fabs(M_PI - alpha - beta - gamma) > MYEPSILON)1556 cerr << Verbose(0) << "WARNING: sum of angles for candidate triangle " << (alpha + beta + gamma)/M_PI*180. << " != 180.\n";1557 1538 1558 1539 Umkreisradius = SideA / 2.0 / sin(alpha); … … 1563 1544 if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points. 1564 1545 { 1565 cout << Verbose(3) << "Circle of circumference would fit: " << Umkreisradius << " < " << RADIUS << "." << endl; 1566 cout << Verbose(2) << "Candidate is "<< *Candidate << endl; 1546 cout << Verbose(1) << "Candidate is "<< *Candidate << endl; 1567 1547 sign = AngleCheck.ScalarProduct(direction1); 1568 1548 if (fabs(sign)<MYEPSILON) … … 1582 1562 { 1583 1563 sign /= fabs(sign); 1584 cout << Verbose(3) << "Candidate is in search direction: " << sign << "." << endl;1585 1564 } 1586 1565 1587 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), &NewUmkreismittelpunkt, OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1566 1567 1568 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1588 1569 1589 1570 AngleCheck.CopyVector(&ReferencePoint); … … 1592 1573 AngleCheck.AddVector(&Mittelpunkt); 1593 1574 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1594 cout << Verbose(4) << "Reference vector to sphere's center is " << AngleCheck << "." << endl;1595 1575 1596 1576 BallAngle = AngleCheck.Angle(OldNormal); 1597 cout << Verbose(3) << "Angle between normal of base triangle and center of ball sphere is :" << BallAngle << "." << endl;1598 1577 1599 1578 //cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl; 1600 1579 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1601 1580 1602 cout << Verbose(3) << "BallAngle is " << BallAngle << " Sign is " << sign << endl; 1603 1604 NewUmkreismittelpunkt.SubtractVector(&ReferencePoint); 1605 1606 if ((AngleCheck.ScalarProduct(direction1) >=0) || (fabs(NewUmkreismittelpunkt.Norm()) < MYEPSILON)) 1581 cout << Verbose(1) << "BallAngle is " << BallAngle << " Sign is " << sign << endl; 1582 1583 if (AngleCheck.ScalarProduct(direction1) >=0) 1607 1584 { 1608 1585 if (Storage[0]< -1.5) // first Candidate at all 1609 1586 { 1610 1587 1611 cout << Verbose(2) << "First goodcandidate is " << *Candidate << " with ";1588 cout << "Next better candidate is " << *Candidate << " with "; 1612 1589 Opt_Candidate = Candidate; 1613 1590 Storage[0] = sign; 1614 1591 Storage[1] = AlternativeSign; 1615 1592 Storage[2] = BallAngle; 1616 cout << " angle " << Storage[2] << " and Up/Down"1593 cout << "Angle is " << Storage[2] << ", Halbraum ist " 1617 1594 << Storage[0] << endl; 1595 1596 1618 1597 } 1619 1598 else … … 1621 1600 if ( Storage[2] > BallAngle) 1622 1601 { 1623 cout << Verbose(2) <<"Next better candidate is " << *Candidate << " with ";1602 cout << "Next better candidate is " << *Candidate << " with "; 1624 1603 Opt_Candidate = Candidate; 1625 1604 Storage[0] = sign; 1626 1605 Storage[1] = AlternativeSign; 1627 1606 Storage[2] = BallAngle; 1628 cout << " angle " << Storage[2] << " and Up/Down"1607 cout << "Angle is " << Storage[2] << ", Halbraum ist " 1629 1608 << Storage[0] << endl; 1630 1609 } 1631 1610 else 1632 1611 { 1633 if (DEBUG) 1634 { 1635 cout << Verbose(3) << *Candidate << " looses against better candidate " << *Opt_Candidate << "." << endl; 1636 } 1612 //if (DEBUG) 1613 cout << "Looses to better candidate" << endl; 1614 1637 1615 } 1638 1616 } … … 1640 1618 else 1641 1619 { 1642 if (DEBUG) 1643 { 1644 cout << Verbose(3) << *Candidate << " refused due to Up/Down sign which is " << sign << endl; 1645 } 1620 //if (DEBUG) 1621 cout << "Refused due to bad direction of ball centre." << endl; 1646 1622 } 1647 1623 } 1648 1624 else 1649 1625 { 1650 if (DEBUG) 1651 { 1652 cout << Verbose(3) << *Candidate << " would have circumference of " << Umkreisradius << " bigger than ball's radius " << RADIUS << "." << endl; 1653 } 1626 //if (DEBUG) 1627 cout << "Doesn't satisfy requirements for circumscribing circle" << endl; 1654 1628 } 1655 1629 } 1656 1630 else 1657 1631 { 1658 if (DEBUG) 1659 { 1660 cout << Verbose(3) << *Candidate << " is either " << *a << " or " << *b << "." << endl; 1661 } 1632 //if (DEBUG) 1633 cout << "identisch mit Ursprungslinie" << endl; 1634 1662 1635 } 1663 1636 … … 1682 1655 } 1683 1656 } 1684 cout << Verbose(2) << "End of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n";1685 1657 } 1686 1658 ; … … 1804 1776 d1->ProjectOntoPlane(&AngleCheckReference); 1805 1777 sign = AngleCheck.ScalarProduct(d1); 1806 if (fabs(sign) < MYEPSILON) 1807 sign = 0; 1808 else 1809 sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction... 1778 sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction... 1810 1779 1811 1780 … … 1965 1934 const double& RADIUS, int N) 1966 1935 { 1967 cout << Verbose(1) << " Begin of Find_next_suitable_triangle\n";1936 cout << Verbose(1) << "Looking for next suitable triangle \n"; 1968 1937 Vector direction1; 1969 1938 Vector helper; … … 1971 1940 ofstream *tempstream = NULL; 1972 1941 char filename[255]; 1973 double tmp;1974 //atom* Walker;1975 1942 atom* OldThirdPoint; 1976 1943 … … 1982 1949 Vector Opt_Mittelpunkt; 1983 1950 1984 cout << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl; 1985 1951 cout << Verbose(1) << "Constructing helpful vectors ... " << endl; 1986 1952 helper.CopyVector(&(Line.endpoints[0]->node->x)); 1987 1953 for (int i = 0; i < 3; i++) … … 2004 1970 direction1.Scale(-1); 2005 1971 } 2006 cout << Verbose(2) << "Looking in direction " << direction1 << " for candidates.\n";2007 1972 2008 1973 Chord.CopyVector(&(Line.endpoints[0]->node->x)); // bring into calling function 2009 1974 Chord.SubtractVector(&(Line.endpoints[1]->node->x)); 2010 cout << Verbose(2) << "Baseline vector is " << Chord << ".\n"; 2011 2012 2013 Vector Umkreismittelpunkt, a, b, c; 2014 double alpha, beta, gamma; 2015 a.CopyVector(&(T.endpoints[0]->node->x)); 2016 b.CopyVector(&(T.endpoints[1]->node->x)); 2017 c.CopyVector(&(T.endpoints[2]->node->x)); 2018 a.SubtractVector(&(T.endpoints[1]->node->x)); 2019 b.SubtractVector(&(T.endpoints[2]->node->x)); 2020 c.SubtractVector(&(T.endpoints[0]->node->x)); 2021 2022 // alpha = a.Angle(&c) - M_PI/2.; 2023 // beta = b.Angle(&a); 2024 // gamma = c.Angle(&b) - M_PI/2.; 1975 1976 1977 Vector Umkreismittelpunkt, a, b, c; 1978 double alpha, beta, gamma; 1979 a.CopyVector(&(T.endpoints[0]->node->x)); 1980 b.CopyVector(&(T.endpoints[1]->node->x)); 1981 c.CopyVector(&(T.endpoints[2]->node->x)); 1982 a.SubtractVector(&(T.endpoints[1]->node->x)); 1983 b.SubtractVector(&(T.endpoints[2]->node->x)); 1984 c.SubtractVector(&(T.endpoints[0]->node->x)); 1985 2025 1986 alpha = M_PI - a.Angle(&c); 2026 1987 beta = M_PI - b.Angle(&a); 2027 1988 gamma = M_PI - c.Angle(&b); 2028 if (fabs(M_PI - alpha - beta - gamma) > MYEPSILON)2029 cerr << Verbose(0) << "WARNING: sum of angles for candidate triangle " << (alpha + beta + gamma)/M_PI*180. << " != 180.\n";2030 1989 2031 1990 Umkreismittelpunkt = (T.endpoints[0]->node->x) * sin(2.*alpha) + T.endpoints[1]->node->x * sin(2.*beta) + (T.endpoints[2]->node->x) * sin(2.*gamma) ; … … 2036 1995 cout << " Old Normal is " << (T.NormalVector.x)[0] << " " << T.NormalVector.x[1] << " " << (T.NormalVector.x)[2] << " " << endl; 2037 1996 2038 cout << Verbose(2) << "Base triangle has sides " << a << ", " << b << ", " << c << " with angles " << alpha/M_PI*180. << ", " << beta/M_PI*180. << ", " << gamma/M_PI*180. << "." << endl;2039 Umkreismittelpunkt = (T.endpoints[0]->node->x) * sin(2.*alpha) + T.endpoints[1]->node->x * sin(2.*beta) + (T.endpoints[2]->node->x) * sin(2.*gamma) ;2040 Umkreismittelpunkt.Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma)));2041 cout << Verbose(2) << "Center of circumference is " << Umkreismittelpunkt << "." << endl;2042 if (DEBUG)2043 cout << Verbose(3) << "Check of relative endpoints (same distance, equally spreaded): "<< endl;2044 tmp = 0;2045 for (int i=0;i<NDIM;i++) {2046 helper.CopyVector(&T.endpoints[i]->node->x);2047 helper.SubtractVector(&Umkreismittelpunkt);2048 if (DEBUG)2049 cout << Verbose(3) << "Endpoint[" << i << "]: " << helper << " with length " << helper.Norm() << "." << endl;2050 if (tmp == 0) // set on first time for comparison against next ones2051 tmp = helper.Norm();2052 if (fabs(helper.Norm() - tmp) > MYEPSILON)2053 cerr << Verbose(1) << "WARNING: center of circumference is wrong!" << endl;2054 }2055 1997 2056 1998 cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl; … … 2069 2011 if ((TrianglesOnBoundaryCount % 1) == 0) 2070 2012 { 2071 cout << Verbose(1) << "Writing temporary non convex hull to file testEnvelope-" << TriangleFilesWritten << "d.dat.\n";2072 2013 sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten); 2073 2014 tempstream = new ofstream(filename, ios::trunc); … … 2080 2021 if (TrianglesOnBoundaryCount >189 and TrianglesOnBoundaryCount < 200 ) 2081 2022 { 2082 c err << Verbose(0)2083 << " WARNING: Already more than " << TrianglesOnBoundaryCount-1 << "triangles, construction probably has crashed." << endl;2023 cout << Verbose(1) 2024 << "No new Atom found, triangle construction will crash" << endl; 2084 2025 write_tecplot_file(out, tecplot, this, mol, TriangleFilesWritten); 2085 cout << Verbose(2) <<"This is currently added candidate" << Opt_Candidate << endl;2026 cout << "This is currently added candidate" << Opt_Candidate << endl; 2086 2027 } 2087 2028 // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke 2088 2029 2089 cout << Verbose(2) << " Optimal candidate is " << *Opt_Candidate << endl; 2090 2091 // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2) 2030 cout << " Optimal candidate is " << *Opt_Candidate << endl; 2092 2031 2093 2032 AddTrianglePoint(Opt_Candidate, 0); 2094 LineMap::iterator TryAndError; 2095 TryAndError = TPS[0]->lines.find(Line.endpoints[0]->node->nr); 2096 bool flag = true; 2097 if ((TryAndError != TPS[0]->lines.end()) && (TryAndError->second->TrianglesCount > 1)) 2098 flag = false; 2099 TryAndError = TPS[0]->lines.find(Line.endpoints[1]->node->nr); 2100 if ((TryAndError != TPS[0]->lines.end()) && (TryAndError->second->TrianglesCount > 1)) 2101 flag = false; 2102 2103 if (flag) { // if so, add 2104 AddTrianglePoint(Line.endpoints[0]->node, 1); 2105 AddTrianglePoint(Line.endpoints[1]->node, 2); 2106 2107 AddTriangleLine(TPS[0], TPS[1], 0); 2108 AddTriangleLine(TPS[0], TPS[2], 1); 2109 AddTriangleLine(TPS[1], TPS[2], 2); 2110 2111 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2112 AddTriangleToLines(); 2113 2114 BTS->GetNormalVector(BTS->NormalVector); 2115 2116 if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0) || 2117 (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0) || 2118 (fabs(Storage[0]) < MYEPSILON && Storage[1]*BTS->NormalVector.ScalarProduct(&direction1) < 0) ) 2119 2120 { 2121 BTS->NormalVector.Scale(-1); 2122 }; 2123 cout << Verbose(2) << "New triangle with " << *BTS << "and normal vector " << BTS->NormalVector << " for this triangle ... " << endl; 2124 cout << Verbose(2) << "We have "<< TrianglesOnBoundaryCount << " for line " << Line << "." << endl; 2125 } else { // else, yell and do nothing 2126 cout << Verbose(2) << "This triangle consisting of "; 2127 for (int i=0;i<NDIM;i++) 2128 cout << BLS[i] << "(" << BLS[i]->TrianglesCount << "), "; 2129 cout << " is invalid!" << endl; 2130 } 2131 cout << Verbose(1) << "End of Find_next_suitable_triangle\n"; 2033 AddTrianglePoint(Line.endpoints[0]->node, 1); 2034 AddTrianglePoint(Line.endpoints[1]->node, 2); 2035 2036 AddTriangleLine(TPS[0], TPS[1], 0); 2037 AddTriangleLine(TPS[0], TPS[2], 1); 2038 AddTriangleLine(TPS[1], TPS[2], 2); 2039 2040 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2041 AddTriangleToLines(); 2042 cout << "New triangle with " << *BTS << endl; 2043 cout << "We have "<< TrianglesOnBoundaryCount << endl; 2044 cout << Verbose(1) << "Constructing normal vector for this triangle ... " << endl; 2045 2046 BTS->GetNormalVector(BTS->NormalVector); 2047 2048 if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0) || 2049 (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0) || 2050 (fabs(Storage[0]) < MYEPSILON && Storage[1]*BTS->NormalVector.ScalarProduct(&direction1) < 0) ) 2051 2052 { 2053 BTS->NormalVector.Scale(-1); 2054 }; 2055 2132 2056 } 2133 2057 ; … … 2137 2061 molecule* mol, double RADIUS) 2138 2062 { 2139 cout << Verbose( 2)2140 << " Begin of Find_second_point_for_Tesselation, recursive level "2141 << RecursionLevel << endl; 2063 cout << Verbose(1) 2064 << "Looking for second point of starting triangle, recursive level " 2065 << RecursionLevel << endl;; 2142 2066 int i; 2143 2067 Vector AngleCheck; 2144 2068 atom* Walker; 2145 double norm = -1. , angle;2069 double norm = -1.; 2146 2070 2147 2071 // check if we only have one unique point yet ... 2148 2072 if (a != Candidate) 2149 2073 { 2150 cout << Verbose(3) << "Current candidate is " << *Candidate << ": ";2151 2074 AngleCheck.CopyVector(&(Candidate->x)); 2152 2075 AngleCheck.SubtractVector(&(a->x)); … … 2155 2078 if (norm < RADIUS) 2156 2079 { 2157 angle = AngleCheck.Angle(&Oben); 2158 if (angle < Storage[0]) 2080 if (AngleCheck.Angle(&Oben) < Storage[0]) 2159 2081 { 2160 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 2161 cout << "Is a better candidate with distance " << norm << " and " << angle << ".\n"; 2082 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[2]); 2083 cout << "Next better candidate is " << *Candidate 2084 << " with distance " << norm << ".\n"; 2162 2085 Opt_Candidate = Candidate; 2163 2086 Storage[0] = AngleCheck.Angle(&Oben); … … 2166 2089 else 2167 2090 { 2168 cout << "Looses with angle " << angle << "to a better candidate "2091 cout << Verbose(1) << "Supposedly looses to a better candidate " 2169 2092 << *Opt_Candidate << endl; 2170 2093 } … … 2172 2095 else 2173 2096 { 2174 cout << "Refused due to Radius " << norm2097 cout << Verbose(1) << *Candidate << " refused due to Radius " << norm 2175 2098 << endl; 2176 2099 } … … 2191 2114 }; 2192 2115 }; 2193 cout << Verbose(2) << "End of Find_second_point_for_Tesselation, recursive level "2194 << RecursionLevel << endl;2195 2116 } 2196 2117 ; … … 2198 2119 void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS) 2199 2120 { 2200 cout << Verbose(1) << " Begin of Find_starting_triangle\n";2121 cout << Verbose(1) << "Looking for starting triangle \n"; 2201 2122 int i = 0; 2202 2123 atom* Walker; 2203 2124 atom* FirstPoint; 2204 2125 atom* SecondPoint; 2205 atom* max_index[ NDIM];2206 double max_coordinate[ NDIM];2126 atom* max_index[3]; 2127 double max_coordinate[3]; 2207 2128 Vector Oben; 2208 2129 Vector helper; … … 2217 2138 max_coordinate[i] = -1; 2218 2139 } 2219 cout << Verbose( 2) << "Molecule mol is there and has " << mol->AtomCount2140 cout << Verbose(1) << "Molecule mol is there and has " << mol->AtomCount 2220 2141 << " Atoms \n"; 2221 2142 … … 2235 2156 } 2236 2157 2237 cout << Verbose(2) << "Found maximum coordinates: "; 2238 for (int i=0;i<NDIM;i++) 2239 cout << i << ": " << *max_index[i] << "\t"; 2240 cout << endl; 2158 cout << Verbose(1) << "Found maximum coordinates. " << endl; 2241 2159 //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0 2242 2160 const int k = 1; … … 2244 2162 FirstPoint = max_index[k]; 2245 2163 2246 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << " with " << mol->NumberOfBondsPerAtom[FirstPoint->nr] << " bonds." << endl; 2164 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << ": " 2165 << FirstPoint->x.x[0] << endl; 2247 2166 double Storage[3]; 2248 2167 atom* Opt_Candidate = NULL; … … 2250 2169 Storage[1] = 999999.; // This will be an angle looking for the third point. 2251 2170 Storage[2] = 999999.; 2171 cout << Verbose(1) << "Number of Bonds: " 2172 << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl; 2252 2173 2253 2174 Find_second_point_for_Tesselation(FirstPoint, FirstPoint, FirstPoint, 0, 2254 2175 Oben, Opt_Candidate, Storage, mol, RADIUS); // we give same point as next candidate as its bonds are looked into in find_second_... 2255 2176 SecondPoint = Opt_Candidate; 2256 cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n";2177 cout << Verbose(1) << "Found second point is " << *SecondPoint << ".\n"; 2257 2178 2258 2179 helper.CopyVector(&(FirstPoint->x)); … … 2270 2191 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 2271 2192 2272 cout << Verbose(2) << "Looking for third point candidates \n"; 2193 cout << Verbose(1) << "Looking for third point candidates \n"; 2194 cout << Verbose(1) << " In direction " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << " " << endl; 2273 2195 // look in one direction of baseline for initial candidate 2274 2196 Opt_Candidate = NULL; … … 2277 2199 CenterOfFirstLine.AddVector(&(SecondPoint->x)); 2278 2200 2279 cout << Verbose(1) << "Looking for third point candidates from " << *FirstPoint << " onward ...\n";2280 2201 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, SecondPoint, FirstPoint, 0, 2281 2202 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); 2282 2203 // look in other direction of baseline for possible better candidate 2283 cout << Verbose(1) << "Looking for third point candidates from " << *SecondPoint << " onward ...\n";2284 2204 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, SecondPoint, 0, 2285 2205 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); … … 2287 2207 2288 2208 // FOUND Starting Triangle: FirstPoint, SecondPoint, Opt_Candidate 2209 2210 cout << Verbose(1) << "The found starting triangle consists of " 2211 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate 2212 << "." << endl; 2289 2213 2290 2214 // Finally, we only have to add the found points … … 2302 2226 Oben.Scale(-1.); 2303 2227 BTS->GetNormalVector(Oben); 2304 cout << Verbose(0) << "==> The found starting triangle consists of "2305 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate2306 << " with normal vector " << BTS->NormalVector << ".\n";2307 cout << Verbose(1) << "End of Find_starting_triangle\n";2308 2228 } 2309 2229 ; … … 2317 2237 const double RADIUS = 6.; 2318 2238 LineMap::iterator baseline; 2319 cout << Verbose(0) << "Begin of Find_non_convex_border\n";2320 bool flag = false; // marks whether we went once through all baselines without finding any without two triangles2321 2322 2239 Tess->Find_starting_triangle(mol, RADIUS); 2323 2240 2324 2241 baseline = Tess->LinesOnBoundary.begin(); 2325 while ( (baseline != Tess->LinesOnBoundary.end()) || (flag))2242 while (baseline != Tess->LinesOnBoundary.end()) 2326 2243 { 2327 2244 if (baseline->second->TrianglesCount == 1) 2328 2245 { 2246 cout << Verbose(1) << "Begin of Tesselation ... " << endl; 2329 2247 Tess->Find_next_suitable_triangle(out, tecplot, mol, 2330 2248 *(baseline->second), 2331 2249 *(((baseline->second->triangles.begin()))->second), RADIUS, N); //the line is there, so there is a triangle, but only one. 2332 flag = true;2250 cout << Verbose(1) << "End of Tesselation ... " << endl; 2333 2251 } 2334 2252 else 2335 2253 { 2336 cout << Verbose(1) << " Line " << baseline->second << " has"2254 cout << Verbose(1) << "There is a line with " 2337 2255 << baseline->second->TrianglesCount << " triangles adjacent" 2338 2256 << endl; … … 2340 2258 N++; 2341 2259 baseline++; 2342 if ((baseline == Tess->LinesOnBoundary.end()) && (flag)) { 2343 baseline = Tess->LinesOnBoundary.begin(); // restart if we reach end due to newly inserted lines 2344 flag = false; 2345 } 2346 } 2347 cout << Verbose(1) << "Writing final tecplot file\n"; 2260 } 2348 2261 write_tecplot_file(out, tecplot, Tess, mol, -1); 2349 2262 2350 cout << Verbose(0) << "End of Find_non_convex_border\n"; 2351 } 2352 ; 2353 2263 } 2264 ; -
src/vector.cpp
r02bfde r196a5a 219 219 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 220 220 */ 221 double Vector::Angle( constVector *y) const221 double Vector::Angle(Vector *y) const 222 222 { 223 223 return acos(this->ScalarProduct(y)/Norm()/y->Norm()); … … 313 313 }; 314 314 315 /** Prints a 3dim vector to a stream. 316 * \param ost output stream 317 * \param v Vector to be printed 318 * \return output stream 319 */ 320 ostream& operator<<(ostream& ost,Vector& m) 321 { 322 ost << "("; 323 for (int i=0;i<NDIM;i++) { 324 ost << m.x[i]; 325 if (i != 2) 326 ost << ","; 327 } 328 ost << ")"; 315 ofstream& operator<<(ofstream& ost,Vector& m) 316 { 317 m.Output(&ost); 329 318 return ost; 330 319 }; -
src/vector.hpp
r02bfde r196a5a 21 21 double Projection(const Vector *y) const; 22 22 double Norm() const ; 23 double Angle( constVector *y) const;23 double Angle(Vector *y) const; 24 24 25 25 void AddVector(const Vector *y); … … 55 55 }; 56 56 57 o stream & operator << (ostream& ost, Vector &m);57 ofstream& operator<<(ofstream& ost, Vector& m); 58 58 Vector& operator+=(Vector& a, const Vector& b); 59 59 Vector& operator*=(Vector& a, const double m);
Note:
See TracChangeset
for help on using the changeset viewer.