Changes in / [196a5a:02bfde]


Ignore:
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r196a5a r02bfde  
    22#include "boundary.hpp"
    33
    4 #define DEBUG 0
     4#define DEBUG 1
    55
    66// ======================================== Points on Boundary =================================
     
    13561356  LineMap::iterator LineWalker;
    13571357  //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)
    13591359  //If a line is there, how do I recognize that beyond a shadow of a doubt?
    13601360    {
     
    14211421 * @param b vector second point of triangle
    14221422 * @param c vector third point of triangle
     1423 * @param *Umkreismittelpunkt new cneter point of circumference
    14231424 * @param Direction vector indicates up/down
    14241425 * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle
     
    14321433 */
    14331434
    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,
    14351436      double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius)
    14361437  {
    14371438    Vector TempNormal, helper;
    14381439    double Restradius;
    1439 
     1440    cout << Verbose(3) << "Begin of Get_center_of_sphere.\n";
    14401441    *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ;
    14411442    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";
    14421445    // Here we calculated center of circumscribing circle, using barycentric coordinates
     1446    cout << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
    14431447
    14441448    TempNormal.CopyVector(&a);
     
    14641468    TempNormal.Normalize();
    14651469    Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
     1470    cout << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";
    14661471    TempNormal.Scale(Restradius);
     1472    cout << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
    14671473
    14681474    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";
    14691477  }
    14701478  ;
     
    14991507    atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol)
    15001508{
    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;
    15021515  /* OldNormal is normal vector on the old triangle
    15031516   * direction1 is normal on the triangle line, from which we come, as well as on OldNormal.
     
    15151528  atom *Walker; // variable atom point
    15161529
    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;
    15341531
    15351532
    15361533  if (a != Candidate and b != Candidate and c != Candidate)
    15371534    {
     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";
    15381557
    15391558      Umkreisradius = SideA / 2.0 / sin(alpha);
     
    15441563      if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points.
    15451564        {
    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;
    15471567          sign = AngleCheck.ScalarProduct(direction1);
    15481568          if (fabs(sign)<MYEPSILON)
     
    15621582            {
    15631583              sign /= fabs(sign);
     1584              cout << Verbose(3) << "Candidate is in search direction: " << sign << "." << endl;
    15641585            }
    15651586
    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);
    15691588
    15701589          AngleCheck.CopyVector(&ReferencePoint);
     
    15731592          AngleCheck.AddVector(&Mittelpunkt);
    15741593          //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;
    15751595
    15761596          BallAngle = AngleCheck.Angle(OldNormal);
     1597          cout << Verbose(3) << "Angle between normal of base triangle and center of ball sphere is :" << BallAngle << "." << endl;
    15771598
    15781599          //cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl;
    15791600          //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
    15801601
    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))
    15841607            {
    15851608              if (Storage[0]< -1.5) // first Candidate at all
    15861609                {
    15871610
    1588                   cout << "Next better candidate is " << *Candidate << " with ";
     1611                  cout << Verbose(2) << "First good candidate is " << *Candidate << " with ";
    15891612                  Opt_Candidate = Candidate;
    15901613                  Storage[0] = sign;
    15911614                  Storage[1] = AlternativeSign;
    15921615                  Storage[2] = BallAngle;
    1593                   cout << "Angle is " << Storage[2] << ", Halbraum ist "
     1616                  cout << " angle " << Storage[2] << " and Up/Down "
    15941617                    << Storage[0] << endl;
    1595 
    1596 
    15971618                }
    15981619              else
     
    16001621                  if ( Storage[2] > BallAngle)
    16011622                    {
    1602                       cout << "Next better candidate is " << *Candidate << " with ";
     1623                      cout << Verbose(2) << "Next better candidate is " << *Candidate << " with ";
    16031624                      Opt_Candidate = Candidate;
    16041625                      Storage[0] = sign;
    16051626                      Storage[1] = AlternativeSign;
    16061627                      Storage[2] = BallAngle;
    1607                       cout << "Angle is " << Storage[2] << ", Halbraum ist "
     1628                      cout << " angle " << Storage[2] << " and Up/Down "
    16081629                        << Storage[0] << endl;
    16091630                    }
    16101631                  else
    16111632                    {
    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                        }
    16151637                    }
    16161638                }
     
    16181640            else
    16191641              {
    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                }
    16221646              }
    16231647          }
    16241648        else
    16251649          {
    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              }
    16281654          }
    16291655      }
    16301656    else
    16311657      {
    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          }
    16351662      }
    16361663
     
    16551682        }
    16561683    }
     1684  cout << Verbose(2) << "End of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n";
    16571685}
    16581686;
     
    17761804          d1->ProjectOntoPlane(&AngleCheckReference);
    17771805          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...
    17791810
    17801811
     
    19341965    const double& RADIUS, int N)
    19351966{
    1936   cout << Verbose(1) << "Looking for next suitable triangle \n";
     1967  cout << Verbose(1) << "Begin of Find_next_suitable_triangle\n";
    19371968  Vector direction1;
    19381969  Vector helper;
     
    19401971  ofstream *tempstream = NULL;
    19411972  char filename[255];
     1973  double tmp;
     1974  //atom* Walker;
    19421975  atom* OldThirdPoint;
    19431976
     
    19491982  Vector Opt_Mittelpunkt;
    19501983
    1951   cout << Verbose(1) << "Constructing helpful vectors ... " << endl;
     1984  cout << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl;
     1985
    19521986  helper.CopyVector(&(Line.endpoints[0]->node->x));
    19531987  for (int i = 0; i < 3; i++)
     
    19702004      direction1.Scale(-1);
    19712005    }
     2006  cout << Verbose(2) << "Looking in direction " << direction1 << " for candidates.\n";
    19722007
    19732008  Chord.CopyVector(&(Line.endpoints[0]->node->x)); // bring into calling function
    19742009  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.;
    19862025    alpha = M_PI - a.Angle(&c);
    19872026    beta = M_PI - b.Angle(&a);
    19882027    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";
    19892030
    19902031    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) ;
     
    19952036    cout << " Old Normal is " <<  (T.NormalVector.x)[0] << " " << T.NormalVector.x[1] << " " << (T.NormalVector.x)[2] << " " << endl;
    19962037
     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  }
    19972055
    19982056  cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl;
     
    20112069  if ((TrianglesOnBoundaryCount % 1) == 0)
    20122070    {
     2071    cout << Verbose(1) << "Writing temporary non convex hull to file testEnvelope-" << TriangleFilesWritten << "d.dat.\n";
    20132072    sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten);
    20142073    tempstream = new ofstream(filename, ios::trunc);
     
    20212080  if (TrianglesOnBoundaryCount >189 and TrianglesOnBoundaryCount < 200 )
    20222081    {
    2023       cout << 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;
    20252084      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;
    20272086    }
    20282087  // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
    20292088
    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)
    20312092
    20322093  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";
    20562132}
    20572133;
     
    20612137    molecule* mol, double RADIUS)
    20622138{
    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;
    20662142  int i;
    20672143  Vector AngleCheck;
    20682144  atom* Walker;
    2069   double norm = -1.;
     2145  double norm = -1., angle;
    20702146
    20712147  // check if we only have one unique point yet ...
    20722148  if (a != Candidate)
    20732149    {
     2150    cout << Verbose(3) << "Current candidate is " << *Candidate << ": ";
    20742151      AngleCheck.CopyVector(&(Candidate->x));
    20752152      AngleCheck.SubtractVector(&(a->x));
     
    20782155      if (norm < RADIUS)
    20792156        {
    2080           if (AngleCheck.Angle(&Oben) < Storage[0])
     2157        angle = AngleCheck.Angle(&Oben);
     2158          if (angle < Storage[0])
    20812159            {
    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";
    20852162              Opt_Candidate = Candidate;
    20862163              Storage[0] = AngleCheck.Angle(&Oben);
     
    20892166          else
    20902167            {
    2091               cout << Verbose(1) << "Supposedly looses to a better candidate "
     2168              cout << "Looses with angle " << angle << " to a better candidate "
    20922169                  << *Opt_Candidate << endl;
    20932170            }
     
    20952172      else
    20962173        {
    2097           cout << Verbose(1) << *Candidate << " refused due to Radius " << norm
     2174          cout << "Refused due to Radius " << norm
    20982175              << endl;
    20992176        }
     
    21142191        };
    21152192    };
     2193  cout << Verbose(2) << "End of Find_second_point_for_Tesselation, recursive level "
     2194      << RecursionLevel << endl;
    21162195}
    21172196;
     
    21192198void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS)
    21202199{
    2121   cout << Verbose(1) << "Looking for starting triangle \n";
     2200  cout << Verbose(1) << "Begin of Find_starting_triangle\n";
    21222201  int i = 0;
    21232202  atom* Walker;
    21242203  atom* FirstPoint;
    21252204  atom* SecondPoint;
    2126   atom* max_index[3];
    2127   double max_coordinate[3];
     2205  atom* max_index[NDIM];
     2206  double max_coordinate[NDIM];
    21282207  Vector Oben;
    21292208  Vector helper;
     
    21382217      max_coordinate[i] = -1;
    21392218    }
    2140   cout << Verbose(1) << "Molecule mol is there and has " << mol->AtomCount
     2219  cout << Verbose(2) << "Molecule mol is there and has " << mol->AtomCount
    21412220      << " Atoms \n";
    21422221
     
    21562235    }
    21572236
    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;
    21592241  //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0
    21602242  const int k = 1;
     
    21622244  FirstPoint = max_index[k];
    21632245
    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;
    21662247  double Storage[3];
    21672248  atom* Opt_Candidate = NULL;
     
    21692250  Storage[1] = 999999.; // This will be an angle looking for the third point.
    21702251  Storage[2] = 999999.;
    2171   cout << Verbose(1) << "Number of Bonds: "
    2172       << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl;
    21732252
    21742253  Find_second_point_for_Tesselation(FirstPoint, FirstPoint, FirstPoint, 0,
    21752254      Oben, Opt_Candidate, Storage, mol, RADIUS); // we give same point as next candidate as its bonds are looked into in find_second_...
    21762255  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";
    21782257
    21792258  helper.CopyVector(&(FirstPoint->x));
     
    21912270  // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized)
    21922271
    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";
    21952273  // look in one direction of baseline for initial candidate
    21962274  Opt_Candidate = NULL;
     
    21992277  CenterOfFirstLine.AddVector(&(SecondPoint->x));
    22002278
     2279  cout << Verbose(1) << "Looking for third point candidates from " << *FirstPoint << " onward ...\n";
    22012280  Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, SecondPoint, FirstPoint, 0,
    22022281      &Chord, &helper, &Oben, CenterOfFirstLine,  Opt_Candidate, Storage, RADIUS, mol);
    22032282  // look in other direction of baseline for possible better candidate
     2283  cout << Verbose(1) << "Looking for third point candidates from " << *SecondPoint << " onward ...\n";
    22042284  Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, SecondPoint, 0,
    22052285      &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol);
     
    22072287
    22082288  // 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;
    22132289
    22142290  // Finally, we only have to add the found points
     
    22262302  Oben.Scale(-1.);
    22272303  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";
    22282308}
    22292309;
     
    22372317  const double RADIUS = 6.;
    22382318  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
    22392322  Tess->Find_starting_triangle(mol, RADIUS);
    22402323
    22412324  baseline = Tess->LinesOnBoundary.begin();
    2242   while (baseline != Tess->LinesOnBoundary.end())
     2325  while ((baseline != Tess->LinesOnBoundary.end()) || (flag))
    22432326    {
    22442327      if (baseline->second->TrianglesCount == 1)
    22452328        {
    2246           cout << Verbose(1) << "Begin of Tesselation ... " << endl;
    22472329          Tess->Find_next_suitable_triangle(out, tecplot, mol,
    22482330              *(baseline->second),
    22492331              *(((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;
    22512333        }
    22522334      else
    22532335        {
    2254           cout << Verbose(1) << "There is a line with "
     2336          cout << Verbose(1) << "Line " << baseline->second << " has "
    22552337              << baseline->second->TrianglesCount << " triangles adjacent"
    22562338              << endl;
     
    22582340      N++;
    22592341      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";
    22612348  write_tecplot_file(out, tecplot, Tess, mol, -1);
    22622349
    2263 }
    2264 ;
     2350  cout << Verbose(0) << "End of Find_non_convex_border\n";
     2351}
     2352;
     2353
  • src/vector.cpp

    r196a5a r02bfde  
    219219 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
    220220 */
    221 double Vector::Angle(Vector *y) const
     221double Vector::Angle(const Vector *y) const
    222222{
    223223  return acos(this->ScalarProduct(y)/Norm()/y->Norm());
     
    313313};
    314314
    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 */
     320ostream& 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 << ")";
    318329        return ost;
    319330};
  • src/vector.hpp

    r196a5a r02bfde  
    2121  double Projection(const Vector *y) const;
    2222  double Norm() const ;
    23   double Angle(Vector *y) const;
     23  double Angle(const Vector *y) const;
    2424
    2525  void AddVector(const Vector *y);
     
    5555};
    5656
    57 ofstream& operator<<(ofstream& ost, Vector& m);
     57ostream & operator << (ostream& ost, Vector &m);
    5858Vector& operator+=(Vector& a, const Vector& b);
    5959Vector& operator*=(Vector& a, const double m);
Note: See TracChangeset for help on using the changeset viewer.