Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselationhelpers.cpp

    r299554 re138de  
    88#include <fstream>
    99
    10 #include "info.hpp"
    1110#include "linkedcell.hpp"
    1211#include "log.hpp"
     
    1615#include "verbose.hpp"
    1716
    18 double DetGet(gsl_matrix * const A, const int inPlace)
    19 {
    20         Info FunctionInfo(__func__);
     17double DetGet(gsl_matrix * const A, const int inPlace) {
    2118  /*
    2219  inPlace = 1 => A is replaced with the LU decomposed copy.
     
    4845void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
    4946{
    50         Info FunctionInfo(__func__);
    5147  gsl_matrix *A = gsl_matrix_calloc(3,3);
    5248  double m11, m12, m13, m14;
     
    8177
    8278  if (fabs(m11) < MYEPSILON)
    83     DoeLog(1) && (eLog()<< Verbose(1) << "three points are colinear." << endl);
     79    eLog() << Verbose(0) << "ERROR: three points are colinear." << endl;
    8480
    8581  center->x[0] =  0.5 * m12/ m11;
     
    8884
    8985  if (fabs(a.Distance(center) - RADIUS) > MYEPSILON)
    90     DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl);
     86    eLog() << Verbose(0) << "ERROR: The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl;
    9187
    9288  gsl_matrix_free(A);
     
    115111    const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius)
    116112{
    117         Info FunctionInfo(__func__);
    118113  Vector TempNormal, helper;
    119114  double Restradius;
    120115  Vector OtherCenter;
     116  Log() << Verbose(3) << "Begin of GetCenterOfSphere.\n";
    121117  Center->Zero();
    122118  helper.CopyVector(&a);
     
    132128  Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
    133129  NewUmkreismittelpunkt->CopyVector(Center);
    134   DoLog(1) && (Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n");
     130  Log() << Verbose(4) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n";
    135131  // Here we calculated center of circumscribing circle, using barycentric coordinates
    136   DoLog(1) && (Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n");
     132  Log() << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
    137133
    138134  TempNormal.CopyVector(&a);
     
    143139  if (fabs(HalfplaneIndicator) < MYEPSILON)
    144140    {
    145       if ((TempNormal.ScalarProduct(AlternativeDirection) <0 && AlternativeIndicator >0) || (TempNormal.ScalarProduct(AlternativeDirection) >0 && AlternativeIndicator <0))
     141      if ((TempNormal.ScalarProduct(AlternativeDirection) <0 and AlternativeIndicator >0) or (TempNormal.ScalarProduct(AlternativeDirection) >0 and AlternativeIndicator <0))
    146142        {
    147143          TempNormal.Scale(-1);
     
    150146  else
    151147    {
    152       if (((TempNormal.ScalarProduct(Direction)<0) && (HalfplaneIndicator >0)) || ((TempNormal.ScalarProduct(Direction)>0) && (HalfplaneIndicator<0)))
     148      if (TempNormal.ScalarProduct(Direction)<0 && HalfplaneIndicator >0 || TempNormal.ScalarProduct(Direction)>0 && HalfplaneIndicator<0)
    153149        {
    154150          TempNormal.Scale(-1);
     
    158154  TempNormal.Normalize();
    159155  Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
    160   DoLog(1) && (Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n");
     156  Log() << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";
    161157  TempNormal.Scale(Restradius);
    162   DoLog(1) && (Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n");
     158  Log() << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
    163159
    164160  Center->AddVector(&TempNormal);
    165   DoLog(1) && (Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n");
     161  Log() << Verbose(0) << "Center of sphere of circumference is " << *Center << ".\n";
    166162  GetSphere(&OtherCenter, a, b, c, RADIUS);
    167   DoLog(1) && (Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n");
     163  Log() << Verbose(0) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n";
     164  Log() << Verbose(3) << "End of GetCenterOfSphere.\n";
    168165};
    169166
     
    177174void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c)
    178175{
    179         Info FunctionInfo(__func__);
    180176  Vector helper;
    181177  double alpha, beta, gamma;
     
    190186  beta = M_PI - SideC.Angle(&SideA);
    191187  gamma = M_PI - SideA.Angle(&SideB);
    192   //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;
    193   if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) {
    194     DoeLog(2) && (eLog()<< Verbose(2) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl);
    195   }
     188  //Log() << Verbose(3) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;
     189  if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON)
     190    eLog() << Verbose(0) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl;
    196191
    197192  Center->Zero();
     
    223218double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection)
    224219{
    225         Info FunctionInfo(__func__);
    226220  Vector helper;
    227221  double radius, alpha;
    228   Vector RelativeOldSphereCenter;
    229   Vector RelativeNewSphereCenter;
    230 
    231   RelativeOldSphereCenter.CopyVector(&OldSphereCenter);
    232   RelativeOldSphereCenter.SubtractVector(&CircleCenter);
    233   RelativeNewSphereCenter.CopyVector(&NewSphereCenter);
    234   RelativeNewSphereCenter.SubtractVector(&CircleCenter);
    235   helper.CopyVector(&RelativeNewSphereCenter);
     222
     223  helper.CopyVector(&NewSphereCenter);
    236224  // test whether new center is on the parameter circle's plane
    237225  if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
    238     DoeLog(1) && (eLog()<< Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal))  << "!" << endl);
     226    eLog() << Verbose(0) << "ERROR: Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal))  << "!" << endl;
    239227    helper.ProjectOntoPlane(&CirclePlaneNormal);
    240228  }
    241   radius = helper.NormSquared();
     229  radius = helper.ScalarProduct(&helper);
    242230  // test whether the new center vector has length of CircleRadius
    243231  if (fabs(radius - CircleRadius) > HULLEPSILON)
    244     DoeLog(1) && (eLog()<< Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl);
    245   alpha = helper.Angle(&RelativeOldSphereCenter);
     232    eLog() << Verbose(1) << "ERROR: The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;
     233  alpha = helper.Angle(&OldSphereCenter);
    246234  // make the angle unique by checking the halfplanes/search direction
    247235  if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)  // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
    248236    alpha = 2.*M_PI - alpha;
    249   DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl);
    250   radius = helper.Distance(&RelativeOldSphereCenter);
     237  //Log() << Verbose(2) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << OldSphereCenter << " and resulting angle is " << alpha << "." << endl;
     238  radius = helper.Distance(&OldSphereCenter);
    251239  helper.ProjectOntoPlane(&NormalVector);
    252240  // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles
    253241  if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) {
    254     DoLog(1) && (Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl);
     242    //Log() << Verbose(2) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;
    255243    return alpha;
    256244  } else {
    257     DoLog(1) && (Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl);
     245    //Log() << Verbose(1) << "INFO: NewSphereCenter " << helper << " is too close to OldSphereCenter" << OldSphereCenter << "." << endl;
    258246    return 2.*M_PI;
    259247  }
     
    275263double MinIntersectDistance(const gsl_vector * x, void *params)
    276264{
    277         Info FunctionInfo(__func__);
    278265  double retval = 0;
    279266  struct Intersection *I = (struct Intersection *)params;
     
    296283
    297284  retval = HeightA.ScalarProduct(&HeightA) + HeightB.ScalarProduct(&HeightB);
    298   //Log() << Verbose(1) << "MinIntersectDistance called, result: " << retval << endl;
     285  //Log() << Verbose(2) << "MinIntersectDistance called, result: " << retval << endl;
    299286
    300287  return retval;
     
    316303bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4)
    317304{
    318         Info FunctionInfo(__func__);
    319305  bool result;
    320306
     
    364350
    365351        if (status == GSL_SUCCESS) {
    366           DoLog(1) && (Log() << Verbose(1) << "converged to minimum" <<  endl);
     352          Log() << Verbose(2) << "converged to minimum" <<  endl;
    367353        }
    368354    } while (status == GSL_CONTINUE && iter < 100);
     
    389375  t2 = HeightB.ScalarProduct(&SideB)/SideB.ScalarProduct(&SideB);
    390376
    391   Log() << Verbose(1) << "Intersection " << intersection << " is at "
     377  Log() << Verbose(2) << "Intersection " << intersection << " is at "
    392378    << t1 << " for (" << point1 << "," << point2 << ") and at "
    393379    << t2 << " for (" << point3 << "," << point4 << "): ";
    394380
    395381  if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) {
    396     DoLog(1) && (Log() << Verbose(1) << "true intersection." << endl);
     382    Log() << Verbose(0) << "true intersection." << endl;
    397383    result = true;
    398384  } else {
    399     DoLog(1) && (Log() << Verbose(1) << "intersection out of region of interest." << endl);
     385    Log() << Verbose(0) << "intersection out of region of interest." << endl;
    400386    result = false;
    401387  }
     
    420406double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector)
    421407{
    422         Info FunctionInfo(__func__);
    423408  if (reference.IsZero())
    424409    return M_PI;
     
    432417  }
    433418
    434   DoLog(1) && (Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl);
     419  Log() << Verbose(4) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl;
    435420
    436421  return phi;
     
    447432double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d)
    448433{
    449         Info FunctionInfo(__func__);
    450434  Vector Point, TetraederVector[3];
    451435  double volume;
     
    471455bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3])
    472456{
    473         Info FunctionInfo(__func__);
    474457  bool result = false;
    475458  int counter = 0;
     
    478461  for (int i=0;i<3;i++)
    479462    for (int j=i+1; j<3; j++) {
    480       if (nodes[i] == NULL) {
    481         DoLog(1) && (Log() << Verbose(1) << "Node nr. " << i << " is not yet present." << endl);
    482         result = true;
    483       } else if (nodes[i]->lines.find(nodes[j]->node->nr) != nodes[i]->lines.end()) {  // there already is a line
     463      if (nodes[i]->lines.find(nodes[j]->node->nr) != nodes[i]->lines.end()) {  // there already is a line
    484464        LineMap::const_iterator FindLine;
    485465        pair<LineMap::const_iterator,LineMap::const_iterator> FindPair;
     
    493473        }
    494474      } else { // no line
    495         DoLog(1) && (Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl);
     475        Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl;
    496476        result = true;
    497477      }
    498478    }
    499479  if ((!result) && (counter > 1)) {
    500     DoLog(1) && (Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl);
     480    Log() << Verbose(2) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl;
    501481    result = true;
    502482  }
     
    505485
    506486
    507 ///** Sort function for the candidate list.
    508 // */
    509 //bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2)
    510 //{
    511 //      Info FunctionInfo(__func__);
    512 //  Vector BaseLineVector, OrthogonalVector, helper;
    513 //  if (candidate1->BaseLine != candidate2->BaseLine) {  // sanity check
    514 //    DoeLog(1) && (eLog()<< Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl);
    515 //    //return false;
    516 //    exit(1);
    517 //  }
    518 //  // create baseline vector
    519 //  BaseLineVector.CopyVector(candidate1->BaseLine->endpoints[1]->node->node);
    520 //  BaseLineVector.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
    521 //  BaseLineVector.Normalize();
    522 //
    523 //  // create normal in-plane vector to cope with acos() non-uniqueness on [0,2pi] (note that is pointing in the "right" direction already, hence ">0" test!)
    524 //  helper.CopyVector(candidate1->BaseLine->endpoints[0]->node->node);
    525 //  helper.SubtractVector(candidate1->point->node);
    526 //  OrthogonalVector.CopyVector(&helper);
    527 //  helper.VectorProduct(&BaseLineVector);
    528 //  OrthogonalVector.SubtractVector(&helper);
    529 //  OrthogonalVector.Normalize();
    530 //
    531 //  // calculate both angles and correct with in-plane vector
    532 //  helper.CopyVector(candidate1->point->node);
    533 //  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
    534 //  double phi = BaseLineVector.Angle(&helper);
    535 //  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
    536 //    phi = 2.*M_PI - phi;
    537 //  }
    538 //  helper.CopyVector(candidate2->point->node);
    539 //  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
    540 //  double psi = BaseLineVector.Angle(&helper);
    541 //  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
    542 //    psi = 2.*M_PI - psi;
    543 //  }
    544 //
    545 //  Log() << Verbose(1) << *candidate1->point << " has angle " << phi << endl;
    546 //  Log() << Verbose(1) << *candidate2->point << " has angle " << psi << endl;
    547 //
    548 //  // return comparison
    549 //  return phi < psi;
    550 //};
     487/** Sort function for the candidate list.
     488 */
     489bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2)
     490{
     491  Vector BaseLineVector, OrthogonalVector, helper;
     492  if (candidate1->BaseLine != candidate2->BaseLine) {  // sanity check
     493    Log() << Verbose(0) << "ERROR: sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl;
     494    //return false;
     495    exit(1);
     496  }
     497  // create baseline vector
     498  BaseLineVector.CopyVector(candidate1->BaseLine->endpoints[1]->node->node);
     499  BaseLineVector.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
     500  BaseLineVector.Normalize();
     501
     502  // create normal in-plane vector to cope with acos() non-uniqueness on [0,2pi] (note that is pointing in the "right" direction already, hence ">0" test!)
     503  helper.CopyVector(candidate1->BaseLine->endpoints[0]->node->node);
     504  helper.SubtractVector(candidate1->point->node);
     505  OrthogonalVector.CopyVector(&helper);
     506  helper.VectorProduct(&BaseLineVector);
     507  OrthogonalVector.SubtractVector(&helper);
     508  OrthogonalVector.Normalize();
     509
     510  // calculate both angles and correct with in-plane vector
     511  helper.CopyVector(candidate1->point->node);
     512  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
     513  double phi = BaseLineVector.Angle(&helper);
     514  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
     515    phi = 2.*M_PI - phi;
     516  }
     517  helper.CopyVector(candidate2->point->node);
     518  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
     519  double psi = BaseLineVector.Angle(&helper);
     520  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
     521    psi = 2.*M_PI - psi;
     522  }
     523
     524  Log() << Verbose(2) << *candidate1->point << " has angle " << phi << endl;
     525  Log() << Verbose(2) << *candidate2->point << " has angle " << psi << endl;
     526
     527  // return comparison
     528  return phi < psi;
     529};
    551530
    552531/**
     
    558537 * @return point which is second closest to the provided one
    559538 */
    560 TesselPoint* FindSecondClosestTesselPoint(const Vector* Point, const LinkedCell* const LC)
    561 {
    562         Info FunctionInfo(__func__);
     539TesselPoint* FindSecondClosestPoint(const Vector* Point, const LinkedCell* const LC)
     540{
    563541  TesselPoint* closestPoint = NULL;
    564542  TesselPoint* secondClosestPoint = NULL;
     
    571549  for(int i=0;i<NDIM;i++) // store indices of this cell
    572550    N[i] = LC->n[i];
    573   DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
     551  Log() << Verbose(2) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    574552
    575553  LC->GetNeighbourBounds(Nlower, Nupper);
    576   //Log() << Verbose(1) << endl;
     554  //Log() << Verbose(0) << endl;
    577555  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
    578556    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    579557      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    580         const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    581         //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
     558        const LinkedNodes *List = LC->GetCurrentCell();
     559        //Log() << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    582560        if (List != NULL) {
    583           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     561          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    584562            helper.CopyVector(Point);
    585563            helper.SubtractVector((*Runner)->node);
     
    596574          }
    597575        } else {
    598           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << ","
     576          eLog() << Verbose(0) << "ERROR: The current cell " << LC->n[0] << "," << LC->n[1] << ","
    599577            << LC->n[2] << " is invalid!" << endl;
    600578        }
     
    613591 * @return point which is closest to the provided one, NULL if none found
    614592 */
    615 TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
    616 {
    617         Info FunctionInfo(__func__);
     593TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
     594{
    618595  TesselPoint* closestPoint = NULL;
    619596  SecondPoint = NULL;
     
    626603  for(int i=0;i<NDIM;i++) // store indices of this cell
    627604    N[i] = LC->n[i];
    628   DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
     605  Log() << Verbose(3) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    629606
    630607  LC->GetNeighbourBounds(Nlower, Nupper);
    631   //Log() << Verbose(1) << endl;
     608  //Log() << Verbose(0) << endl;
    632609  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
    633610    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    634611      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    635         const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    636         //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
     612        const LinkedNodes *List = LC->GetCurrentCell();
     613        //Log() << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    637614        if (List != NULL) {
    638           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     615          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    639616            helper.CopyVector(Point);
    640617            helper.SubtractVector((*Runner)->node);
    641             double currentNorm = helper.NormSquared();
     618            double currentNorm = helper. Norm();
    642619            if (currentNorm < distance) {
    643620              secondDistance = distance;
     
    645622              distance = currentNorm;
    646623              closestPoint = (*Runner);
    647               //Log() << Verbose(1) << "INFO: New Nearest Neighbour is " << *closestPoint << "." << endl;
     624              //Log() << Verbose(2) << "INFO: New Nearest Neighbour is " << *closestPoint << "." << endl;
    648625            } else if (currentNorm < secondDistance) {
    649626              secondDistance = currentNorm;
    650627              SecondPoint = (*Runner);
    651               //Log() << Verbose(1) << "INFO: New Second Nearest Neighbour is " << *SecondPoint << "." << endl;
     628              //Log() << Verbose(2) << "INFO: New Second Nearest Neighbour is " << *SecondPoint << "." << endl;
    652629            }
    653630          }
    654631        } else {
    655           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << ","
     632          eLog() << Verbose(0) << "ERROR: The current cell " << LC->n[0] << "," << LC->n[1] << ","
    656633            << LC->n[2] << " is invalid!" << endl;
    657634        }
     
    659636  // output
    660637  if (closestPoint != NULL) {
    661     DoLog(1) && (Log() << Verbose(1) << "Closest point is " << *closestPoint);
     638    Log() << Verbose(2) << "Closest point is " << *closestPoint;
    662639    if (SecondPoint != NULL)
    663       DoLog(0) && (Log() << Verbose(0) << " and second closest is " << *SecondPoint);
    664     DoLog(0) && (Log() << Verbose(0) << "." << endl);
     640      Log() << Verbose(0) << " and second closest is " << *SecondPoint;
     641    Log() << Verbose(0) << "." << endl;
    665642  }
    666643  return closestPoint;
     
    675652Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase)
    676653{
    677         Info FunctionInfo(__func__);
    678654  // construct the plane of the two baselines (i.e. take both their directional vectors)
    679655  Vector Normal;
     
    686662  Normal.VectorProduct(&OtherBaseline);
    687663  Normal.Normalize();
    688   DoLog(1) && (Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl);
     664  Log() << Verbose(4) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl;
    689665
    690666  // project one offset point of OtherBase onto this plane (and add plane offset vector)
     
    703679  Normal.CopyVector(Intersection);
    704680  Normal.SubtractVector(Base->endpoints[0]->node->node);
    705   DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl);
     681  Log() << Verbose(3) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl;
    706682
    707683  return Intersection;
     
    716692double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle)
    717693{
    718         Info FunctionInfo(__func__);
    719694  double distance = 0.;
    720695  if (x == NULL) {
     
    733708void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud)
    734709{
    735         Info FunctionInfo(__func__);
    736710  TesselPoint *Walker = NULL;
    737711  int i;
     
    764738    }
    765739  } else {
    766     DoeLog(1) && (eLog()<< Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl);
     740    eLog() << Verbose(0) << "ERROR: Given vrmlfile is " << vrmlfile << "." << endl;
    767741  }
    768742  delete(center);
     
    777751void IncludeSphereinRaster3D(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
    778752{
    779         Info FunctionInfo(__func__);
    780753  Vector helper;
    781 
    782   if (Tess->LastTriangle != NULL) {
    783     // include the current position of the virtual sphere in the temporary raster3d file
    784     Vector *center = cloud->GetCenter();
    785     // make the circumsphere's center absolute again
    786     helper.CopyVector(Tess->LastTriangle->endpoints[0]->node->node);
    787     helper.AddVector(Tess->LastTriangle->endpoints[1]->node->node);
    788     helper.AddVector(Tess->LastTriangle->endpoints[2]->node->node);
    789     helper.Scale(1./3.);
    790     helper.SubtractVector(center);
    791     // and add to file plus translucency object
    792     *rasterfile << "# current virtual sphere\n";
    793     *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
    794     *rasterfile << "2\n  " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << "\t" << 5. << "\t1 0 0\n";
    795     *rasterfile << "9\n  terminating special property\n";
    796     delete(center);
    797   }
     754  // include the current position of the virtual sphere in the temporary raster3d file
     755  Vector *center = cloud->GetCenter();
     756  // make the circumsphere's center absolute again
     757  helper.CopyVector(Tess->LastTriangle->endpoints[0]->node->node);
     758  helper.AddVector(Tess->LastTriangle->endpoints[1]->node->node);
     759  helper.AddVector(Tess->LastTriangle->endpoints[2]->node->node);
     760  helper.Scale(1./3.);
     761  helper.SubtractVector(center);
     762  // and add to file plus translucency object
     763  *rasterfile << "# current virtual sphere\n";
     764  *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
     765  *rasterfile << "2\n  " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << "\t" << 5. << "\t1 0 0\n";
     766  *rasterfile << "9\n  terminating special property\n";
     767  delete(center);
    798768};
    799769
     
    806776void WriteRaster3dFile(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
    807777{
    808         Info FunctionInfo(__func__);
    809778  TesselPoint *Walker = NULL;
    810779  int i;
     
    839808    *rasterfile << "9\n#  terminating special property\n";
    840809  } else {
    841     DoeLog(1) && (eLog()<< Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl);
     810    eLog() << Verbose(0) << "ERROR: Given rasterfile is " << rasterfile << "." << endl;
    842811  }
    843812  IncludeSphereinRaster3D(rasterfile, Tess, cloud);
     
    852821void WriteTecplotFile(ofstream * const tecplot, const Tesselation * const TesselStruct, const PointCloud * const cloud, const int N)
    853822{
    854         Info FunctionInfo(__func__);
    855823  if ((tecplot != NULL) && (TesselStruct != NULL)) {
    856824    // write header
    857825    *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
    858826    *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\" \"U\"" << endl;
    859     *tecplot << "ZONE T=\"";
    860     if (N < 0) {
    861       *tecplot << cloud->GetName();
    862     } else {
    863       *tecplot << N << "-";
    864       if (TesselStruct->LastTriangle != NULL) {
    865         for (int i=0;i<3;i++)
    866           *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
    867       } else {
    868         *tecplot << "none";
    869       }
    870     }
     827    *tecplot << "ZONE T=\"" << N << "-";
     828    for (int i=0;i<3;i++)
     829      *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
    871830    *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
    872     int i=cloud->GetMaxId();
     831    int i=0;
     832    for (cloud->GoToFirst(); !cloud->IsEnd(); cloud->GoToNext(), i++);
    873833    int *LookupList = new int[i];
    874834    for (cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++)
     
    876836
    877837    // print atom coordinates
     838    Log() << Verbose(2) << "The following triangles were created:";
    878839    int Counter = 1;
    879840    TesselPoint *Walker = NULL;
     
    885846    *tecplot << endl;
    886847    // print connectivity
    887     DoLog(1) && (Log() << Verbose(1) << "The following triangles were created:" << endl);
    888848    for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) {
    889       DoLog(1) && (Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name << endl);
     849      Log() << Verbose(0) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name;
    890850      *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
    891851    }
    892852    delete[] (LookupList);
     853    Log() << Verbose(0) << endl;
    893854  }
    894855};
     
    901862void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct)
    902863{
    903         Info FunctionInfo(__func__);
    904864  class BoundaryPointSet *point = NULL;
    905865  class BoundaryLineSet *line = NULL;
    906866
     867  //Log() << Verbose(2) << "Begin of CalculateConcavityPerBoundaryPoint" << endl;
    907868  // calculate remaining concavity
    908869  for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
    909870    point = PointRunner->second;
    910     DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
     871    Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
    911872    point->value = 0;
    912873    for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    913874      line = LineRunner->second;
    914       //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
     875      //Log() << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    915876      if (!line->CheckConvexityCriterion())
    916877        point->value += 1;
    917878    }
    918879  }
     880  //Log() << Verbose(2) << "End of CalculateConcavityPerBoundaryPoint" << endl;
    919881};
    920882
     
    927889bool CheckListOfBaselines(const Tesselation * const TesselStruct)
    928890{
    929         Info FunctionInfo(__func__);
    930891  LineMap::const_iterator testline;
    931892  bool result = false;
    932893  int counter = 0;
    933894
    934   DoLog(1) && (Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl);
     895  Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl;
    935896  for (testline = TesselStruct->LinesOnBoundary.begin(); testline != TesselStruct->LinesOnBoundary.end(); testline++) {
    936897    if (testline->second->triangles.size() != 2) {
    937       DoLog(2) && (Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl);
     898      Log() << Verbose(1) << *testline->second << "\t" << testline->second->triangles.size() << endl;
    938899      counter++;
    939900    }
    940901  }
    941902  if (counter == 0) {
    942     DoLog(1) && (Log() << Verbose(1) << "None." << endl);
     903    Log() << Verbose(1) << "None." << endl;
    943904    result = true;
    944905  }
     
    946907}
    947908
    948 /** Counts the number of triangle pairs that contain the given polygon.
    949  * \param *P polygon with endpoints to look for
    950  * \param *T set of triangles to create pairs from containing \a *P
    951  */
    952 int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T)
    953 {
    954   Info FunctionInfo(__func__);
    955   // check number of endpoints in *P
    956   if (P->endpoints.size() != 4) {
    957     DoeLog(1) && (eLog()<< Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl);
    958     return 0;
    959   }
    960 
    961   // check number of triangles in *T
    962   if (T->size() < 2) {
    963     DoeLog(1) && (eLog()<< Verbose(1) << "Not enough triangles to have pairs!" << endl);
    964     return 0;
    965   }
    966 
    967   DoLog(0) && (Log() << Verbose(0) << "Polygon is " << *P << endl);
    968   // create each pair, get the endpoints and check whether *P is contained.
    969   int counter = 0;
    970   PointSet Trianglenodes;
    971   class BoundaryPolygonSet PairTrianglenodes;
    972   for(TriangleSet::iterator Walker = T->begin(); Walker != T->end(); Walker++) {
    973     for (int i=0;i<3;i++)
    974       Trianglenodes.insert((*Walker)->endpoints[i]);
    975 
    976     for(TriangleSet::iterator PairWalker = Walker; PairWalker != T->end(); PairWalker++) {
    977       if (Walker != PairWalker) { // skip first
    978         PairTrianglenodes.endpoints = Trianglenodes;
    979         for (int i=0;i<3;i++)
    980           PairTrianglenodes.endpoints.insert((*PairWalker)->endpoints[i]);
    981         const int size = PairTrianglenodes.endpoints.size();
    982         if (size == 4) {
    983           DoLog(0) && (Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl);
    984           // now check
    985           if (PairTrianglenodes.ContainsPresentTupel(P)) {
    986             counter++;
    987             DoLog(0) && (Log() << Verbose(0) << "  ACCEPT: Matches with " << *P << endl);
    988           } else {
    989             DoLog(0) && (Log() << Verbose(0) << "  REJECT: No match with " << *P << endl);
    990           }
    991         } else {
    992           DoLog(0) && (Log() << Verbose(0) << "  REJECT: Less than four endpoints." << endl);
    993         }
    994       }
    995     }
    996     Trianglenodes.clear();
    997   }
    998   return counter;
    999 };
    1000 
    1001 /** Checks whether two give polygons have two or more points in common.
    1002  * \param *P1 first polygon
    1003  * \param *P2 second polygon
    1004  * \return true - are connected, false = are note
    1005  */
    1006 bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2)
    1007 {
    1008   Info FunctionInfo(__func__);
    1009   int counter = 0;
    1010   for(PointSet::const_iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) {
    1011     if (P2->ContainsBoundaryPoint((*Runner))) {
    1012       counter++;
    1013       DoLog(1) && (Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl);
    1014       return true;
    1015     }
    1016   }
    1017   return false;
    1018 };
    1019 
    1020 /** Combines second into the first and deletes the second.
    1021  * \param *P1 first polygon, contains all nodes on return
    1022  * \param *&P2 second polygon, is deleted.
    1023  */
    1024 void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2)
    1025 {
    1026   Info FunctionInfo(__func__);
    1027   pair <PointSet::iterator, bool> Tester;
    1028   for(PointSet::iterator Runner = P2->endpoints.begin(); Runner != P2->endpoints.end(); Runner++) {
    1029     Tester = P1->endpoints.insert((*Runner));
    1030     if (Tester.second)
    1031       DoLog(0) && (Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl);
    1032   }
    1033   P2->endpoints.clear();
    1034   delete(P2);
    1035 };
    1036 
Note: See TracChangeset for help on using the changeset viewer.