Changeset 6d4a76 for src/boundary.cpp
- Timestamp:
- Dec 29, 2008, 12:29:21 PM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- e1bc68
- Parents:
- 12298c (diff), 23e09b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r12298c r6d4a76 1414 1414 LineMap::iterator LineWalker; 1415 1415 //cout << "Manually checking endpoints for line." << endl; 1416 if ((a->lines.find(b->node->nr)) != a->lines.end()) //->first == b->node->nr)1416 if ((a->lines.find(b->node->nr))->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 circumference1482 1481 * @param Direction vector indicates up/down 1483 1482 * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle … … 1491 1490 */ 1492 1491 1493 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector *NewUmkreismittelpunkt, Vector* Direction, Vector* AlternativeDirection,1492 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector* Direction, Vector* AlternativeDirection, 1494 1493 double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius) 1495 1494 { 1496 1495 Vector TempNormal, helper; 1497 1496 double Restradius; 1498 cout << Verbose(3) << "Begin of Get_center_of_sphere.\n"; 1497 1499 1498 *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ; 1500 1499 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";1503 1500 // Here we calculated center of circumscribing circle, using barycentric coordinates 1504 cout << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";1505 1501 1506 1502 TempNormal.CopyVector(&a); … … 1526 1522 TempNormal.Normalize(); 1527 1523 Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius); 1528 cout << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";1529 1524 TempNormal.Scale(Restradius); 1530 cout << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";1531 1525 1532 1526 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";1535 1527 } 1536 1528 ; … … 1565 1557 atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol) 1566 1558 { 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; 1559 //cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl; 1573 1560 /* OldNormal is normal vector on the old triangle 1574 1561 * direction1 is normal on the triangle line, from which we come, as well as on OldNormal. … … 1586 1573 atom *Walker; // variable atom point 1587 1574 1588 Vector NewUmkreismittelpunkt; 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); 1589 1592 1590 1593 1591 1594 if (a != Candidate and b != Candidate and c != Candidate) 1592 1595 { 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";1615 1596 1616 1597 Umkreisradius = SideA / 2.0 / sin(alpha); … … 1621 1602 if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points. 1622 1603 { 1623 cout << Verbose(3) << "Circle of circumference would fit: " << Umkreisradius << " < " << RADIUS << "." << endl; 1624 cout << Verbose(2) << "Candidate is "<< *Candidate << endl; 1604 cout << Verbose(1) << "Candidate is "<< *Candidate << endl; 1625 1605 sign = AngleCheck.ScalarProduct(direction1); 1626 1606 if (fabs(sign)<MYEPSILON) … … 1640 1620 { 1641 1621 sign /= fabs(sign); 1642 cout << Verbose(3) << "Candidate is in search direction: " << sign << "." << endl;1643 1622 } 1644 1623 1645 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), &NewUmkreismittelpunkt, OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1624 1625 1626 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1646 1627 1647 1628 AngleCheck.CopyVector(&ReferencePoint); … … 1650 1631 AngleCheck.AddVector(&Mittelpunkt); 1651 1632 //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;1653 1633 1654 1634 BallAngle = AngleCheck.Angle(OldNormal); 1655 cout << Verbose(3) << "Angle between normal of base triangle and center of ball sphere is :" << BallAngle << "." << endl;1656 1635 1657 1636 //cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl; 1658 1637 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1659 1638 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)) 1639 cout << Verbose(1) << "BallAngle is " << BallAngle << " Sign is " << sign << endl; 1640 1641 if (AngleCheck.ScalarProduct(direction1) >=0) 1665 1642 { 1666 1643 if (Storage[0]< -1.5) // first Candidate at all 1667 1644 { 1668 1645 1669 cout << Verbose(2) << "First goodcandidate is " << *Candidate << " with ";1646 cout << "Next better candidate is " << *Candidate << " with "; 1670 1647 Opt_Candidate = Candidate; 1671 1648 Storage[0] = sign; 1672 1649 Storage[1] = AlternativeSign; 1673 1650 Storage[2] = BallAngle; 1674 cout << " angle " << Storage[2] << " and Up/Down"1651 cout << "Angle is " << Storage[2] << ", Halbraum ist " 1675 1652 << Storage[0] << endl; 1653 1654 1676 1655 } 1677 1656 else … … 1679 1658 if ( Storage[2] > BallAngle) 1680 1659 { 1681 cout << Verbose(2) <<"Next better candidate is " << *Candidate << " with ";1660 cout << "Next better candidate is " << *Candidate << " with "; 1682 1661 Opt_Candidate = Candidate; 1683 1662 Storage[0] = sign; 1684 1663 Storage[1] = AlternativeSign; 1685 1664 Storage[2] = BallAngle; 1686 cout << " angle " << Storage[2] << " and Up/Down"1665 cout << "Angle is " << Storage[2] << ", Halbraum ist " 1687 1666 << Storage[0] << endl; 1688 1667 } 1689 1668 else 1690 1669 { 1691 if (DEBUG) 1692 { 1693 cout << Verbose(3) << *Candidate << " looses against better candidate " << *Opt_Candidate << "." << endl; 1694 } 1670 //if (DEBUG) 1671 cout << "Looses to better candidate" << endl; 1672 1695 1673 } 1696 1674 } … … 1698 1676 else 1699 1677 { 1700 if (DEBUG) 1701 { 1702 cout << Verbose(3) << *Candidate << " refused due to Up/Down sign which is " << sign << endl; 1703 } 1678 //if (DEBUG) 1679 cout << "Refused due to bad direction of ball centre." << endl; 1704 1680 } 1705 1681 } 1706 1682 else 1707 1683 { 1708 if (DEBUG) 1709 { 1710 cout << Verbose(3) << *Candidate << " would have circumference of " << Umkreisradius << " bigger than ball's radius " << RADIUS << "." << endl; 1711 } 1684 //if (DEBUG) 1685 cout << "Doesn't satisfy requirements for circumscribing circle" << endl; 1712 1686 } 1713 1687 } 1714 1688 else 1715 1689 { 1716 if (DEBUG) 1717 { 1718 cout << Verbose(3) << *Candidate << " is either " << *a << " or " << *b << "." << endl; 1719 } 1690 //if (DEBUG) 1691 cout << "identisch mit Ursprungslinie" << endl; 1692 1720 1693 } 1721 1694 … … 1740 1713 } 1741 1714 } 1742 cout << Verbose(2) << "End of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n";1743 1715 } 1744 1716 ; … … 1862 1834 d1->ProjectOntoPlane(&AngleCheckReference); 1863 1835 sign = AngleCheck.ScalarProduct(d1); 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... 1836 sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction... 1868 1837 1869 1838 … … 2022 1991 const double& RADIUS, int N, const char *tempbasename) 2023 1992 { 2024 cout << Verbose(1) << " Begin of Find_next_suitable_triangle\n";1993 cout << Verbose(1) << "Looking for next suitable triangle \n"; 2025 1994 Vector direction1; 2026 1995 Vector helper; … … 2039 2008 Vector Opt_Mittelpunkt; 2040 2009 2041 cout << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl; 2042 2010 cout << Verbose(1) << "Constructing helpful vectors ... " << endl; 2043 2011 helper.CopyVector(&(Line.endpoints[0]->node->x)); 2044 2012 for (int i = 0; i < 3; i++) … … 2061 2029 direction1.Scale(-1); 2062 2030 } 2063 cout << Verbose(2) << "Looking in direction " << direction1 << " for candidates.\n";2064 2031 2065 2032 Chord.CopyVector(&(Line.endpoints[0]->node->x)); // bring into calling function 2066 2033 Chord.SubtractVector(&(Line.endpoints[1]->node->x)); 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.; 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 2082 2045 alpha = M_PI - a.Angle(&c); 2083 2046 beta = M_PI - b.Angle(&a); 2084 2047 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";2087 2048 2088 2049 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) ; … … 2093 2054 cout << " Old Normal is " << (T.NormalVector.x)[0] << " " << T.NormalVector.x[1] << " " << (T.NormalVector.x)[2] << " " << endl; 2094 2055 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 ones2108 tmp = helper.Norm();2109 if (fabs(helper.Norm() - tmp) > MYEPSILON)2110 cerr << Verbose(1) << "WARNING: center of circumference is wrong!" << endl;2111 }2112 2056 2113 2057 cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl; … … 2153 2097 // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke 2154 2098 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) 2099 cout << " Optimal candidate is " << *Opt_Candidate << endl; 2158 2100 2159 2101 AddTrianglePoint(Opt_Candidate, 0); 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"; 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 2198 2125 } 2199 2126 ; … … 2203 2130 molecule* mol, double RADIUS) 2204 2131 { 2205 cout << Verbose( 2)2206 << " Begin of Find_second_point_for_Tesselation, recursive level "2207 << RecursionLevel << endl; 2132 cout << Verbose(1) 2133 << "Looking for second point of starting triangle, recursive level " 2134 << RecursionLevel << endl;; 2208 2135 int i; 2209 2136 Vector AngleCheck; 2210 2137 atom* Walker; 2211 double norm = -1. , angle;2138 double norm = -1.; 2212 2139 2213 2140 // check if we only have one unique point yet ... 2214 2141 if (a != Candidate) 2215 2142 { 2216 cout << Verbose(3) << "Current candidate is " << *Candidate << ": ";2217 2143 AngleCheck.CopyVector(&(Candidate->x)); 2218 2144 AngleCheck.SubtractVector(&(a->x)); … … 2221 2147 if (norm < RADIUS) 2222 2148 { 2223 angle = AngleCheck.Angle(&Oben); 2224 if (angle < Storage[0]) 2149 if (AngleCheck.Angle(&Oben) < Storage[0]) 2225 2150 { 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"; 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"; 2228 2154 Opt_Candidate = Candidate; 2229 2155 Storage[0] = AngleCheck.Angle(&Oben); … … 2232 2158 else 2233 2159 { 2234 cout << "Looses with angle " << angle << "to a better candidate "2160 cout << Verbose(1) << "Supposedly looses to a better candidate " 2235 2161 << *Opt_Candidate << endl; 2236 2162 } … … 2238 2164 else 2239 2165 { 2240 cout << "Refused due to Radius " << norm2166 cout << Verbose(1) << *Candidate << " refused due to Radius " << norm 2241 2167 << endl; 2242 2168 } … … 2257 2183 }; 2258 2184 }; 2259 cout << Verbose(2) << "End of Find_second_point_for_Tesselation, recursive level "2260 << RecursionLevel << endl;2261 2185 } 2262 2186 ; … … 2264 2188 void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS) 2265 2189 { 2266 cout << Verbose(1) << " Begin of Find_starting_triangle\n";2190 cout << Verbose(1) << "Looking for starting triangle \n"; 2267 2191 int i = 0; 2268 2192 atom* Walker; 2269 2193 atom* FirstPoint; 2270 2194 atom* SecondPoint; 2271 atom* max_index[ NDIM];2272 double max_coordinate[ NDIM];2195 atom* max_index[3]; 2196 double max_coordinate[3]; 2273 2197 Vector Oben; 2274 2198 Vector helper; … … 2283 2207 max_coordinate[i] = -1; 2284 2208 } 2285 cout << Verbose( 2) << "Molecule mol is there and has " << mol->AtomCount2209 cout << Verbose(1) << "Molecule mol is there and has " << mol->AtomCount 2286 2210 << " Atoms \n"; 2287 2211 … … 2301 2225 } 2302 2226 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; 2227 cout << Verbose(1) << "Found maximum coordinates. " << endl; 2307 2228 //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0 2308 2229 const int k = 1; … … 2310 2231 FirstPoint = max_index[k]; 2311 2232 2312 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << " with " << mol->NumberOfBondsPerAtom[FirstPoint->nr] << " bonds." << endl; 2233 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << ": " 2234 << FirstPoint->x.x[0] << endl; 2313 2235 double Storage[3]; 2314 2236 atom* Opt_Candidate = NULL; … … 2316 2238 Storage[1] = 999999.; // This will be an angle looking for the third point. 2317 2239 Storage[2] = 999999.; 2240 cout << Verbose(1) << "Number of Bonds: " 2241 << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl; 2318 2242 2319 2243 Find_second_point_for_Tesselation(FirstPoint, FirstPoint, FirstPoint, 0, 2320 2244 Oben, Opt_Candidate, Storage, mol, RADIUS); // we give same point as next candidate as its bonds are looked into in find_second_... 2321 2245 SecondPoint = Opt_Candidate; 2322 cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n";2246 cout << Verbose(1) << "Found second point is " << *SecondPoint << ".\n"; 2323 2247 2324 2248 helper.CopyVector(&(FirstPoint->x)); … … 2336 2260 // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized) 2337 2261 2338 cout << Verbose(2) << "Looking for third point candidates \n"; 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; 2339 2264 // look in one direction of baseline for initial candidate 2340 2265 Opt_Candidate = NULL; … … 2343 2268 CenterOfFirstLine.AddVector(&(SecondPoint->x)); 2344 2269 2345 cout << Verbose(1) << "Looking for third point candidates from " << *FirstPoint << " onward ...\n";2346 2270 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, SecondPoint, FirstPoint, 0, 2347 2271 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); 2348 2272 // look in other direction of baseline for possible better candidate 2349 cout << Verbose(1) << "Looking for third point candidates from " << *SecondPoint << " onward ...\n";2350 2273 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, SecondPoint, 0, 2351 2274 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); … … 2353 2276 2354 2277 // FOUND Starting Triangle: FirstPoint, SecondPoint, Opt_Candidate 2278 2279 cout << Verbose(1) << "The found starting triangle consists of " 2280 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate 2281 << "." << endl; 2355 2282 2356 2283 // Finally, we only have to add the found points … … 2368 2295 Oben.Scale(-1.); 2369 2296 BTS->GetNormalVector(Oben); 2370 cout << Verbose(0) << "==> The found starting triangle consists of "2371 << *FirstPoint << ", " << *SecondPoint << " and " << *Opt_Candidate2372 << " with normal vector " << BTS->NormalVector << ".\n";2373 cout << Verbose(1) << "End of Find_starting_triangle\n";2374 2297 } 2375 2298 ; … … 2388 2311 2389 2312 baseline = Tess->LinesOnBoundary.begin(); 2390 while ( (baseline != Tess->LinesOnBoundary.end()) || (flag))2313 while (baseline != Tess->LinesOnBoundary.end()) 2391 2314 { 2392 2315 if (baseline->second->TrianglesCount == 1) 2393 2316 { 2317 cout << Verbose(1) << "Begin of Tesselation ... " << endl; 2394 2318 Tess->Find_next_suitable_triangle(out, mol, 2395 2319 *(baseline->second), 2396 2320 *(((baseline->second->triangles.begin()))->second), RADIUS, N, filename); //the line is there, so there is a triangle, but only one. 2397 2321 flag = true; 2322 cout << Verbose(1) << "End of Tesselation ... " << endl; 2398 2323 } 2399 2324 else 2400 2325 { 2401 cout << Verbose(1) << " Line " << baseline->second << " has"2326 cout << Verbose(1) << "There is a line with " 2402 2327 << baseline->second->TrianglesCount << " triangles adjacent" 2403 2328 << endl; … … 2405 2330 N++; 2406 2331 baseline++; 2407 if ((baseline == Tess->LinesOnBoundary.end()) && (flag)) {2408 baseline = Tess->LinesOnBoundary.begin(); // restart if we reach end due to newly inserted lines2409 flag = false;2410 }2411 2332 } 2412 2333 cout << Verbose(1) << "Writing final tecplot file\n"; … … 2425 2346 raster.close(); 2426 2347 } 2427 2428 cout << Verbose(0) << "End of Find_non_convex_border\n"; 2429 } 2430 ; 2431 2348 } 2349 ;
Note:
See TracChangeset
for help on using the changeset viewer.