Changes in / [6d4a76:12298c]
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r6d4a76 r12298c 1414 1414 LineMap::iterator LineWalker; 1415 1415 //cout << "Manually checking endpoints for line." << endl; 1416 if ((a->lines.find(b->node->nr)) ->first == b->node->nr)1416 if ((a->lines.find(b->node->nr)) != a->lines.end()) // ->first == b->node->nr) 1417 1417 //If a line is there, how do I recognize that beyond a shadow of a doubt? 1418 1418 { … … 1479 1479 * @param b vector second point of triangle 1480 1480 * @param c vector third point of triangle 1481 * @param *Umkreismittelpunkt new cneter point of circumference 1481 1482 * @param Direction vector indicates up/down 1482 1483 * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle … … 1490 1491 */ 1491 1492 1492 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector * Direction, Vector* AlternativeDirection,1493 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector *NewUmkreismittelpunkt, Vector* Direction, Vector* AlternativeDirection, 1493 1494 double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius) 1494 1495 { 1495 1496 Vector TempNormal, helper; 1496 1497 double Restradius; 1497 1498 cout << Verbose(3) << "Begin of Get_center_of_sphere.\n"; 1498 1499 *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ; 1499 1500 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma))); 1501 NewUmkreismittelpunkt->CopyVector(Center); 1502 cout << Verbose(4) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n"; 1500 1503 // Here we calculated center of circumscribing circle, using barycentric coordinates 1504 cout << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n"; 1501 1505 1502 1506 TempNormal.CopyVector(&a); … … 1522 1526 TempNormal.Normalize(); 1523 1527 Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius); 1528 cout << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n"; 1524 1529 TempNormal.Scale(Restradius); 1530 cout << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n"; 1525 1531 1526 1532 Center->AddVector(&TempNormal); 1533 cout << Verbose(4) << "Center of sphere of circumference is " << *Center << ".\n"; 1534 cout << Verbose(3) << "End of Get_center_of_sphere.\n"; 1527 1535 } 1528 1536 ; … … 1557 1565 atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol) 1558 1566 { 1559 //cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl; 1567 cout << Verbose(2) << "Begin of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n"; 1568 cout << Verbose(3) << "Candidate is "<< *Candidate << endl; 1569 cout << Verbose(4) << "Baseline vector is " << *Chord << "." << endl; 1570 cout << Verbose(4) << "ReferencePoint is " << ReferencePoint << "." << endl; 1571 cout << Verbose(4) << "Normal of base triangle is " << *OldNormal << "." << endl; 1572 cout << Verbose(4) << "Search direction is " << *direction1 << "." << endl; 1560 1573 /* OldNormal is normal vector on the old triangle 1561 1574 * direction1 is normal on the triangle line, from which we come, as well as on OldNormal. … … 1573 1586 atom *Walker; // variable atom point 1574 1587 1575 1576 dif_a.CopyVector(&(a->x)); 1577 dif_a.SubtractVector(&(Candidate->x)); 1578 dif_b.CopyVector(&(b->x)); 1579 dif_b.SubtractVector(&(Candidate->x)); 1580 AngleCheck.CopyVector(&(Candidate->x)); 1581 AngleCheck.SubtractVector(&(a->x)); 1582 AngleCheck.ProjectOntoPlane(Chord); 1583 1584 SideA = dif_b.Norm(); 1585 SideB = dif_a.Norm(); 1586 SideC = Chord->Norm(); 1587 //Chord->Scale(-1); 1588 1589 alpha = Chord->Angle(&dif_a); 1590 beta = M_PI - Chord->Angle(&dif_b); 1591 gamma = dif_a.Angle(&dif_b); 1588 Vector NewUmkreismittelpunkt; 1592 1589 1593 1590 1594 1591 if (a != Candidate and b != Candidate and c != Candidate) 1595 1592 { 1593 cout << Verbose(3) << "We have a unique candidate!" << endl; 1594 dif_a.CopyVector(&(a->x)); 1595 dif_a.SubtractVector(&(Candidate->x)); 1596 dif_b.CopyVector(&(b->x)); 1597 dif_b.SubtractVector(&(Candidate->x)); 1598 AngleCheck.CopyVector(&(Candidate->x)); 1599 AngleCheck.SubtractVector(&(a->x)); 1600 AngleCheck.ProjectOntoPlane(Chord); 1601 1602 SideA = dif_b.Norm(); 1603 SideB = dif_a.Norm(); 1604 SideC = Chord->Norm(); 1605 //Chord->Scale(-1); 1606 1607 alpha = Chord->Angle(&dif_a); 1608 beta = M_PI - Chord->Angle(&dif_b); 1609 gamma = dif_a.Angle(&dif_b); 1610 1611 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; 1612 1613 if (fabs(M_PI - alpha - beta - gamma) > MYEPSILON) 1614 cerr << Verbose(0) << "WARNING: sum of angles for candidate triangle " << (alpha + beta + gamma)/M_PI*180. << " != 180.\n"; 1596 1615 1597 1616 Umkreisradius = SideA / 2.0 / sin(alpha); … … 1602 1621 if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points. 1603 1622 { 1604 cout << Verbose(1) << "Candidate is "<< *Candidate << endl; 1623 cout << Verbose(3) << "Circle of circumference would fit: " << Umkreisradius << " < " << RADIUS << "." << endl; 1624 cout << Verbose(2) << "Candidate is "<< *Candidate << endl; 1605 1625 sign = AngleCheck.ScalarProduct(direction1); 1606 1626 if (fabs(sign)<MYEPSILON) … … 1620 1640 { 1621 1641 sign /= fabs(sign); 1642 cout << Verbose(3) << "Candidate is in search direction: " << sign << "." << endl; 1622 1643 } 1623 1644 1624 1625 1626 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1645 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), &NewUmkreismittelpunkt, OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1627 1646 1628 1647 AngleCheck.CopyVector(&ReferencePoint); … … 1631 1650 AngleCheck.AddVector(&Mittelpunkt); 1632 1651 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1652 cout << Verbose(4) << "Reference vector to sphere's center is " << AngleCheck << "." << endl; 1633 1653 1634 1654 BallAngle = AngleCheck.Angle(OldNormal); 1655 cout << Verbose(3) << "Angle between normal of base triangle and center of ball sphere is :" << BallAngle << "." << endl; 1635 1656 1636 1657 //cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl; 1637 1658 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1638 1659 1639 cout << Verbose(1) << "BallAngle is " << BallAngle << " Sign is " << sign << endl; 1640 1641 if (AngleCheck.ScalarProduct(direction1) >=0) 1660 cout << Verbose(3) << "BallAngle is " << BallAngle << " Sign is " << sign << endl; 1661 1662 NewUmkreismittelpunkt.SubtractVector(&ReferencePoint); 1663 1664 if ((AngleCheck.ScalarProduct(direction1) >=0) || (fabs(NewUmkreismittelpunkt.Norm()) < MYEPSILON)) 1642 1665 { 1643 1666 if (Storage[0]< -1.5) // first Candidate at all 1644 1667 { 1645 1668 1646 cout << "Next bettercandidate is " << *Candidate << " with ";1669 cout << Verbose(2) << "First good candidate is " << *Candidate << " with "; 1647 1670 Opt_Candidate = Candidate; 1648 1671 Storage[0] = sign; 1649 1672 Storage[1] = AlternativeSign; 1650 1673 Storage[2] = BallAngle; 1651 cout << " Angle is " << Storage[2] << ", Halbraum ist"1674 cout << " angle " << Storage[2] << " and Up/Down " 1652 1675 << Storage[0] << endl; 1653 1654 1655 1676 } 1656 1677 else … … 1658 1679 if ( Storage[2] > BallAngle) 1659 1680 { 1660 cout << "Next better candidate is " << *Candidate << " with ";1681 cout << Verbose(2) << "Next better candidate is " << *Candidate << " with "; 1661 1682 Opt_Candidate = Candidate; 1662 1683 Storage[0] = sign; 1663 1684 Storage[1] = AlternativeSign; 1664 1685 Storage[2] = BallAngle; 1665 cout << " Angle is " << Storage[2] << ", Halbraum ist"1686 cout << " angle " << Storage[2] << " and Up/Down " 1666 1687 << Storage[0] << endl; 1667 1688 } 1668 1689 else 1669 1690 { 1670 //if (DEBUG) 1671 cout << "Looses to better candidate" << endl; 1672 1691 if (DEBUG) 1692 { 1693 cout << Verbose(3) << *Candidate << " looses against better candidate " << *Opt_Candidate << "." << endl; 1694 } 1673 1695 } 1674 1696 } … … 1676 1698 else 1677 1699 { 1678 //if (DEBUG) 1679 cout << "Refused due to bad direction of ball centre." << endl; 1700 if (DEBUG) 1701 { 1702 cout << Verbose(3) << *Candidate << " refused due to Up/Down sign which is " << sign << endl; 1703 } 1680 1704 } 1681 1705 } 1682 1706 else 1683 1707 { 1684 //if (DEBUG) 1685 cout << "Doesn't satisfy requirements for circumscribing circle" << endl; 1708 if (DEBUG) 1709 { 1710 cout << Verbose(3) << *Candidate << " would have circumference of " << Umkreisradius << " bigger than ball's radius " << RADIUS << "." << endl; 1711 } 1686 1712 } 1687 1713 } 1688 1714 else 1689 1715 { 1690 //if (DEBUG) 1691 cout << "identisch mit Ursprungslinie" << endl; 1692 1716 if (DEBUG) 1717 { 1718 cout << Verbose(3) << *Candidate << " is either " << *a << " or " << *b << "." << endl; 1719 } 1693 1720 } 1694 1721 … … 1713 1740 } 1714 1741 } 1742 cout << Verbose(2) << "End of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n"; 1715 1743 } 1716 1744 ; … … 1834 1862 d1->ProjectOntoPlane(&AngleCheckReference); 1835 1863 sign = AngleCheck.ScalarProduct(d1); 1836 sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction... 1864 if (fabs(sign) < MYEPSILON) 1865 sign = 0; 1866 else 1867 sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction... 1837 1868 1838 1869 … … 1991 2022 const double& RADIUS, int N, const char *tempbasename) 1992 2023 { 1993 cout << Verbose(1) << " Looking for next suitable triangle\n";2024 cout << Verbose(1) << "Begin of Find_next_suitable_triangle\n"; 1994 2025 Vector direction1; 1995 2026 Vector helper; … … 2008 2039 Vector Opt_Mittelpunkt; 2009 2040 2010 cout << Verbose(1) << "Constructing helpful vectors ... " << endl; 2041 cout << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl; 2042 2011 2043 helper.CopyVector(&(Line.endpoints[0]->node->x)); 2012 2044 for (int i = 0; i < 3; i++) … … 2029 2061 direction1.Scale(-1); 2030 2062 } 2063 cout << Verbose(2) << "Looking in direction " << direction1 << " for candidates.\n"; 2031 2064 2032 2065 Chord.CopyVector(&(Line.endpoints[0]->node->x)); // bring into calling function 2033 2066 Chord.SubtractVector(&(Line.endpoints[1]->node->x)); 2034 2035 2036 Vector Umkreismittelpunkt, a, b, c; 2037 double alpha, beta, gamma; 2038 a.CopyVector(&(T.endpoints[0]->node->x)); 2039 b.CopyVector(&(T.endpoints[1]->node->x)); 2040 c.CopyVector(&(T.endpoints[2]->node->x)); 2041 a.SubtractVector(&(T.endpoints[1]->node->x)); 2042 b.SubtractVector(&(T.endpoints[2]->node->x)); 2043 c.SubtractVector(&(T.endpoints[0]->node->x)); 2044 2067 cout << Verbose(2) << "Baseline vector is " << Chord << ".\n"; 2068 2069 2070 Vector Umkreismittelpunkt, a, b, c; 2071 double alpha, beta, gamma; 2072 a.CopyVector(&(T.endpoints[0]->node->x)); 2073 b.CopyVector(&(T.endpoints[1]->node->x)); 2074 c.CopyVector(&(T.endpoints[2]->node->x)); 2075 a.SubtractVector(&(T.endpoints[1]->node->x)); 2076 b.SubtractVector(&(T.endpoints[2]->node->x)); 2077 c.SubtractVector(&(T.endpoints[0]->node->x)); 2078 2079 // alpha = a.Angle(&c) - M_PI/2.; 2080 // beta = b.Angle(&a); 2081 // gamma = c.Angle(&b) - M_PI/2.; 2045 2082 alpha = M_PI - a.Angle(&c); 2046 2083 beta = M_PI - b.Angle(&a); 2047 2084 gamma = M_PI - c.Angle(&b); 2085 if (fabs(M_PI - alpha - beta - gamma) > MYEPSILON) 2086 cerr << Verbose(0) << "WARNING: sum of angles for candidate triangle " << (alpha + beta + gamma)/M_PI*180. << " != 180.\n"; 2048 2087 2049 2088 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) ; … … 2054 2093 cout << " Old Normal is " << (T.NormalVector.x)[0] << " " << T.NormalVector.x[1] << " " << (T.NormalVector.x)[2] << " " << endl; 2055 2094 2095 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; 2096 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) ; 2097 Umkreismittelpunkt.Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma))); 2098 cout << Verbose(2) << "Center of circumference is " << Umkreismittelpunkt << "." << endl; 2099 if (DEBUG) 2100 cout << Verbose(3) << "Check of relative endpoints (same distance, equally spreaded): "<< endl; 2101 tmp = 0; 2102 for (int i=0;i<NDIM;i++) { 2103 helper.CopyVector(&T.endpoints[i]->node->x); 2104 helper.SubtractVector(&Umkreismittelpunkt); 2105 if (DEBUG) 2106 cout << Verbose(3) << "Endpoint[" << i << "]: " << helper << " with length " << helper.Norm() << "." << endl; 2107 if (tmp == 0) // set on first time for comparison against next ones 2108 tmp = helper.Norm(); 2109 if (fabs(helper.Norm() - tmp) > MYEPSILON) 2110 cerr << Verbose(1) << "WARNING: center of circumference is wrong!" << endl; 2111 } 2056 2112 2057 2113 cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl; … … 2097 2153 // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke 2098 2154 2099 cout << " Optimal candidate is " << *Opt_Candidate << endl; 2155 cout << Verbose(2) << " Optimal candidate is " << *Opt_Candidate << endl; 2156 2157 // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2) 2100 2158 2101 2159 AddTrianglePoint(Opt_Candidate, 0); 2102 AddTrianglePoint(Line.endpoints[0]->node, 1); 2103 AddTrianglePoint(Line.endpoints[1]->node, 2); 2104 2105 AddTriangleLine(TPS[0], TPS[1], 0); 2106 AddTriangleLine(TPS[0], TPS[2], 1); 2107 AddTriangleLine(TPS[1], TPS[2], 2); 2108 2109 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2110 AddTriangleToLines(); 2111 cout << "New triangle with " << *BTS << endl; 2112 cout << "We have "<< TrianglesOnBoundaryCount << endl; 2113 cout << Verbose(1) << "Constructing normal vector for this triangle ... " << endl; 2114 2115 BTS->GetNormalVector(BTS->NormalVector); 2116 2117 if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0) || 2118 (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0) || 2119 (fabs(Storage[0]) < MYEPSILON && Storage[1]*BTS->NormalVector.ScalarProduct(&direction1) < 0) ) 2120 2121 { 2122 BTS->NormalVector.Scale(-1); 2123 }; 2124 2160 LineMap::iterator TryAndError; 2161 TryAndError = TPS[0]->lines.find(Line.endpoints[0]->node->nr); 2162 bool flag = true; 2163 if ((TryAndError != TPS[0]->lines.end()) && (TryAndError->second->TrianglesCount > 1)) 2164 flag = false; 2165 TryAndError = TPS[0]->lines.find(Line.endpoints[1]->node->nr); 2166 if ((TryAndError != TPS[0]->lines.end()) && (TryAndError->second->TrianglesCount > 1)) 2167 flag = false; 2168 2169 if (flag) { // if so, add 2170 AddTrianglePoint(Line.endpoints[0]->node, 1); 2171 AddTrianglePoint(Line.endpoints[1]->node, 2); 2172 2173 AddTriangleLine(TPS[0], TPS[1], 0); 2174 AddTriangleLine(TPS[0], TPS[2], 1); 2175 AddTriangleLine(TPS[1], TPS[2], 2); 2176 2177 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 2178 AddTriangleToLines(); 2179 2180 BTS->GetNormalVector(BTS->NormalVector); 2181 2182 if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0) || 2183 (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0) || 2184 (fabs(Storage[0]) < MYEPSILON && Storage[1]*BTS->NormalVector.ScalarProduct(&direction1) < 0) ) 2185 2186 { 2187 BTS->NormalVector.Scale(-1); 2188 }; 2189 cout << Verbose(2) << "New triangle with " << *BTS << "and normal vector " << BTS->NormalVector << " for this triangle ... " << endl; 2190 cout << Verbose(2) << "We have "<< TrianglesOnBoundaryCount << " for line " << Line << "." << endl; 2191 } else { // else, yell and do nothing 2192 cout << Verbose(2) << "This triangle consisting of "; 2193 for (int i=0;i<NDIM;i++) 2194 cout << BLS[i] << "(" << BLS[i]->TrianglesCount << "), "; 2195 cout << " is invalid!" << endl; 2196 } 2197 cout << Verbose(1) << "End of Find_next_suitable_triangle\n"; 2125 2198 } 2126 2199 ; … … 2130 2203 molecule* mol, double RADIUS) 2131 2204 { 2132 cout << Verbose( 1)2133 << " Looking for second point of starting triangle, recursive level "2134 << RecursionLevel << endl; ;2205 cout << Verbose(2) 2206 << "Begin of Find_second_point_for_Tesselation, recursive level " 2207 << RecursionLevel << endl; 2135 2208 int i; 2136 2209 Vector AngleCheck; 2137 2210 atom* Walker; 2138 double norm = -1. ;2211 double norm = -1., angle; 2139 2212 2140 2213 // check if we only have one unique point yet ... 2141 2214 if (a != Candidate) 2142 2215 { 2216 cout << Verbose(3) << "Current candidate is " << *Candidate << ": "; 2143 2217 AngleCheck.CopyVector(&(Candidate->x)); 2144 2218 AngleCheck.SubtractVector(&(a->x)); … … 2147 2221 if (norm < RADIUS) 2148 2222 { 2149 if (AngleCheck.Angle(&Oben) < Storage[0]) 2223 angle = AngleCheck.Angle(&Oben); 2224 if (angle < Storage[0]) 2150 2225 { 2151 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[2]); 2152 cout << "Next better candidate is " << *Candidate 2153 << " with distance " << norm << ".\n"; 2226 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 2227 cout << "Is a better candidate with distance " << norm << " and " << angle << ".\n"; 2154 2228 Opt_Candidate = Candidate; 2155 2229 Storage[0] = AngleCheck.Angle(&Oben); … … 2158 2232 else 2159 2233 { 2160 cout << Verbose(1) << "Supposedly loosesto a better candidate "2234 cout << "Looses with angle " << angle << " to a better candidate " 2161 2235 << *Opt_Candidate << endl; 2162 2236 } … … 2164 2238 else 2165 2239 { 2166 cout << Verbose(1) << *Candidate << " refused due to Radius " << norm2240 cout << "Refused due to Radius " << norm 2167 2241 << endl; 2168 2242 } … … 2183 2257 }; 2184 2258 }; 2259 cout << Verbose(2) << "End of Find_second_point_for_Tesselation, recursive level " 2260 << RecursionLevel << endl; 2185 2261 } 2186 2262 ; … … 2188 2264 void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS) 2189 2265 { 2190 cout << Verbose(1) << " Looking for starting triangle\n";2266 cout << Verbose(1) << "Begin of Find_starting_triangle\n"; 2191 2267 int i = 0; 2192 2268 atom* Walker; 2193 2269 atom* FirstPoint; 2194 2270 atom* SecondPoint; 2195 atom* max_index[ 3];2196 double max_coordinate[ 3];2271 atom* max_index[NDIM]; 2272 double max_coordinate[NDIM]; 2197 2273 Vector Oben; 2198 2274 Vector helper; … … 2207 2283 max_coordinate[i] = -1; 2208 2284 } 2209 cout << Verbose( 1) << "Molecule mol is there and has " << mol->AtomCount2285 cout << Verbose(2) << "Molecule mol is there and has " << mol->AtomCount 2210 2286 << " Atoms \n"; 2211 2287 … … 2225 2301 } 2226 2302 2227 cout << Verbose(1) << "Found maximum coordinates. " << endl; 2303 cout << Verbose(2) << "Found maximum coordinates: "; 2304 for (int i=0;i<NDIM;i++) 2305 cout << i << ": " << *max_index[i] << "\t"; 2306 cout << endl; 2228 2307 //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0 2229 2308 const int k = 1; … … 2231 2310 FirstPoint = max_index[k]; 2232 2311 2233 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << ": " 2234 << FirstPoint->x.x[0] << endl; 2312 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << " with " << mol->NumberOfBondsPerAtom[FirstPoint->nr] << " bonds." << endl; 2235 2313 double Storage[3]; 2236 2314 atom* Opt_Candidate = NULL; … … 2238 2316 Storage[1] = 999999.; // This will be an angle looking for the third point. 2239 2317 Storage[2] = 999999.; 2240 cout << Verbose(1) << "Number of Bonds: "2241 << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl;2242 2318 2243 2319 Find_second_point_for_Tesselation(FirstPoint, FirstPoint, FirstPoint, 0, 2244 2320 Oben, Opt_Candidate, Storage, mol, RADIUS); // we give same point as next candidate as its bonds are looked into in find_second_... 2245 2321 SecondPoint = Opt_Candidate; 2246 cout << Verbose(1) << "Found second point is " << *SecondPoint << " .\n";2322 cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n"; 2247 2323 2248 2324 helper.CopyVector(&(FirstPoint->x)); … … 2260 2336 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 2261 2337 2262 cout << Verbose(1) << "Looking for third point candidates \n"; 2263 cout << Verbose(1) << " In direction " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << " " << endl; 2338 cout << Verbose(2) << "Looking for third point candidates \n"; 2264 2339 // look in one direction of baseline for initial candidate 2265 2340 Opt_Candidate = NULL; … … 2268 2343 CenterOfFirstLine.AddVector(&(SecondPoint->x)); 2269 2344 2345 cout << Verbose(1) << "Looking for third point candidates from " << *FirstPoint << " onward ...\n"; 2270 2346 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, SecondPoint, FirstPoint, 0, 2271 2347 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); 2272 2348 // look in other direction of baseline for possible better candidate 2349 cout << Verbose(1) << "Looking for third point candidates from " << *SecondPoint << " onward ...\n"; 2273 2350 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, SecondPoint, 0, 2274 2351 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); … … 2276 2353 2277 2354 // FOUND Starting Triangle: FirstPoint, SecondPoint, Opt_Candidate 2278 2279 cout << Verbose(1) << "The found starting triangle consists of "2280 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate2281 << "." << endl;2282 2355 2283 2356 // Finally, we only have to add the found points … … 2295 2368 Oben.Scale(-1.); 2296 2369 BTS->GetNormalVector(Oben); 2370 cout << Verbose(0) << "==> The found starting triangle consists of " 2371 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate 2372 << " with normal vector " << BTS->NormalVector << ".\n"; 2373 cout << Verbose(1) << "End of Find_starting_triangle\n"; 2297 2374 } 2298 2375 ; … … 2311 2388 2312 2389 baseline = Tess->LinesOnBoundary.begin(); 2313 while ( baseline != Tess->LinesOnBoundary.end())2390 while ((baseline != Tess->LinesOnBoundary.end()) || (flag)) 2314 2391 { 2315 2392 if (baseline->second->TrianglesCount == 1) 2316 2393 { 2317 cout << Verbose(1) << "Begin of Tesselation ... " << endl;2318 2394 Tess->Find_next_suitable_triangle(out, mol, 2319 2395 *(baseline->second), 2320 2396 *(((baseline->second->triangles.begin()))->second), RADIUS, N, filename); //the line is there, so there is a triangle, but only one. 2321 2397 flag = true; 2322 cout << Verbose(1) << "End of Tesselation ... " << endl;2323 2398 } 2324 2399 else 2325 2400 { 2326 cout << Verbose(1) << " There is a line with"2401 cout << Verbose(1) << "Line " << baseline->second << " has " 2327 2402 << baseline->second->TrianglesCount << " triangles adjacent" 2328 2403 << endl; … … 2330 2405 N++; 2331 2406 baseline++; 2407 if ((baseline == Tess->LinesOnBoundary.end()) && (flag)) { 2408 baseline = Tess->LinesOnBoundary.begin(); // restart if we reach end due to newly inserted lines 2409 flag = false; 2410 } 2332 2411 } 2333 2412 cout << Verbose(1) << "Writing final tecplot file\n"; … … 2346 2425 raster.close(); 2347 2426 } 2348 } 2349 ; 2427 2428 cout << Verbose(0) << "End of Find_non_convex_border\n"; 2429 } 2430 ; 2431 -
src/vector.cpp
r6d4a76 r12298c 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
r6d4a76 r12298c 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.