Changes in / [196a5a:02bfde]
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r196a5a r02bfde 2 2 #include "boundary.hpp" 3 3 4 #define DEBUG 04 #define DEBUG 1 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)) ->first == b->node->nr)1358 if ((a->lines.find(b->node->nr)) != a->lines.end()) // ->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 circumference 1423 1424 * @param Direction vector indicates up/down 1424 1425 * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle … … 1432 1433 */ 1433 1434 1434 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector * Direction, Vector* AlternativeDirection,1435 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector *NewUmkreismittelpunkt, Vector* Direction, Vector* AlternativeDirection, 1435 1436 double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius) 1436 1437 { 1437 1438 Vector TempNormal, helper; 1438 1439 double Restradius; 1439 1440 cout << Verbose(3) << "Begin of Get_center_of_sphere.\n"; 1440 1441 *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ; 1441 1442 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"; 1442 1445 // Here we calculated center of circumscribing circle, using barycentric coordinates 1446 cout << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n"; 1443 1447 1444 1448 TempNormal.CopyVector(&a); … … 1464 1468 TempNormal.Normalize(); 1465 1469 Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius); 1470 cout << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n"; 1466 1471 TempNormal.Scale(Restradius); 1472 cout << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n"; 1467 1473 1468 1474 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"; 1469 1477 } 1470 1478 ; … … 1499 1507 atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol) 1500 1508 { 1501 //cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl; 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; 1502 1515 /* OldNormal is normal vector on the old triangle 1503 1516 * direction1 is normal on the triangle line, from which we come, as well as on OldNormal. … … 1515 1528 atom *Walker; // variable atom point 1516 1529 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); 1530 Vector NewUmkreismittelpunkt; 1534 1531 1535 1532 1536 1533 if (a != Candidate and b != Candidate and c != Candidate) 1537 1534 { 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"; 1538 1557 1539 1558 Umkreisradius = SideA / 2.0 / sin(alpha); … … 1544 1563 if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points. 1545 1564 { 1546 cout << Verbose(1) << "Candidate is "<< *Candidate << endl; 1565 cout << Verbose(3) << "Circle of circumference would fit: " << Umkreisradius << " < " << RADIUS << "." << endl; 1566 cout << Verbose(2) << "Candidate is "<< *Candidate << endl; 1547 1567 sign = AngleCheck.ScalarProduct(direction1); 1548 1568 if (fabs(sign)<MYEPSILON) … … 1562 1582 { 1563 1583 sign /= fabs(sign); 1584 cout << Verbose(3) << "Candidate is in search direction: " << sign << "." << endl; 1564 1585 } 1565 1586 1566 1567 1568 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1587 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), &NewUmkreismittelpunkt, OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1569 1588 1570 1589 AngleCheck.CopyVector(&ReferencePoint); … … 1573 1592 AngleCheck.AddVector(&Mittelpunkt); 1574 1593 //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; 1575 1595 1576 1596 BallAngle = AngleCheck.Angle(OldNormal); 1597 cout << Verbose(3) << "Angle between normal of base triangle and center of ball sphere is :" << BallAngle << "." << endl; 1577 1598 1578 1599 //cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl; 1579 1600 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1580 1601 1581 cout << Verbose(1) << "BallAngle is " << BallAngle << " Sign is " << sign << endl; 1582 1583 if (AngleCheck.ScalarProduct(direction1) >=0) 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)) 1584 1607 { 1585 1608 if (Storage[0]< -1.5) // first Candidate at all 1586 1609 { 1587 1610 1588 cout << "Next bettercandidate is " << *Candidate << " with ";1611 cout << Verbose(2) << "First good candidate is " << *Candidate << " with "; 1589 1612 Opt_Candidate = Candidate; 1590 1613 Storage[0] = sign; 1591 1614 Storage[1] = AlternativeSign; 1592 1615 Storage[2] = BallAngle; 1593 cout << " Angle is " << Storage[2] << ", Halbraum ist"1616 cout << " angle " << Storage[2] << " and Up/Down " 1594 1617 << Storage[0] << endl; 1595 1596 1597 1618 } 1598 1619 else … … 1600 1621 if ( Storage[2] > BallAngle) 1601 1622 { 1602 cout << "Next better candidate is " << *Candidate << " with ";1623 cout << Verbose(2) << "Next better candidate is " << *Candidate << " with "; 1603 1624 Opt_Candidate = Candidate; 1604 1625 Storage[0] = sign; 1605 1626 Storage[1] = AlternativeSign; 1606 1627 Storage[2] = BallAngle; 1607 cout << " Angle is " << Storage[2] << ", Halbraum ist"1628 cout << " angle " << Storage[2] << " and Up/Down " 1608 1629 << Storage[0] << endl; 1609 1630 } 1610 1631 else 1611 1632 { 1612 //if (DEBUG) 1613 cout << "Looses to better candidate" << endl; 1614 1633 if (DEBUG) 1634 { 1635 cout << Verbose(3) << *Candidate << " looses against better candidate " << *Opt_Candidate << "." << endl; 1636 } 1615 1637 } 1616 1638 } … … 1618 1640 else 1619 1641 { 1620 //if (DEBUG) 1621 cout << "Refused due to bad direction of ball centre." << endl; 1642 if (DEBUG) 1643 { 1644 cout << Verbose(3) << *Candidate << " refused due to Up/Down sign which is " << sign << endl; 1645 } 1622 1646 } 1623 1647 } 1624 1648 else 1625 1649 { 1626 //if (DEBUG) 1627 cout << "Doesn't satisfy requirements for circumscribing circle" << endl; 1650 if (DEBUG) 1651 { 1652 cout << Verbose(3) << *Candidate << " would have circumference of " << Umkreisradius << " bigger than ball's radius " << RADIUS << "." << endl; 1653 } 1628 1654 } 1629 1655 } 1630 1656 else 1631 1657 { 1632 //if (DEBUG) 1633 cout << "identisch mit Ursprungslinie" << endl; 1634 1658 if (DEBUG) 1659 { 1660 cout << Verbose(3) << *Candidate << " is either " << *a << " or " << *b << "." << endl; 1661 } 1635 1662 } 1636 1663 … … 1655 1682 } 1656 1683 } 1684 cout << Verbose(2) << "End of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n"; 1657 1685 } 1658 1686 ; … … 1776 1804 d1->ProjectOntoPlane(&AngleCheckReference); 1777 1805 sign = AngleCheck.ScalarProduct(d1); 1778 sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction... 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... 1779 1810 1780 1811 … … 1934 1965 const double& RADIUS, int N) 1935 1966 { 1936 cout << Verbose(1) << " Looking for next suitable triangle\n";1967 cout << Verbose(1) << "Begin of Find_next_suitable_triangle\n"; 1937 1968 Vector direction1; 1938 1969 Vector helper; … … 1940 1971 ofstream *tempstream = NULL; 1941 1972 char filename[255]; 1973 double tmp; 1974 //atom* Walker; 1942 1975 atom* OldThirdPoint; 1943 1976 … … 1949 1982 Vector Opt_Mittelpunkt; 1950 1983 1951 cout << Verbose(1) << "Constructing helpful vectors ... " << endl; 1984 cout << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl; 1985 1952 1986 helper.CopyVector(&(Line.endpoints[0]->node->x)); 1953 1987 for (int i = 0; i < 3; i++) … … 1970 2004 direction1.Scale(-1); 1971 2005 } 2006 cout << Verbose(2) << "Looking in direction " << direction1 << " for candidates.\n"; 1972 2007 1973 2008 Chord.CopyVector(&(Line.endpoints[0]->node->x)); // bring into calling function 1974 2009 Chord.SubtractVector(&(Line.endpoints[1]->node->x)); 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 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.; 1986 2025 alpha = M_PI - a.Angle(&c); 1987 2026 beta = M_PI - b.Angle(&a); 1988 2027 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"; 1989 2030 1990 2031 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) ; … … 1995 2036 cout << " Old Normal is " << (T.NormalVector.x)[0] << " " << T.NormalVector.x[1] << " " << (T.NormalVector.x)[2] << " " << endl; 1996 2037 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 ones 2051 tmp = helper.Norm(); 2052 if (fabs(helper.Norm() - tmp) > MYEPSILON) 2053 cerr << Verbose(1) << "WARNING: center of circumference is wrong!" << endl; 2054 } 1997 2055 1998 2056 cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl; … … 2011 2069 if ((TrianglesOnBoundaryCount % 1) == 0) 2012 2070 { 2071 cout << Verbose(1) << "Writing temporary non convex hull to file testEnvelope-" << TriangleFilesWritten << "d.dat.\n"; 2013 2072 sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten); 2014 2073 tempstream = new ofstream(filename, ios::trunc); … … 2021 2080 if (TrianglesOnBoundaryCount >189 and TrianglesOnBoundaryCount < 200 ) 2022 2081 { 2023 c out << Verbose(1)2024 << " No new Atom found, triangle construction will crash" << endl;2082 cerr << Verbose(0) 2083 << "WARNING: Already more than " << TrianglesOnBoundaryCount-1 << "triangles, construction probably has crashed." << endl; 2025 2084 write_tecplot_file(out, tecplot, this, mol, TriangleFilesWritten); 2026 cout << "This is currently added candidate" << Opt_Candidate << endl;2085 cout << Verbose(2) << "This is currently added candidate" << Opt_Candidate << endl; 2027 2086 } 2028 2087 // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke 2029 2088 2030 cout << " Optimal candidate is " << *Opt_Candidate << endl; 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) 2031 2092 2032 2093 AddTrianglePoint(Opt_Candidate, 0); 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 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"; 2056 2132 } 2057 2133 ; … … 2061 2137 molecule* mol, double RADIUS) 2062 2138 { 2063 cout << Verbose( 1)2064 << " Looking for second point of starting triangle, recursive level "2065 << RecursionLevel << endl; ;2139 cout << Verbose(2) 2140 << "Begin of Find_second_point_for_Tesselation, recursive level " 2141 << RecursionLevel << endl; 2066 2142 int i; 2067 2143 Vector AngleCheck; 2068 2144 atom* Walker; 2069 double norm = -1. ;2145 double norm = -1., angle; 2070 2146 2071 2147 // check if we only have one unique point yet ... 2072 2148 if (a != Candidate) 2073 2149 { 2150 cout << Verbose(3) << "Current candidate is " << *Candidate << ": "; 2074 2151 AngleCheck.CopyVector(&(Candidate->x)); 2075 2152 AngleCheck.SubtractVector(&(a->x)); … … 2078 2155 if (norm < RADIUS) 2079 2156 { 2080 if (AngleCheck.Angle(&Oben) < Storage[0]) 2157 angle = AngleCheck.Angle(&Oben); 2158 if (angle < Storage[0]) 2081 2159 { 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"; 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"; 2085 2162 Opt_Candidate = Candidate; 2086 2163 Storage[0] = AngleCheck.Angle(&Oben); … … 2089 2166 else 2090 2167 { 2091 cout << Verbose(1) << "Supposedly loosesto a better candidate "2168 cout << "Looses with angle " << angle << " to a better candidate " 2092 2169 << *Opt_Candidate << endl; 2093 2170 } … … 2095 2172 else 2096 2173 { 2097 cout << Verbose(1) << *Candidate << " refused due to Radius " << norm2174 cout << "Refused due to Radius " << norm 2098 2175 << endl; 2099 2176 } … … 2114 2191 }; 2115 2192 }; 2193 cout << Verbose(2) << "End of Find_second_point_for_Tesselation, recursive level " 2194 << RecursionLevel << endl; 2116 2195 } 2117 2196 ; … … 2119 2198 void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS) 2120 2199 { 2121 cout << Verbose(1) << " Looking for starting triangle\n";2200 cout << Verbose(1) << "Begin of Find_starting_triangle\n"; 2122 2201 int i = 0; 2123 2202 atom* Walker; 2124 2203 atom* FirstPoint; 2125 2204 atom* SecondPoint; 2126 atom* max_index[ 3];2127 double max_coordinate[ 3];2205 atom* max_index[NDIM]; 2206 double max_coordinate[NDIM]; 2128 2207 Vector Oben; 2129 2208 Vector helper; … … 2138 2217 max_coordinate[i] = -1; 2139 2218 } 2140 cout << Verbose( 1) << "Molecule mol is there and has " << mol->AtomCount2219 cout << Verbose(2) << "Molecule mol is there and has " << mol->AtomCount 2141 2220 << " Atoms \n"; 2142 2221 … … 2156 2235 } 2157 2236 2158 cout << Verbose(1) << "Found maximum coordinates. " << endl; 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; 2159 2241 //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0 2160 2242 const int k = 1; … … 2162 2244 FirstPoint = max_index[k]; 2163 2245 2164 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << ": " 2165 << FirstPoint->x.x[0] << endl; 2246 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << " with " << mol->NumberOfBondsPerAtom[FirstPoint->nr] << " bonds." << endl; 2166 2247 double Storage[3]; 2167 2248 atom* Opt_Candidate = NULL; … … 2169 2250 Storage[1] = 999999.; // This will be an angle looking for the third point. 2170 2251 Storage[2] = 999999.; 2171 cout << Verbose(1) << "Number of Bonds: "2172 << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl;2173 2252 2174 2253 Find_second_point_for_Tesselation(FirstPoint, FirstPoint, FirstPoint, 0, 2175 2254 Oben, Opt_Candidate, Storage, mol, RADIUS); // we give same point as next candidate as its bonds are looked into in find_second_... 2176 2255 SecondPoint = Opt_Candidate; 2177 cout << Verbose(1) << "Found second point is " << *SecondPoint << " .\n";2256 cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n"; 2178 2257 2179 2258 helper.CopyVector(&(FirstPoint->x)); … … 2191 2270 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 2192 2271 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; 2272 cout << Verbose(2) << "Looking for third point candidates \n"; 2195 2273 // look in one direction of baseline for initial candidate 2196 2274 Opt_Candidate = NULL; … … 2199 2277 CenterOfFirstLine.AddVector(&(SecondPoint->x)); 2200 2278 2279 cout << Verbose(1) << "Looking for third point candidates from " << *FirstPoint << " onward ...\n"; 2201 2280 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, SecondPoint, FirstPoint, 0, 2202 2281 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); 2203 2282 // look in other direction of baseline for possible better candidate 2283 cout << Verbose(1) << "Looking for third point candidates from " << *SecondPoint << " onward ...\n"; 2204 2284 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, SecondPoint, 0, 2205 2285 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); … … 2207 2287 2208 2288 // FOUND Starting Triangle: FirstPoint, SecondPoint, Opt_Candidate 2209 2210 cout << Verbose(1) << "The found starting triangle consists of "2211 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate2212 << "." << endl;2213 2289 2214 2290 // Finally, we only have to add the found points … … 2226 2302 Oben.Scale(-1.); 2227 2303 BTS->GetNormalVector(Oben); 2304 cout << Verbose(0) << "==> The found starting triangle consists of " 2305 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate 2306 << " with normal vector " << BTS->NormalVector << ".\n"; 2307 cout << Verbose(1) << "End of Find_starting_triangle\n"; 2228 2308 } 2229 2309 ; … … 2237 2317 const double RADIUS = 6.; 2238 2318 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 triangles 2321 2239 2322 Tess->Find_starting_triangle(mol, RADIUS); 2240 2323 2241 2324 baseline = Tess->LinesOnBoundary.begin(); 2242 while ( baseline != Tess->LinesOnBoundary.end())2325 while ((baseline != Tess->LinesOnBoundary.end()) || (flag)) 2243 2326 { 2244 2327 if (baseline->second->TrianglesCount == 1) 2245 2328 { 2246 cout << Verbose(1) << "Begin of Tesselation ... " << endl;2247 2329 Tess->Find_next_suitable_triangle(out, tecplot, mol, 2248 2330 *(baseline->second), 2249 2331 *(((baseline->second->triangles.begin()))->second), RADIUS, N); //the line is there, so there is a triangle, but only one. 2250 cout << Verbose(1) << "End of Tesselation ... " << endl;2332 flag = true; 2251 2333 } 2252 2334 else 2253 2335 { 2254 cout << Verbose(1) << " There is a line with"2336 cout << Verbose(1) << "Line " << baseline->second << " has " 2255 2337 << baseline->second->TrianglesCount << " triangles adjacent" 2256 2338 << endl; … … 2258 2340 N++; 2259 2341 baseline++; 2260 } 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"; 2261 2348 write_tecplot_file(out, tecplot, Tess, mol, -1); 2262 2349 2263 } 2264 ; 2350 cout << Verbose(0) << "End of Find_non_convex_border\n"; 2351 } 2352 ; 2353 -
src/vector.cpp
r196a5a r02bfde 219 219 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 220 220 */ 221 double Vector::Angle( Vector *y) const221 double Vector::Angle(const Vector *y) const 222 222 { 223 223 return acos(this->ScalarProduct(y)/Norm()/y->Norm()); … … 313 313 }; 314 314 315 ofstream& operator<<(ofstream& ost,Vector& m) 316 { 317 m.Output(&ost); 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 << ")"; 318 329 return ost; 319 330 }; -
src/vector.hpp
r196a5a r02bfde 21 21 double Projection(const Vector *y) const; 22 22 double Norm() const ; 23 double Angle( Vector *y) const;23 double Angle(const Vector *y) const; 24 24 25 25 void AddVector(const Vector *y); … … 55 55 }; 56 56 57 o fstream& operator<<(ofstream& ost, Vector&m);57 ostream & operator << (ostream& 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.