Changes in / [02bfde:196a5a]


Ignore:
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r02bfde r196a5a  
    22#include "boundary.hpp"
    33
    4 #define DEBUG 1
     4#define DEBUG 0
    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)) != a->lines.end()) // ->first == b->node->nr)
     1358  if ((a->lines.find(b->node->nr))->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
    14241423 * @param Direction vector indicates up/down
    14251424 * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle
     
    14331432 */
    14341433
    1435   void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector *NewUmkreismittelpunkt, Vector* Direction, Vector* AlternativeDirection,
     1434  void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector* Direction, Vector* AlternativeDirection,
    14361435      double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius)
    14371436  {
    14381437    Vector TempNormal, helper;
    14391438    double Restradius;
    1440     cout << Verbose(3) << "Begin of Get_center_of_sphere.\n";
     1439
    14411440    *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ;
    14421441    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";
    14451442    // Here we calculated center of circumscribing circle, using barycentric coordinates
    1446     cout << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
    14471443
    14481444    TempNormal.CopyVector(&a);
     
    14681464    TempNormal.Normalize();
    14691465    Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
    1470     cout << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";
    14711466    TempNormal.Scale(Restradius);
    1472     cout << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
    14731467
    14741468    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";
    14771469  }
    14781470  ;
     
    15071499    atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol)
    15081500{
    1509   cout << Verbose(2) << "Begin of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n";
    1510   cout << Verbose(3) << "Candidate is "<< *Candidate << endl;
    1511   cout << Verbose(4) << "Baseline vector is " << *Chord << "." << endl;
    1512   cout << Verbose(4) << "ReferencePoint is " << ReferencePoint << "." << endl;
    1513   cout << Verbose(4) << "Normal of base triangle is " << *OldNormal << "." << endl;
    1514   cout << Verbose(4) << "Search direction is " << *direction1 << "." << endl;
     1501  //cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl;
    15151502  /* OldNormal is normal vector on the old triangle
    15161503   * direction1 is normal on the triangle line, from which we come, as well as on OldNormal.
     
    15281515  atom *Walker; // variable atom point
    15291516
    1530   Vector NewUmkreismittelpunkt;
     1517
     1518  dif_a.CopyVector(&(a->x));
     1519  dif_a.SubtractVector(&(Candidate->x));
     1520  dif_b.CopyVector(&(b->x));
     1521  dif_b.SubtractVector(&(Candidate->x));
     1522  AngleCheck.CopyVector(&(Candidate->x));
     1523  AngleCheck.SubtractVector(&(a->x));
     1524  AngleCheck.ProjectOntoPlane(Chord);
     1525
     1526  SideA = dif_b.Norm();
     1527  SideB = dif_a.Norm();
     1528  SideC = Chord->Norm();
     1529  //Chord->Scale(-1);
     1530
     1531  alpha = Chord->Angle(&dif_a);
     1532  beta = M_PI - Chord->Angle(&dif_b);
     1533  gamma = dif_a.Angle(&dif_b);
    15311534
    15321535
    15331536  if (a != Candidate and b != Candidate and c != Candidate)
    15341537    {
    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";
    15571538
    15581539      Umkreisradius = SideA / 2.0 / sin(alpha);
     
    15631544      if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points.
    15641545        {
    1565           cout << Verbose(3) << "Circle of circumference would fit: " << Umkreisradius << " < " << RADIUS << "." << endl;
    1566           cout << Verbose(2) << "Candidate is "<< *Candidate << endl;
     1546          cout << Verbose(1) << "Candidate is "<< *Candidate << endl;
    15671547          sign = AngleCheck.ScalarProduct(direction1);
    15681548          if (fabs(sign)<MYEPSILON)
     
    15821562            {
    15831563              sign /= fabs(sign);
    1584               cout << Verbose(3) << "Candidate is in search direction: " << sign << "." << endl;
    15851564            }
    15861565
    1587           Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), &NewUmkreismittelpunkt, OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius);
     1566
     1567
     1568          Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius);
    15881569
    15891570          AngleCheck.CopyVector(&ReferencePoint);
     
    15921573          AngleCheck.AddVector(&Mittelpunkt);
    15931574          //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;
    15951575
    15961576          BallAngle = AngleCheck.Angle(OldNormal);
    1597           cout << Verbose(3) << "Angle between normal of base triangle and center of ball sphere is :" << BallAngle << "." << endl;
    15981577
    15991578          //cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl;
    16001579          //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;
    16011580
    1602           cout << Verbose(3) << "BallAngle is " << BallAngle << " Sign is " << sign << endl;
    1603 
    1604           NewUmkreismittelpunkt.SubtractVector(&ReferencePoint);
    1605 
    1606           if ((AngleCheck.ScalarProduct(direction1) >=0) || (fabs(NewUmkreismittelpunkt.Norm()) < MYEPSILON))
     1581          cout << Verbose(1) << "BallAngle is " << BallAngle << " Sign is " << sign << endl;
     1582
     1583          if (AngleCheck.ScalarProduct(direction1) >=0)
    16071584            {
    16081585              if (Storage[0]< -1.5) // first Candidate at all
    16091586                {
    16101587
    1611                   cout << Verbose(2) << "First good candidate is " << *Candidate << " with ";
     1588                  cout << "Next better candidate is " << *Candidate << " with ";
    16121589                  Opt_Candidate = Candidate;
    16131590                  Storage[0] = sign;
    16141591                  Storage[1] = AlternativeSign;
    16151592                  Storage[2] = BallAngle;
    1616                   cout << " angle " << Storage[2] << " and Up/Down "
     1593                  cout << "Angle is " << Storage[2] << ", Halbraum ist "
    16171594                    << Storage[0] << endl;
     1595
     1596
    16181597                }
    16191598              else
     
    16211600                  if ( Storage[2] > BallAngle)
    16221601                    {
    1623                       cout << Verbose(2) << "Next better candidate is " << *Candidate << " with ";
     1602                      cout << "Next better candidate is " << *Candidate << " with ";
    16241603                      Opt_Candidate = Candidate;
    16251604                      Storage[0] = sign;
    16261605                      Storage[1] = AlternativeSign;
    16271606                      Storage[2] = BallAngle;
    1628                       cout << " angle " << Storage[2] << " and Up/Down "
     1607                      cout << "Angle is " << Storage[2] << ", Halbraum ist "
    16291608                        << Storage[0] << endl;
    16301609                    }
    16311610                  else
    16321611                    {
    1633                       if (DEBUG)
    1634                         {
    1635                           cout << Verbose(3) << *Candidate << " looses against better candidate " << *Opt_Candidate << "." << endl;
    1636                         }
     1612                      //if (DEBUG)
     1613                        cout << "Looses to better candidate" << endl;
     1614
    16371615                    }
    16381616                }
     
    16401618            else
    16411619              {
    1642               if (DEBUG)
    1643                 {
    1644                   cout << Verbose(3) << *Candidate << " refused due to Up/Down sign which is " << sign << endl;
    1645                 }
     1620                //if (DEBUG)
     1621                  cout << "Refused due to bad direction of ball centre." << endl;
    16461622              }
    16471623          }
    16481624        else
    16491625          {
    1650             if (DEBUG)
    1651               {
    1652                 cout << Verbose(3) << *Candidate << " would have circumference of " << Umkreisradius << " bigger than ball's radius " << RADIUS << "." << endl;
    1653               }
     1626            //if (DEBUG)
     1627              cout << "Doesn't satisfy requirements for circumscribing circle" << endl;
    16541628          }
    16551629      }
    16561630    else
    16571631      {
    1658         if (DEBUG)
    1659           {
    1660             cout << Verbose(3) << *Candidate << " is either " << *a << " or " << *b << "." << endl;
    1661           }
     1632        //if (DEBUG)
     1633          cout << "identisch mit Ursprungslinie" << endl;
     1634
    16621635      }
    16631636
     
    16821655        }
    16831656    }
    1684   cout << Verbose(2) << "End of Find_next_suitable_point_via_Angle_of_Sphere, recursion level " << RecursionLevel << ".\n";
    16851657}
    16861658;
     
    18041776          d1->ProjectOntoPlane(&AngleCheckReference);
    18051777          sign = AngleCheck.ScalarProduct(d1);
    1806           if (fabs(sign) < MYEPSILON)
    1807             sign = 0;
    1808           else
    1809             sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
     1778          sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
    18101779
    18111780
     
    19651934    const double& RADIUS, int N)
    19661935{
    1967   cout << Verbose(1) << "Begin of Find_next_suitable_triangle\n";
     1936  cout << Verbose(1) << "Looking for next suitable triangle \n";
    19681937  Vector direction1;
    19691938  Vector helper;
     
    19711940  ofstream *tempstream = NULL;
    19721941  char filename[255];
    1973   double tmp;
    1974   //atom* Walker;
    19751942  atom* OldThirdPoint;
    19761943
     
    19821949  Vector Opt_Mittelpunkt;
    19831950
    1984   cout << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl;
    1985 
     1951  cout << Verbose(1) << "Constructing helpful vectors ... " << endl;
    19861952  helper.CopyVector(&(Line.endpoints[0]->node->x));
    19871953  for (int i = 0; i < 3; i++)
     
    20041970      direction1.Scale(-1);
    20051971    }
    2006   cout << Verbose(2) << "Looking in direction " << direction1 << " for candidates.\n";
    20071972
    20081973  Chord.CopyVector(&(Line.endpoints[0]->node->x)); // bring into calling function
    20091974  Chord.SubtractVector(&(Line.endpoints[1]->node->x));
    2010   cout << Verbose(2) << "Baseline vector is " << Chord << ".\n";
    2011 
    2012 
    2013   Vector Umkreismittelpunkt, a, b, c;
    2014   double alpha, beta, gamma;
    2015   a.CopyVector(&(T.endpoints[0]->node->x));
    2016   b.CopyVector(&(T.endpoints[1]->node->x));
    2017   c.CopyVector(&(T.endpoints[2]->node->x));
    2018   a.SubtractVector(&(T.endpoints[1]->node->x));
    2019   b.SubtractVector(&(T.endpoints[2]->node->x));
    2020   c.SubtractVector(&(T.endpoints[0]->node->x));
    2021 
    2022 //  alpha = a.Angle(&c) - M_PI/2.;
    2023 //  beta = b.Angle(&a);
    2024 //  gamma = c.Angle(&b) - M_PI/2.;
     1975
     1976
     1977    Vector Umkreismittelpunkt, a, b, c;
     1978    double alpha, beta, gamma;
     1979    a.CopyVector(&(T.endpoints[0]->node->x));
     1980    b.CopyVector(&(T.endpoints[1]->node->x));
     1981    c.CopyVector(&(T.endpoints[2]->node->x));
     1982    a.SubtractVector(&(T.endpoints[1]->node->x));
     1983    b.SubtractVector(&(T.endpoints[2]->node->x));
     1984    c.SubtractVector(&(T.endpoints[0]->node->x));
     1985
    20251986    alpha = M_PI - a.Angle(&c);
    20261987    beta = M_PI - b.Angle(&a);
    20271988    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";
    20301989
    20311990    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) ;
     
    20361995    cout << " Old Normal is " <<  (T.NormalVector.x)[0] << " " << T.NormalVector.x[1] << " " << (T.NormalVector.x)[2] << " " << endl;
    20371996
    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   }
    20551997
    20561998  cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl;
     
    20692011  if ((TrianglesOnBoundaryCount % 1) == 0)
    20702012    {
    2071     cout << Verbose(1) << "Writing temporary non convex hull to file testEnvelope-" << TriangleFilesWritten << "d.dat.\n";
    20722013    sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten);
    20732014    tempstream = new ofstream(filename, ios::trunc);
     
    20802021  if (TrianglesOnBoundaryCount >189 and TrianglesOnBoundaryCount < 200 )
    20812022    {
    2082       cerr << Verbose(0)
    2083           << "WARNING: Already more than " << TrianglesOnBoundaryCount-1 << "triangles, construction probably has crashed." << endl;
     2023      cout << Verbose(1)
     2024          << "No new Atom found, triangle construction will crash" << endl;
    20842025      write_tecplot_file(out, tecplot, this, mol, TriangleFilesWritten);
    2085       cout << Verbose(2) << "This is currently added candidate" << Opt_Candidate << endl;
     2026      cout << "This is currently added candidate" << Opt_Candidate << endl;
    20862027    }
    20872028  // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
    20882029
    2089   cout << Verbose(2) << " Optimal candidate is " << *Opt_Candidate << endl;
    2090 
    2091   // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
     2030  cout << " Optimal candidate is " << *Opt_Candidate << endl;
    20922031
    20932032  AddTrianglePoint(Opt_Candidate, 0);
    2094   LineMap::iterator TryAndError;
    2095   TryAndError = TPS[0]->lines.find(Line.endpoints[0]->node->nr);
    2096   bool flag = true;
    2097   if ((TryAndError != TPS[0]->lines.end()) && (TryAndError->second->TrianglesCount > 1))
    2098     flag = false;
    2099   TryAndError = TPS[0]->lines.find(Line.endpoints[1]->node->nr);
    2100   if ((TryAndError !=  TPS[0]->lines.end()) && (TryAndError->second->TrianglesCount > 1))
    2101     flag = false;
    2102 
    2103   if (flag) { // if so, add
    2104     AddTrianglePoint(Line.endpoints[0]->node, 1);
    2105     AddTrianglePoint(Line.endpoints[1]->node, 2);
    2106 
    2107     AddTriangleLine(TPS[0], TPS[1], 0);
    2108     AddTriangleLine(TPS[0], TPS[2], 1);
    2109     AddTriangleLine(TPS[1], TPS[2], 2);
    2110 
    2111     BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    2112     AddTriangleToLines();
    2113 
    2114     BTS->GetNormalVector(BTS->NormalVector);
    2115 
    2116     if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0)  ||
    2117         (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0) ||
    2118         (fabs(Storage[0]) < MYEPSILON && Storage[1]*BTS->NormalVector.ScalarProduct(&direction1) < 0) )
    2119 
    2120       {
    2121         BTS->NormalVector.Scale(-1);
    2122       };
    2123     cout << Verbose(2) << "New triangle with " << *BTS << "and normal vector " << BTS->NormalVector << " for this triangle ... " << endl;
    2124     cout << Verbose(2) << "We have "<< TrianglesOnBoundaryCount << " for line " << Line << "." << endl;
    2125   } else { // else, yell and do nothing
    2126     cout << Verbose(2) << "This triangle consisting of ";
    2127     for (int i=0;i<NDIM;i++)
    2128       cout << BLS[i] << "(" << BLS[i]->TrianglesCount << "), ";
    2129     cout << " is invalid!" << endl;
    2130   }
    2131   cout << Verbose(1) << "End of Find_next_suitable_triangle\n";
     2033  AddTrianglePoint(Line.endpoints[0]->node, 1);
     2034  AddTrianglePoint(Line.endpoints[1]->node, 2);
     2035
     2036  AddTriangleLine(TPS[0], TPS[1], 0);
     2037  AddTriangleLine(TPS[0], TPS[2], 1);
     2038  AddTriangleLine(TPS[1], TPS[2], 2);
     2039
     2040  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     2041  AddTriangleToLines();
     2042  cout << "New triangle with " << *BTS << endl;
     2043  cout << "We have "<< TrianglesOnBoundaryCount << endl;
     2044  cout << Verbose(1) << "Constructing normal vector for this triangle ... " << endl;
     2045
     2046  BTS->GetNormalVector(BTS->NormalVector);
     2047
     2048  if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0)  ||
     2049      (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0) ||
     2050      (fabs(Storage[0]) < MYEPSILON && Storage[1]*BTS->NormalVector.ScalarProduct(&direction1) < 0) )
     2051
     2052    {
     2053      BTS->NormalVector.Scale(-1);
     2054    };
     2055
    21322056}
    21332057;
     
    21372061    molecule* mol, double RADIUS)
    21382062{
    2139   cout << Verbose(2)
    2140       << "Begin of Find_second_point_for_Tesselation, recursive level "
    2141       << RecursionLevel << endl;
     2063  cout << Verbose(1)
     2064      << "Looking for second point of starting triangle, recursive level "
     2065      << RecursionLevel << endl;;
    21422066  int i;
    21432067  Vector AngleCheck;
    21442068  atom* Walker;
    2145   double norm = -1., angle;
     2069  double norm = -1.;
    21462070
    21472071  // check if we only have one unique point yet ...
    21482072  if (a != Candidate)
    21492073    {
    2150     cout << Verbose(3) << "Current candidate is " << *Candidate << ": ";
    21512074      AngleCheck.CopyVector(&(Candidate->x));
    21522075      AngleCheck.SubtractVector(&(a->x));
     
    21552078      if (norm < RADIUS)
    21562079        {
    2157         angle = AngleCheck.Angle(&Oben);
    2158           if (angle < Storage[0])
     2080          if (AngleCheck.Angle(&Oben) < Storage[0])
    21592081            {
    2160               //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
    2161               cout << "Is a better candidate with distance " << norm << " and " << angle << ".\n";
     2082              //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[2]);
     2083              cout << "Next better candidate is " << *Candidate
     2084                  << " with distance " << norm << ".\n";
    21622085              Opt_Candidate = Candidate;
    21632086              Storage[0] = AngleCheck.Angle(&Oben);
     
    21662089          else
    21672090            {
    2168               cout << "Looses with angle " << angle << " to a better candidate "
     2091              cout << Verbose(1) << "Supposedly looses to a better candidate "
    21692092                  << *Opt_Candidate << endl;
    21702093            }
     
    21722095      else
    21732096        {
    2174           cout << "Refused due to Radius " << norm
     2097          cout << Verbose(1) << *Candidate << " refused due to Radius " << norm
    21752098              << endl;
    21762099        }
     
    21912114        };
    21922115    };
    2193   cout << Verbose(2) << "End of Find_second_point_for_Tesselation, recursive level "
    2194       << RecursionLevel << endl;
    21952116}
    21962117;
     
    21982119void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS)
    21992120{
    2200   cout << Verbose(1) << "Begin of Find_starting_triangle\n";
     2121  cout << Verbose(1) << "Looking for starting triangle \n";
    22012122  int i = 0;
    22022123  atom* Walker;
    22032124  atom* FirstPoint;
    22042125  atom* SecondPoint;
    2205   atom* max_index[NDIM];
    2206   double max_coordinate[NDIM];
     2126  atom* max_index[3];
     2127  double max_coordinate[3];
    22072128  Vector Oben;
    22082129  Vector helper;
     
    22172138      max_coordinate[i] = -1;
    22182139    }
    2219   cout << Verbose(2) << "Molecule mol is there and has " << mol->AtomCount
     2140  cout << Verbose(1) << "Molecule mol is there and has " << mol->AtomCount
    22202141      << " Atoms \n";
    22212142
     
    22352156    }
    22362157
    2237   cout << Verbose(2) << "Found maximum coordinates: ";
    2238   for (int i=0;i<NDIM;i++)
    2239     cout << i << ": " << *max_index[i] << "\t";
    2240   cout << endl;
     2158  cout << Verbose(1) << "Found maximum coordinates. " << endl;
    22412159  //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0
    22422160  const int k = 1;
     
    22442162  FirstPoint = max_index[k];
    22452163
    2246   cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << " with " << mol->NumberOfBondsPerAtom[FirstPoint->nr] << " bonds." << endl;
     2164  cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << ": "
     2165      << FirstPoint->x.x[0] << endl;
    22472166  double Storage[3];
    22482167  atom* Opt_Candidate = NULL;
     
    22502169  Storage[1] = 999999.; // This will be an angle looking for the third point.
    22512170  Storage[2] = 999999.;
     2171  cout << Verbose(1) << "Number of Bonds: "
     2172      << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl;
    22522173
    22532174  Find_second_point_for_Tesselation(FirstPoint, FirstPoint, FirstPoint, 0,
    22542175      Oben, Opt_Candidate, Storage, mol, RADIUS); // we give same point as next candidate as its bonds are looked into in find_second_...
    22552176  SecondPoint = Opt_Candidate;
    2256   cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n";
     2177  cout << Verbose(1) << "Found second point is " << *SecondPoint << ".\n";
    22572178
    22582179  helper.CopyVector(&(FirstPoint->x));
     
    22702191  // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized)
    22712192
    2272   cout << Verbose(2) << "Looking for third point candidates \n";
     2193  cout << Verbose(1) << "Looking for third point candidates \n";
     2194  cout << Verbose(1) << " In direction " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << " " << endl;
    22732195  // look in one direction of baseline for initial candidate
    22742196  Opt_Candidate = NULL;
     
    22772199  CenterOfFirstLine.AddVector(&(SecondPoint->x));
    22782200
    2279   cout << Verbose(1) << "Looking for third point candidates from " << *FirstPoint << " onward ...\n";
    22802201  Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, SecondPoint, FirstPoint, 0,
    22812202      &Chord, &helper, &Oben, CenterOfFirstLine,  Opt_Candidate, Storage, RADIUS, mol);
    22822203  // look in other direction of baseline for possible better candidate
    2283   cout << Verbose(1) << "Looking for third point candidates from " << *SecondPoint << " onward ...\n";
    22842204  Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, SecondPoint, 0,
    22852205      &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol);
     
    22872207
    22882208  // 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;
    22892213
    22902214  // Finally, we only have to add the found points
     
    23022226  Oben.Scale(-1.);
    23032227  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";
    23082228}
    23092229;
     
    23172237  const double RADIUS = 6.;
    23182238  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 
    23222239  Tess->Find_starting_triangle(mol, RADIUS);
    23232240
    23242241  baseline = Tess->LinesOnBoundary.begin();
    2325   while ((baseline != Tess->LinesOnBoundary.end()) || (flag))
     2242  while (baseline != Tess->LinesOnBoundary.end())
    23262243    {
    23272244      if (baseline->second->TrianglesCount == 1)
    23282245        {
     2246          cout << Verbose(1) << "Begin of Tesselation ... " << endl;
    23292247          Tess->Find_next_suitable_triangle(out, tecplot, mol,
    23302248              *(baseline->second),
    23312249              *(((baseline->second->triangles.begin()))->second), RADIUS, N); //the line is there, so there is a triangle, but only one.
    2332           flag = true;
     2250          cout << Verbose(1) << "End of Tesselation ... " << endl;
    23332251        }
    23342252      else
    23352253        {
    2336           cout << Verbose(1) << "Line " << baseline->second << " has "
     2254          cout << Verbose(1) << "There is a line with "
    23372255              << baseline->second->TrianglesCount << " triangles adjacent"
    23382256              << endl;
     
    23402258      N++;
    23412259      baseline++;
    2342       if ((baseline == Tess->LinesOnBoundary.end()) && (flag)) {
    2343         baseline = Tess->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
    2344         flag = false;
    2345       }
    2346     }
    2347   cout << Verbose(1) << "Writing final tecplot file\n";
     2260    }
    23482261  write_tecplot_file(out, tecplot, Tess, mol, -1);
    23492262
    2350   cout << Verbose(0) << "End of Find_non_convex_border\n";
    2351 }
    2352 ;
    2353 
     2263}
     2264;
  • src/vector.cpp

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

    r02bfde r196a5a  
    2121  double Projection(const Vector *y) const;
    2222  double Norm() const ;
    23   double Angle(const Vector *y) const;
     23  double Angle(Vector *y) const;
    2424
    2525  void AddVector(const Vector *y);
     
    5555};
    5656
    57 ostream & operator << (ostream& ost, Vector &m);
     57ofstream& operator<<(ofstream& 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.