Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    • Property mode changed from 100755 to 100644
    rb34306 rb5c2d7  
    5757  } else {
    5858    BoundaryPoints = BoundaryPtr;
    59     Log() << Verbose(0) << "Using given boundary points set." << endl;
     59    DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    6060  }
    6161  // determine biggest "diameter" of cluster for each axis
     
    163163    AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.;
    164164
    165     Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
     165    DoLog(1) && (Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl);
    166166
    167167    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
     
    184184        angle = 2. * M_PI - angle;
    185185      }
    186       Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
     186      DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
    187187      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
    188188      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    189         Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl;
    190         Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl;
    191         Log() << Verbose(2) << "New vector: " << *Walker << endl;
     189        DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
     190        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
     191        DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl);
    192192        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    193193        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    194194          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    195195          BoundaryTestPair.first->second.second = Walker;
    196           Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
     196          DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    197197        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    198198          helper.CopyVector(&Walker->x);
     
    203203          if (helper.NormSquared() < oldhelperNorm) {
    204204            BoundaryTestPair.first->second.second = Walker;
    205             Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;
     205            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
    206206          } else {
    207             Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl;
     207            DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl);
    208208          }
    209209        } else {
    210           Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
     210          DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    211211        }
    212212      }
     
    227227    // 3c. throw out points whose distance is less than the mean of left and right neighbours
    228228    bool flag = false;
    229     Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl;
     229    DoLog(1) && (Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl);
    230230    do { // do as long as we still throw one out per round
    231231      flag = false;
     
    282282          const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.);
    283283          //Log() << Verbose(1) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl;
    284           Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl;
     284          DoLog(1) && (Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl);
    285285          if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) {
    286286            // throw out point
    287             Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl;
     287            DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl);
    288288            BoundaryPoints[axis].erase(runner);
    289289            flag = true;
     
    320320      BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    321321  } else {
    322       Log() << Verbose(0) << "Using given boundary points set." << endl;
     322      DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    323323  }
    324324
     
    326326  for (int axis=0; axis < NDIM; axis++)
    327327    {
    328       Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
     328      DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
    329329      int i=0;
    330330      for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    331331        if (runner != BoundaryPoints[axis].begin())
    332           Log() << Verbose(0) << ", " << i << ": " << *runner->second.second;
     332          DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
    333333        else
    334           Log() << Verbose(0) << i << ": " << *runner->second.second;
     334          DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
    335335        i++;
    336336      }
    337       Log() << Verbose(0) << endl;
     337      DoLog(0) && (Log() << Verbose(0) << endl);
    338338    }
    339339
     
    342342    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
    343343        if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0))
    344           eLog() << Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl;
    345 
    346   Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl;
     344          DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl);
     345
     346  DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl);
    347347  // now we have the whole set of edge points in the BoundaryList
    348348
     
    362362  // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point
    363363  if (!TesselStruct->InsertStraddlingPoints(mol, LCList))
    364     eLog() << Verbose(1) << "Insertion of straddling points failed!" << endl;
    365 
    366   Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
     364    DoeLog(1) && (eLog()<< Verbose(1) << "Insertion of straddling points failed!" << endl);
     365
     366  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
    367367
    368368  // 4. Store triangles in tecplot file
     
    395395    for (LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) {
    396396      line = LineRunner->second;
    397       Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl;
     397      DoLog(1) && (Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl);
    398398      if (!line->CheckConvexityCriterion()) {
    399         Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;
     399        DoLog(1) && (Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl);
    400400
    401401        // flip the line
    402402        if (TesselStruct->PickFarthestofTwoBaselines(line) == 0.)
    403           eLog() << Verbose(1) << "Correction of concave baselines failed!" << endl;
     403          DoeLog(1) && (eLog()<< Verbose(1) << "Correction of concave baselines failed!" << endl);
    404404        else {
    405405          TesselStruct->FlipBaseline(line);
    406           Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl;
     406          DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl);
    407407        }
    408408      }
     
    414414//    Log() << Verbose(1) << "Correction of concave tesselpoints failed!" << endl;
    415415
    416   Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
     416  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
    417417
    418418  // 4. Store triangles in tecplot file
     
    456456
    457457  if ((TesselStruct == NULL) || (TesselStruct->PointsOnBoundary.empty())) {
    458     eLog() << Verbose(1) << "TesselStruct is empty." << endl;
     458    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty." << endl);
    459459    return false;
    460460  }
     
    462462  PointMap::iterator PointRunner;
    463463  while (!TesselStruct->PointsOnBoundary.empty()) {
    464     Log() << Verbose(1) << "Remaining points are: ";
     464    DoLog(1) && (Log() << Verbose(1) << "Remaining points are: ");
    465465    for (PointMap::iterator PointSprinter = TesselStruct->PointsOnBoundary.begin(); PointSprinter != TesselStruct->PointsOnBoundary.end(); PointSprinter++)
    466       Log() << Verbose(0) << *(PointSprinter->second) << "\t";
    467     Log() << Verbose(0) << endl;
     466      DoLog(0) && (Log() << Verbose(0) << *(PointSprinter->second) << "\t");
     467    DoLog(0) && (Log() << Verbose(0) << endl);
    468468
    469469    PointRunner = TesselStruct->PointsOnBoundary.begin();
     
    521521  // check whether there is something to work on
    522522  if (TesselStruct == NULL) {
    523     eLog() << Verbose(1) << "TesselStruct is empty!" << endl;
     523    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty!" << endl);
    524524    return volume;
    525525  }
     
    537537      PointAdvance++;
    538538      point = PointRunner->second;
    539       Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     539      DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
    540540      for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    541541        line = LineRunner->second;
    542         Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
     542        DoLog(1) && (Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl);
    543543        if (!line->CheckConvexityCriterion()) {
    544544          // remove the point if needed
    545           Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;
     545          DoLog(1) && (Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl);
    546546          volume += TesselStruct->RemovePointFromTesselatedSurface(point);
    547547          sprintf(dummy, "-first-%d", ++run);
     
    564564      LineAdvance++;
    565565      line = LineRunner->second;
    566       Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;
     566      DoLog(1) && (Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl);
    567567      // take highest of both lines
    568568      if (TesselStruct->IsConvexRectangle(line) == NULL) {
     
    605605
    606606  // end
    607   Log() << Verbose(0) << "Volume is " << volume << "." << endl;
     607  DoLog(0) && (Log() << Verbose(0) << "Volume is " << volume << "." << endl);
    608608  return volume;
    609609};
     
    734734      totalmass += Walker->type->mass;
    735735  }
    736   Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl;
    737   Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     736  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
     737  DoLog(0) && (Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    738738
    739739  // solve cubic polynomial
    740   Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl;
     740  DoLog(1) && (Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl);
    741741  if (IsAngstroem)
    742742    cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1);
    743743  else
    744744    cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_a0 - (totalmass / clustervolume)) / (celldensity - 1);
    745   Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     745  DoLog(1) && (Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    746746
    747747  double minimumvolume = TotalNoClusters * (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]);
    748   Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     748  DoLog(1) && (Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    749749  if (minimumvolume > cellvolume) {
    750     eLog() << Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl;
    751     Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl;
     750    DoeLog(1) && (eLog()<< Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl);
     751    DoLog(0) && (Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl);
    752752    for (int i = 0; i < NDIM; i++)
    753753      BoxLengths.x[i] = GreatestDiameter[i];
     
    761761    double x2 = 0.;
    762762    if (gsl_poly_solve_cubic(BoxLengths.x[0], BoxLengths.x[1], BoxLengths.x[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
    763       Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;
     763      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl);
    764764    else {
    765       Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl;
     765      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl);
    766766      x0 = x2; // sorted in ascending order
    767767    }
     
    774774
    775775    // set new box dimensions
    776     Log() << Verbose(0) << "Translating to box with these boundaries." << endl;
     776    DoLog(0) && (Log() << Verbose(0) << "Translating to box with these boundaries." << endl);
    777777    mol->SetBoxDimension(&BoxLengths);
    778778    mol->CenterInBox();
     
    780780  // update Box of atoms by boundary
    781781  mol->SetBoxDimension(&BoxLengths);
    782   Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     782  DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    783783};
    784784
     
    822822  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
    823823    if ((*ListRunner)->AtomCount > 0) {
    824       Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
     824      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
    825825      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
    826       Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
     826      DoLog(1) && (Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl);
    827827      TesselStruct[(*ListRunner)] = NULL;
    828828      FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL);
     
    832832  filler->CenterEdge(&Inserter);
    833833  filler->Center.Zero();
     834  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
     835  Binder = filler->first;
     836  while(Binder->next != filler->last) {
     837    Binder = Binder->next;
     838    DoLog(2) && (Log() << Verbose(2) << "  " << *Binder << endl);
     839  }
    834840
    835841  filler->CountAtoms();
     
    841847  for(int i=0;i<NDIM;i++)
    842848    N[i] = (int) ceil(1./FillerDistance.x[i]);
    843   Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
     849  DoLog(1) && (Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl);
    844850
    845851  // initialize seed of random number generator to current time
     
    856862        for (int i=0;i<NDIM;i++)
    857863          FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    858         Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl;
     864        DoLog(2) && (Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl);
    859865
    860866        // go through all atoms
     
    911917          // insert into Filling
    912918          if (FillIt) {
    913             Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl;
     919            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
    914920            // copy atom ...
    915921            CopyAtoms[Walker->nr] = new atom(Walker);
    916922            CopyAtoms[Walker->nr]->x.CopyVector(&Inserter);
    917923            Filling->AddAtom(CopyAtoms[Walker->nr]);
    918             Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl;
     924            DoLog(4) && (Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);
    919925          } else {
    920             Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl;
     926            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
    921927            CopyAtoms[Walker->nr] = NULL;
    922928            continue;
    923929          }
    924 
    925           // go through all bonds and add as well
    926           Binder = filler->first;
    927           while(Binder->next != filler->last) {
    928             Binder = Binder->next;
    929             if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
    930               Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
    931               Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    932             }
     930        }
     931        // go through all bonds and add as well
     932        Binder = filler->first;
     933        while(Binder->next != filler->last) {
     934          Binder = Binder->next;
     935          if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
     936            Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     937            Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    933938          }
    934939        }
     
    955960  bool freeLC = false;
    956961  bool status = false;
    957   CandidateForTesselation *baseline;
    958   LineMap::iterator testline;
     962  CandidateForTesselation *baseline = NULL;
    959963  bool OneLoopWithoutSuccessFlag = true;  // marks whether we went once through all baselines without finding any without two triangles
    960964  bool TesselationFailFlag = false;
    961   BoundaryTriangleSet *T = NULL;
    962965
    963966  if (TesselStruct == NULL) {
    964     Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl;
     967    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
    965968    TesselStruct= new Tesselation;
    966969  } else {
    967970    delete(TesselStruct);
    968     Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl;
     971    DoLog(1) && (Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl);
    969972    TesselStruct = new Tesselation;
    970973  }
     
    977980
    978981  // 1. get starting triangle
    979   TesselStruct->FindStartingTriangle(RADIUS, LCList);
     982  if (!TesselStruct->FindStartingTriangle(RADIUS, LCList)) {
     983    DoeLog(0) && (eLog() << Verbose(0) << "No valid starting triangle found." << endl);
     984    //performCriticalExit();
     985  }
     986  if (filename != NULL) {
     987    if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     988      TesselStruct->Output(filename, mol);
     989    }
     990  }
    980991
    981992  // 2. expand from there
    982993  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
    983     // 2a. fill all new OpenLines
    984     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
     994    (cerr << "There are " <<  TesselStruct->TrianglesOnBoundary.size() << " triangles and " << TesselStruct->OpenLines.size() << " open lines to scan for candidates." << endl);
     995    // 2a. print OpenLines without candidates
     996    DoLog(1) && (Log() << Verbose(1) << "There are the following open lines to scan for a candidates:" << endl);
    985997    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    986       Log() << Verbose(2) << *(Runner->second) << endl;
    987 
    988     for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
    989       baseline = Runner->second;
    990       if (baseline->pointlist.empty()) {
    991         T = (((baseline->BaseLine->triangles.begin()))->second);
    992         Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;
    993         TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    994       }
    995     }
    996 
    997     // 2b. search for smallest ShortestAngle among all candidates
     998      if (Runner->second->pointlist.empty())
     999        DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
     1000
     1001    // 2b. find best candidate for each OpenLine
     1002    TesselationFailFlag = TesselStruct->FindCandidatesforOpenLines(RADIUS, LCList);
     1003
     1004    // 2c. print OpenLines with candidates again
     1005    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
     1006    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
     1007      DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
     1008
     1009    // 2d. search for smallest ShortestAngle among all candidates
    9981010    double ShortestAngle = 4.*M_PI;
    999     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
    1000     for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    1001       Log() << Verbose(2) << *(Runner->second) << endl;
    1002 
    10031011    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
    10041012      if (Runner->second->ShortestAngle < ShortestAngle) {
    10051013        baseline = Runner->second;
    10061014        ShortestAngle = baseline->ShortestAngle;
    1007         //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
     1015        DoLog(1) && (Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *(*baseline->pointlist.begin()) << " and angle " << baseline->ShortestAngle << endl);
    10081016      }
    10091017    }
     1018    // 2e. if we found one, add candidate
    10101019    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
    10111020      OneLoopWithoutSuccessFlag = false;
    10121021    else {
    1013       TesselStruct->AddCandidateTriangle(*baseline);
    1014     }
    1015 
    1016     // write temporary envelope
     1022      TesselStruct->AddCandidatePolygon(*baseline, RADIUS, LCList);
     1023    }
     1024
     1025    // 2f. write temporary envelope
    10171026    if (filename != NULL) {
    10181027      if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     
    10491058  StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
    10501059
    1051   // correct degenerated polygons
    1052   TesselStruct->CorrectAllDegeneratedPolygons();
    1053 
    1054   // check envelope for consistency
    1055   status = CheckListOfBaselines(TesselStruct);
     1060//  // correct degenerated polygons
     1061//  TesselStruct->CorrectAllDegeneratedPolygons();
     1062//
     1063//  // check envelope for consistency
     1064//  status = CheckListOfBaselines(TesselStruct);
    10561065
    10571066  // write final envelope
Note: See TracChangeset for help on using the changeset viewer.