Changeset 48b47a


Ignore:
Timestamp:
Jan 13, 2010, 2:01:55 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:
7b36fe
Parents:
9dbea5
Message:

FillWithMolecule() is now working correctly.

  • FillWithMolecule() was almost working except for some positions very much outside. The problem was that a single closest point was found and its first line seen as shortest, despite all other connected lines were equally short due the point always being the one with shortest distance. This kept triangles better aligned from being excluded as they not necessarily belong to the first line
  • This was fixed by introducing a LineSet ClosestLines in Tesselation::FindClosestTrianglesToVector().
    • If a candidate has equal distance, he is added to the list.
    • If a candidate has smaller distance, the list is cleared beforehand.
    • As only the adjacent triangles of the found lines are returned, depending routines don't notice the change.

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    r9dbea5 r48b47a  
    31353135  // for each point, check its lines, remember closest
    31363136  Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl;
    3137   BoundaryLineSet *ClosestLine = NULL;
     3137  LineSet ClosestLines;
    31383138  double MinDistance = 1e+16;
    31393139  Vector BaseLineIntersection;
     
    31573157
    31583158      if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) {  // intersection would be outside, take closer endpoint
    3159         if ((lengthEndA < MinDistance) && (lengthEndA < lengthEndB)) {
    3160           ClosestLine = LineRunner->second;
    3161           MinDistance = lengthEndA;
    3162           Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEndA << "." << endl;
    3163         } else if (lengthEndB < MinDistance) {
    3164           ClosestLine = LineRunner->second;
    3165           MinDistance = lengthEndB;
    3166           Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is closer with " << lengthEndB << "." << endl;
    3167         } else {
     3159        const double lengthEnd = Min(lengthEndA, lengthEndB);
     3160        if (lengthEnd - MinDistance < -MYEPSILON) { // new best line
     3161          ClosestLines.clear();
     3162          ClosestLines.insert(LineRunner->second);
     3163          MinDistance = lengthEnd;
     3164          Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl;
     3165        } else if  (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate
     3166          ClosestLines.insert(LineRunner->second);
     3167          Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl;
     3168        } else { // line is worse
    31683169          Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl;
    31693170        }
     
    31793180          eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl;
    31803181        }
    3181         if ((ClosestLine == NULL) || (distance < MinDistance)) {
    3182           ClosestLine = LineRunner->second;
     3182        if ((ClosestLines.empty()) || (distance < MinDistance)) {
     3183          ClosestLines.insert(LineRunner->second);
    31833184          MinDistance = distance;
    3184           Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl;
     3185          Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl;
    31853186        } else {
    31863187          Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl;
     
    31923193
    31933194  // check whether closest line is "too close" :), then it's inside
    3194   if (ClosestLine == NULL) {
     3195  if (ClosestLines.empty()) {
    31953196    Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl;
    31963197    return NULL;
    31973198  }
    31983199  TriangleList * candidates = new TriangleList;
    3199   for (TriangleMap::iterator Runner = ClosestLine->triangles.begin(); Runner != ClosestLine->triangles.end(); Runner++) {
     3200  for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++)
     3201    for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) {
    32003202    candidates->push_back(Runner->second);
    32013203  }
Note: See TracChangeset for help on using the changeset viewer.