Changeset bdb143 for src/tesselation.cpp


Ignore:
Timestamp:
Jun 28, 2010, 3:38:05 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, Candidate_v1.7.0, 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:
13892b, 51a5c8
Parents:
b2531f (diff), c39cc4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Frederik Heber <heber@…> (06/28/10 14:53:18)
git-committer:
Frederik Heber <heber@…> (06/28/10 15:38:05)
Message:

Merge branch 'StructureRefactoring' into stable

Conflicts:

molecuilder/src/analysis_bonds.cpp
molecuilder/src/analysis_bonds.hpp
molecuilder/src/builder.cpp
molecuilder/src/unittests/Makefile.am
molecuilder/src/unittests/TestRunnerMain.cpp

  • TESTFIX: Tesselations/heptan - Due to different implementations of GetCircumCenter() sequence of triangles nodes has changed in degenerate case
  • TESTFIX: Tesselation/1-3 - Due to convexity criterion fourth argument (i.e. the value at the node) has changed.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    rb2531f rbdb143  
    231231{
    232232  Info FunctionInfo(__func__);
     233  double angle = CalculateConvexity();
     234  if (angle > -MYEPSILON) {
     235    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);
     236    return true;
     237  } else {
     238    DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);
     239    return false;
     240  }
     241}
     242
     243
     244/** Calculates the angle between two triangles with respect to their normal vector.
     245 * We sum the two angles of each height vector with respect to the center of the baseline.
     246 * \return angle > 0 then convex, if < 0 then concave
     247 */
     248double BoundaryLineSet::CalculateConvexity() const
     249{
     250  Info FunctionInfo(__func__);
    233251  Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;
    234252  // get the two triangles
     
    279297  BaseLineNormal.Scale(-1.);
    280298  double angle = GetAngle(helper[0], helper[1], BaseLineNormal);
    281   if ((angle - M_PI) > -MYEPSILON) {
    282     DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);
    283     return true;
    284   } else {
    285     DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);
    286     return false;
    287   }
     299  return (angle - M_PI);
    288300}
    289301
     
    304316/** Returns other endpoint of the line.
    305317 * \param *point other endpoint
    306  * \return NULL - if endpoint not contained in BoundaryLineSet, or pointer to BoundaryPointSet otherwise
     318 * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise
    307319 */
    308320class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
     
    315327  else
    316328    return NULL;
     329}
     330;
     331
     332/** Returns other triangle of the line.
     333 * \param *point other endpoint
     334 * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise
     335 */
     336class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const
     337{
     338  Info FunctionInfo(__func__);
     339  if (triangles.size() == 2) {
     340    for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner)
     341      if (TriangleRunner->second != triangle)
     342        return TriangleRunner->second;
     343  }
     344  return NULL;
    317345}
    318346;
     
    661689;
    662690
     691/** Returns the baseline which does not contain the given boundary point \a *point.
     692 * \param *point endpoint which is neither endpoint of the desired line
     693 * \return pointer to desired third baseline
     694 */
     695class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const
     696{
     697  Info FunctionInfo(__func__);
     698  // sanity check
     699  if (!ContainsBoundaryPoint(point))
     700    return NULL;
     701  for (int i = 0; i < 3; i++)
     702    if (!lines[i]->ContainsBoundaryPoint(point))
     703      return lines[i];
     704  // actually, that' impossible :)
     705  return NULL;
     706}
     707;
     708
    663709/** Calculates the center point of the triangle.
    664710 * Is third of the sum of all endpoints.
     
    11101156    TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));
    11111157
    1112     DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << OtherOptCenter << ":" << endl);
     1158    DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl);
    11131159    for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
    1114       DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->distance(OtherOptCenter) << "." << endl);
     1160      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl);
    11151161
    11161162    // remove baseline's endpoints and candidates
     
    11281174      DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl);
    11291175      for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
    1130         DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << endl);
     1176        DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl);
     1177
     1178      // check with animate_sphere.tcl VMD script
     1179      if (ThirdPoint != NULL) {
     1180        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
     1181      } else {
     1182        DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl);
     1183        DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
     1184      }
    11311185    }
    11321186    delete (ListofPoints);
    11331187
    1134     // check with animate_sphere.tcl VMD script
    1135     if (ThirdPoint != NULL) {
    1136       DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
    1137     } else {
    1138       DoLog(1) && (Log() << Verbose(1) << "Check by: ... missing third point ..." << endl);
    1139       DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);
    1140     }
    11411188  }
    11421189  return flag;
     
    32903337                        }
    32913338                      } else {
    3292                         DoLog(1) && (Log() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);
     3339                        DoeLog(0) && (eLog() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);
    32933340                      }
    32943341                    } else {
     
    45904637
    45914638  DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl);
    4592   IndexToIndex::iterator it;
    4593   for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
     4639  for (IndexToIndex::iterator it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
    45944640    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
    45954641
     
    46094655  int count = 0;
    46104656
    4611   for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) {
     4657  // iterate over all degenerated triangles
     4658  for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); !DegeneratedTriangles->empty(); TriangleKeyRunner = DegeneratedTriangles->begin()) {
     4659    DoLog(0) && (Log() << Verbose(0) << "Checking presence of triangles " << TriangleKeyRunner->first << " and " << TriangleKeyRunner->second << "." << endl);
     4660    // both ways are stored in the map, only use one
     4661    if (TriangleKeyRunner->first > TriangleKeyRunner->second)
     4662      continue;
     4663
     4664    // determine from the keys in the map the two _present_ triangles
    46124665    finder = TrianglesOnBoundary.find(TriangleKeyRunner->first);
    46134666    if (finder != TrianglesOnBoundary.end())
    46144667      triangle = finder->second;
    46154668    else
    4616       break;
     4669      continue;
    46174670    finder = TrianglesOnBoundary.find(TriangleKeyRunner->second);
    46184671    if (finder != TrianglesOnBoundary.end())
    46194672      partnerTriangle = finder->second;
    46204673    else
    4621       break;
    4622 
     4674      continue;
     4675
     4676    // determine which lines are shared by the two triangles
    46234677    bool trianglesShareLine = false;
    46244678    for (int i = 0; i < 3; ++i)
Note: See TracChangeset for help on using the changeset viewer.