Changeset 1e168b for src


Ignore:
Timestamp:
Nov 25, 2009, 12:18:18 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
8725ed
Parents:
791138
Message:

Now the best (in terms of ShortestAngle) baseline is picked among all open ones instead of the next.

  • Element initialization was done for all constructors in tesselation.cpp
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r791138 r1e168b  
    955955{
    956956  bool freeLC = false;
    957   LineMap::iterator baseline;
     957  CandidateForTesselation *baseline;
    958958  LineMap::iterator testline;
    959   bool OneLoopWithoutSuccessFlag = false;  // marks whether we went once through all baselines without finding any without two triangles
     959  bool OneLoopWithoutSuccessFlag = true;  // marks whether we went once through all baselines without finding any without two triangles
    960960  bool TesselationFailFlag = false;
    961961
     
    982982
    983983  // 2. expand from there
    984   baseline = TesselStruct->LinesOnBoundary.begin();
    985   baseline++; // skip first line
    986   while ((baseline != TesselStruct->LinesOnBoundary.end()) || (OneLoopWithoutSuccessFlag)) {
    987     if (baseline->second->triangles.size() == 1) {
    988       CheckListOfBaselines(TesselStruct);
    989       // 3. find next triangle
    990       TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    991       OneLoopWithoutSuccessFlag = OneLoopWithoutSuccessFlag || TesselationFailFlag;
    992       if (!TesselationFailFlag)
    993         eLog() << Verbose(2) << "FindNextSuitableTriangle failed." << endl;
    994 
    995       // write temporary envelope
    996       if (filename != NULL) {
    997         if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
    998           TesselStruct->Output(filename, mol);
    999         }
     984  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
     985    // 2a. fill all new OpenLines
     986    Log() << Verbose(0) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
     987    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
     988      Log() << Verbose(1) << *(Runner->second) << endl;
     989
     990    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     991      baseline = Runner->second;
     992      if (baseline->point == NULL) {
     993        Log() << Verbose(0) << "Finding best candidate for open line " << *baseline->BaseLine << endl;
     994        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *(((baseline->BaseLine->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    1000995      }
    1001       if (TesselationFailFlag) {
    1002         baseline = TesselStruct->LinesOnBoundary.begin();
    1003         OneLoopWithoutSuccessFlag = false;
    1004         Log() << Verbose(2) << "Baseline set to begin." << endl;
     996    }
     997
     998    // 2b. search for smallest ShortestAngle among all candidates
     999    double ShortestAngle = 4.*M_PI;
     1000    Log() << Verbose(0) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
     1001    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
     1002      Log() << Verbose(1) << *(Runner->second) << endl;
     1003
     1004    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     1005      if (Runner->second->ShortestAngle < ShortestAngle) {
     1006        baseline = Runner->second;
     1007        ShortestAngle = baseline->ShortestAngle;
     1008        //Log() << Verbose(0) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
    10051009      }
    1006     } else {
    1007       //Log() << Verbose(1) << "Line " << *baseline->second << " has " << baseline->second->triangles.size() << " triangles adjacent" << endl;
    1008       if (baseline->second->triangles.size() != 2) {
    1009         eLog() << Verbose(0) << "TESSELATION FINISHED WITH INVALID TRIANGLE COUNT!" << endl;
    1010         performCriticalExit();
     1010    }
     1011    if ((ShortestAngle == 4.*M_PI) || (baseline->point == NULL))
     1012      OneLoopWithoutSuccessFlag = false;
     1013    else {
     1014      TesselStruct->AddCandidateTriangle(*baseline);
     1015    }
     1016
     1017    // write temporary envelope
     1018    if (filename != NULL) {
     1019      if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     1020        TesselStruct->Output(filename, mol);
    10111021      }
    10121022    }
    1013 
    1014     if ((baseline == TesselStruct->LinesOnBoundary.end()) && (OneLoopWithoutSuccessFlag)) {
    1015       baseline = TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
    1016       OneLoopWithoutSuccessFlag = false;
    1017     }
    1018     baseline++;
    10191023  }
    10201024  // check envelope for consistency
  • src/tesselation.cpp

    r791138 r1e168b  
    2222/** Constructor of BoundaryPointSet.
    2323 */
    24 BoundaryPointSet::BoundaryPointSet()
    25 {
    26   LinesCount = 0;
    27   Nr = -1;
    28   value = 0.;
     24BoundaryPointSet::BoundaryPointSet() :
     25    LinesCount(0),
     26    value(0.),
     27    Nr(-1)
     28{
    2929};
    3030
     
    8585/** Constructor of BoundaryLineSet.
    8686 */
    87 BoundaryLineSet::BoundaryLineSet()
     87BoundaryLineSet::BoundaryLineSet() :
     88    Nr(-1)
    8889{
    8990  for (int i = 0; i < 2; i++)
    9091    endpoints[i] = NULL;
    91   Nr = -1;
    9292};
    9393
     
    106106  Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
    107107  Point[1]->AddLine(this); //
     108  // set skipped to false
     109  skipped = false;
    108110  // clear triangles list
    109111  Log() << Verbose(5) << "New Line with endpoints " << *this << "." << endl;
     
    286288/** Constructor for BoundaryTriangleSet.
    287289 */
    288 BoundaryTriangleSet::BoundaryTriangleSet()
     290BoundaryTriangleSet::BoundaryTriangleSet() :
     291  Nr(-1)
    289292{
    290293  for (int i = 0; i < 3; i++)
     
    293296      lines[i] = NULL;
    294297    }
    295   Nr = -1;
    296298};
    297299
     
    300302 * \param number number of triangle
    301303 */
    302 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet *line[3], int number)
     304BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet *line[3], int number) :
     305  Nr(number)
    303306{
    304307  // set number
    305   Nr = number;
    306308  // set lines
    307   Log() << Verbose(5) << "New triangle " << Nr << ":" << endl;
     309  Log() << Verbose(5) << "New triangle " << Nr << ":";
    308310  for (int i = 0; i < 3; i++)
    309311    {
     
    579581PointCloud::PointCloud()
    580582{
    581 
    582583};
    583584
     
    586587PointCloud::~PointCloud()
    587588{
    588 
    589589};
    590590
     
    593593/** Constructor of class CandidateForTesselation.
    594594 */
    595 CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) {
    596   point = candidate;
    597   BaseLine = line;
     595CandidateForTesselation::CandidateForTesselation (BoundaryLineSet* line) :
     596  point(NULL),
     597  BaseLine(line),
     598  ShortestAngle(2.*M_PI),
     599  OtherShortestAngle(2.*M_PI)
     600{
     601};
     602
     603
     604/** Constructor of class CandidateForTesselation.
     605 */
     606CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
     607    point(candidate),
     608    BaseLine(line),
     609    ShortestAngle(2.*M_PI),
     610    OtherShortestAngle(2.*M_PI)
     611{
    598612  OptCenter.CopyVector(&OptCandidateCenter);
    599613  OtherOptCenter.CopyVector(&OtherOptCandidateCenter);
     
    607621};
    608622
     623/** output operator for CandidateForTesselation.
     624 * \param &ost output stream
     625 * \param &a boundary line
     626 */
     627ostream & operator <<(ostream &ost, const  CandidateForTesselation &a)
     628{
     629  ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->Name << "," << a.BaseLine->endpoints[1]->node->Name << "] with ";
     630  if (a.point == NULL)
     631    ost << "no candidate.";
     632  else
     633    ost << "candidate " << *(a.point) << " at angle " << (a.ShortestAngle)<< ".";
     634
     635  return ost;
     636};
     637
     638
    609639// =========================================================== class TESSELATION ===========================================
    610640
    611641/** Constructor of class Tesselation.
    612642 */
    613 Tesselation::Tesselation()
    614 {
    615   PointsOnBoundaryCount = 0;
    616   LinesOnBoundaryCount = 0;
    617   TrianglesOnBoundaryCount = 0;
    618   InternalPointer = PointsOnBoundary.begin();
    619   LastTriangle = NULL;
    620   TriangleFilesWritten = 0;
     643Tesselation::Tesselation() :
     644  PointsOnBoundaryCount(0),
     645  LinesOnBoundaryCount(0),
     646  TrianglesOnBoundaryCount(0),
     647  LastTriangle(NULL),
     648  TriangleFilesWritten(0),
     649  InternalPointer(PointsOnBoundary.begin())
     650{
    621651}
    622652;
     
    12831313        BLS[n] = FindLine->second;
    12841314
     1315        // remove existing line from OpenLines
     1316        CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]);
     1317        delete(CandidateLine->second);
     1318        OpenLines.erase(CandidateLine);
     1319
    12851320        break;
    12861321      }
     
    13041339void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
    13051340{
    1306   Log() << Verbose(4) << "Adding line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;
     1341  Log() << Verbose(4) << "Adding open line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;
    13071342  BPS[0] = a;
    13081343  BPS[1] = b;
     
    13121347  // increase counter
    13131348  LinesOnBoundaryCount++;
     1349  // also add to open lines
     1350  CandidateForTesselation *CFT = new CandidateForTesselation(BLS[n]);
     1351  OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT));
    13141352};
    13151353
     
    16801718      << *(*it)->point << " with normal vector " << BTS->NormalVector << ".\n";
    16811719
    1682       // if we do not reach the end with the next step of iteration, we need to setup a new first line
    1683       if (it != OptCandidates->end()--) {
    1684         FirstPoint = (*it)->BaseLine->endpoints[0]->node;
    1685         SecondPoint = (*it)->point;
    1686         // adding point 1 and point 2 and the line between them
    1687         AddTesselationPoint(FirstPoint, 0);
    1688         AddTesselationPoint(SecondPoint, 1);
    1689         AddTesselationLine(TPS[0], TPS[1], 0);
    1690       }
     1720//      // if we do not reach the end with the next step of iteration, we need to setup a new first line
     1721//      if (it != OptCandidates->end()--) {
     1722//        FirstPoint = (*it)->BaseLine->endpoints[0]->node;
     1723//        SecondPoint = (*it)->point;
     1724//        // adding point 1 and point 2 and the line between them
     1725//        AddTesselationPoint(FirstPoint, 0);
     1726//        AddTesselationPoint(SecondPoint, 1);
     1727//        AddTesselationLine(TPS[0], TPS[1], 0);
     1728//      }
    16911729      Log() << Verbose(2) << "Projection is " << BTS->NormalVector.ScalarProduct(&Oben) << "." << endl;
    16921730    }
     
    18601898/** This function finds a triangle to a line, adjacent to an existing one.
    18611899 * @param out output stream for debugging
    1862  * @param Line current baseline to search from
     1900 * @param CandidateLine current cadndiate baseline to search from
    18631901 * @param T current triangle which \a Line is edge of
    18641902 * @param RADIUS radius of the rolling ball
     
    18661904 * @param *LC LinkedCell structure with neighbouring points
    18671905 */
    1868 bool Tesselation::FindNextSuitableTriangle(BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
     1906bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
    18691907{
    18701908  Log() << Verbose(0) << "Begin of FindNextSuitableTriangle\n";
     
    18821920  double radius, CircleRadius;
    18831921
    1884   Log() << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl;
     1922  Log() << Verbose(1) << "Current baseline is " << *CandidateLine.BaseLine << " of triangle " << T << "." << endl;
    18851923  for (int i=0;i<3;i++)
    1886     if ((T.endpoints[i]->node != Line.endpoints[0]->node) && (T.endpoints[i]->node != Line.endpoints[1]->node))
     1924    if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node))
    18871925      ThirdNode = T.endpoints[i]->node;
    18881926
    18891927  // construct center of circle
    1890   CircleCenter.CopyVector(Line.endpoints[0]->node->node);
    1891   CircleCenter.AddVector(Line.endpoints[1]->node->node);
     1928  CircleCenter.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
     1929  CircleCenter.AddVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    18921930  CircleCenter.Scale(0.5);
    18931931
    18941932  // construct normal vector of circle
    1895   CirclePlaneNormal.CopyVector(Line.endpoints[0]->node->node);
    1896   CirclePlaneNormal.SubtractVector(Line.endpoints[1]->node->node);
     1933  CirclePlaneNormal.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
     1934  CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    18971935
    18981936  // calculate squared radius of circle
     
    19061944    GetCenterofCircumcircle(&OldSphereCenter, *T.endpoints[0]->node->node, *T.endpoints[1]->node->node, *T.endpoints[2]->node->node);
    19071945    helper.CopyVector(&T.NormalVector);  // normal vector ensures that this is correct center of the two possible ones
    1908     radius = Line.endpoints[0]->node->node->DistanceSquared(&OldSphereCenter);
     1946    radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&OldSphereCenter);
    19091947    helper.Scale(sqrt(RADIUS*RADIUS - radius));
    19101948    OldSphereCenter.AddVector(&helper);
     
    19141952    // construct SearchDirection
    19151953    SearchDirection.MakeNormalVector(&T.NormalVector, &CirclePlaneNormal);
    1916     helper.CopyVector(Line.endpoints[0]->node->node);
     1954    helper.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
    19171955    helper.SubtractVector(ThirdNode->node);
    19181956    if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
     
    19271965
    19281966    // add third point
    1929     FindThirdPointForTesselation(T.NormalVector, SearchDirection, OldSphereCenter, &Line, ThirdNode, OptCandidates, &ShortestAngle, RADIUS, LC);
     1967    FindThirdPointForTesselation(T.NormalVector, SearchDirection, OldSphereCenter, CandidateLine.BaseLine, ThirdNode, OptCandidates, &ShortestAngle, RADIUS, LC);
    19301968
    19311969  } else {
    1932     Log() << Verbose(1) << "Circumcircle for base line " << Line << " and base triangle " << T << " is too big!" << endl;
     1970    Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and base triangle " << T << " is too big!" << endl;
    19331971  }
    19341972
     
    19421980  }
    19431981
    1944   BoundaryLineSet *BaseRay = &Line;
     1982  BoundaryLineSet *BaseRay = CandidateLine.BaseLine;
    19451983  for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    19461984    Log() << Verbose(1) << " Third point candidate is " << *(*it)->point
     
    19692007
    19702008        if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
    1971           AddTesselationLine(TPS[0], TPS[1], 0);
    1972           AddTesselationLine(TPS[0], TPS[2], 1);
    1973           AddTesselationLine(TPS[1], TPS[2], 2);
    1974 
    1975           BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    1976           AddTesselationTriangle();
    1977           (*it)->OptCenter.Scale(-1.);
    1978           BTS->GetNormalVector((*it)->OptCenter);
    1979           (*it)->OptCenter.Scale(-1.);
    1980 
    1981           Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector
    1982             << " for this triangle ... " << endl;
    1983         //Log() << Verbose(1) << "We have "<< TrianglesOnBoundaryCount << " for line " << *BaseRay << "." << endl;
     2009          CandidateLine.point = (*it)->point;
     2010          CandidateLine.OptCenter.CopyVector(&((*it)->OptCenter));
     2011          CandidateLine.OtherOptCenter.CopyVector(&((*it)->OtherOptCenter));
     2012          CandidateLine.ShortestAngle = ShortestAngle;
    19842013        } else {
    1985           eLog() << Verbose(2) << "This triangle consisting of ";
    1986           Log() << Verbose(0) << *(*it)->point << ", ";
    1987           Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    1988           Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    1989           Log() << Verbose(0) << "exists and is not added, as it does not seem helpful!" << endl;
     2014//          eLog() << Verbose(2) << "This triangle consisting of ";
     2015//          Log() << Verbose(0) << *(*it)->point << ", ";
     2016//          Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
     2017//          Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
     2018//          Log() << Verbose(0) << "exists and is not added, as it 0x80000000006fc150(does not seem helpful!" << endl;
    19902019          result = false;
    19912020        }
     
    19972026          // We demand that at most one new degenerate line is created and that this line also already exists (which has to be the case due to existentTrianglesCount == 1)
    19982027          // i.e. at least one of the three lines must be present with TriangleCount <= 1
    1999           if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS)) {
    2000             AddTesselationLine(TPS[0], TPS[1], 0);
    2001             AddTesselationLine(TPS[0], TPS[2], 1);
    2002             AddTesselationLine(TPS[1], TPS[2], 2);
    2003 
    2004             BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    2005             AddTesselationTriangle();  // add to global map
    2006 
    2007             (*it)->OtherOptCenter.Scale(-1.);
    2008             BTS->GetNormalVector((*it)->OtherOptCenter);
    2009             (*it)->OtherOptCenter.Scale(-1.);
    2010 
    2011             eLog() << Verbose(2) << "--> WARNING: Special new triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " for this triangle ... " << endl;
    2012             Log() << Verbose(1) << "We have "<< BaseRay->triangles.size() << " for line " << BaseRay << "." << endl;
     2028          if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS) || CandidateLine.BaseLine->skipped) {
     2029            CandidateLine.point = (*it)->point;
     2030            CandidateLine.OptCenter.CopyVector(&(*it)->OptCenter);
     2031            CandidateLine.OtherOptCenter.CopyVector(&(*it)->OtherOptCenter);
     2032            CandidateLine.ShortestAngle = ShortestAngle+2.*M_PI;
     2033
    20132034          } else {
    2014             eLog() << Verbose(2) << "This triangle consisting of " << *(*it)->point << ", " << *BaseRay->endpoints[0]->node << " and " << *BaseRay->endpoints[1]->node << " " << "exists and is not added, as it does not seem helpful!" << endl;
     2035//            eLog() << Verbose(2) << "This triangle consisting of " << *(*it)->point << ", " << *BaseRay->endpoints[0]->node << " and " << *BaseRay->endpoints[1]->node << " " << "exists and is not added, as it does not seem helpful!" << endl;
    20152036            result = false;
    20162037          }
    20172038      } else {
    2018         Log() << Verbose(1) << "This triangle consisting of ";
    2019         Log() << Verbose(0) << *(*it)->point << ", ";
    2020         Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    2021         Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    2022         Log() << Verbose(0) << "is invalid!" << endl;
     2039//        Log() << Verbose(1) << "This triangle consisting of ";
     2040//        Log() << Verbose(0) << *(*it)->point << ", ";
     2041//        Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
     2042//        Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
     2043//        Log() << Verbose(0) << "is invalid!" << endl;
    20232044        result = false;
    20242045      }
     
    20432064  Log() << Verbose(0) << "End of FindNextSuitableTriangle\n";
    20442065  return result;
     2066};
     2067
     2068/** Adds the present line and candidate point from \a &CandidateLine to the Tesselation.
     2069 * \param &CandidateLine triangle to add
     2070 */
     2071void Tesselation::AddCandidateTriangle(CandidateForTesselation &CandidateLine)
     2072{
     2073  Vector Center;
     2074  Log() << Verbose(2) << "BaseLine is :" << *(CandidateLine.BaseLine) << " with candidate " << *(CandidateLine.point) << "." << endl;
     2075  // add the points
     2076  AddTesselationPoint(CandidateLine.point, 0);
     2077  AddTesselationPoint(CandidateLine.BaseLine->endpoints[0]->node, 1);
     2078  AddTesselationPoint(CandidateLine.BaseLine->endpoints[1]->node, 2);
     2079
     2080  Center.CopyVector(&CandidateLine.OptCenter);
     2081  // add the lines
     2082  AddTesselationLine(TPS[0], TPS[1], 0);
     2083  AddTesselationLine(TPS[0], TPS[2], 1);
     2084  AddTesselationLine(TPS[1], TPS[2], 2);
     2085
     2086  // add the triangles
     2087  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     2088  AddTesselationTriangle();
     2089  Center.Scale(-1.);
     2090  BTS->GetNormalVector(Center);
     2091
     2092  Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " for this triangle ... " << endl;
    20452093};
    20462094
  • src/tesselation.hpp

    r791138 r1e168b  
    5353#define PointTestPair pair < PointMap::iterator, bool >
    5454#define CandidateList list <class CandidateForTesselation *>
     55#define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>
    5556
    5657#define LineMap multimap < int, class BoundaryLineSet * >
     
    114115    TriangleMap triangles;
    115116    int Nr;
     117    bool skipped;
    116118};
    117119
     
    186188class CandidateForTesselation {
    187189  public :
     190  CandidateForTesselation(BoundaryLineSet* currentBaseLine);
    188191  CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
    189192  ~CandidateForTesselation();
     
    193196  Vector OptCenter;
    194197  Vector OtherOptCenter;
    195 };
     198  double ShortestAngle;
     199  double OtherShortestAngle;
     200};
     201
     202ostream & operator <<(ostream &ost, const  CandidateForTesselation &a);
    196203
    197204// =========================================================== class TESSELATION ===========================================
     
    211218    void AddTesselationTriangle();
    212219    void AddTesselationTriangle(const int nr);
     220    void AddCandidateTriangle(CandidateForTesselation &CandidateLine);
    213221    void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
    214222    void RemoveTesselationLine(class BoundaryLineSet *line);
     
    220228    void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
    221229    void FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, class BoundaryLineSet *BaseLine, const class TesselPoint * const ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, const LinkedCell *LC) const;
    222     bool FindNextSuitableTriangle(BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
     230    bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
    223231    int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
    224232    class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]);
     
    260268    PointMap PointsOnBoundary;
    261269    LineMap LinesOnBoundary;
     270    CandidateMap OpenLines;
    262271    TriangleMap TrianglesOnBoundary;
    263272    int PointsOnBoundaryCount;
Note: See TracChangeset for help on using the changeset viewer.