Changeset 7c14ec


Ignore:
Timestamp:
Aug 18, 2009, 1:59:11 PM (15 years ago)
Author:
Saskia Metzler <metzler@…>
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:
34e0592
Parents:
f1cccd
Message:

Ticket 15: new function RemoveDegeneratedTriangles()
Added functions to find and remove surplus degenerated triangles.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    rf1cccd r7c14ec  
    12161216  }
    12171217
     1218  // Purges surplus triangles.
     1219  mol->TesselStruct->RemoveDegeneratedTriangles();
     1220
    12181221  // write final envelope
    12191222  if (filename != 0) {
     
    12821285//    << "for atom " << a << " (inside)." << endl;
    12831286
    1284 
    12851287  if (freeLC)
    12861288    delete(LCList);
  • src/tesselation.cpp

    rf1cccd r7c14ec  
    28022802};
    28032803
    2804 
    2805 
    28062804/**
    28072805 * Finds the point which is closest to the provided one.
     
    28602858  return closestPoint;
    28612859};
    2862 
    28632860
    28642861/**
     
    29272924}
    29282925
     2926/**
     2927 * Finds all degenerated triangles within the tesselation structure.
     2928 *
     2929 * @return map of keys of degenerated triangle pairs, each triangle occurs twice
     2930 *         in the list, once as key and once as value
     2931 */
     2932map<int, int> Tesselation::FindAllDegeneratedTriangles()
     2933{
     2934  map<int, int> DegeneratedTriangles;
     2935
     2936  // sanity check
     2937  if (LinesOnBoundary.empty()) {
     2938    cout << Verbose(1) << "Warning: FindAllDegeneratedTriangles() was called without any tesselation structure.";
     2939    return DegeneratedTriangles;
     2940  }
     2941
     2942  LineMap::iterator LineRunner1, LineRunner2;
     2943
     2944  for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) {
     2945    for (LineRunner2 = LinesOnBoundary.begin(); LineRunner2 != LinesOnBoundary.end(); ++LineRunner2) {
     2946      if ((LineRunner1->second != LineRunner2->second)
     2947        && (LineRunner1->second->endpoints[0] == LineRunner2->second->endpoints[0])
     2948        && (LineRunner1->second->endpoints[1] == LineRunner2->second->endpoints[1])
     2949      ) {
     2950        TriangleMap::iterator TriangleRunner1 = LineRunner1->second->triangles.begin(),
     2951          TriangleRunner2 = LineRunner2->second->triangles.begin();
     2952
     2953        for (; TriangleRunner1 != LineRunner1->second->triangles.end(); ++TriangleRunner1) {
     2954          for (; TriangleRunner2 != LineRunner2->second->triangles.end(); ++TriangleRunner2) {
     2955            if ((TriangleRunner1->second != TriangleRunner2->second)
     2956              && (TriangleRunner1->second->endpoints[0] == TriangleRunner2->second->endpoints[0])
     2957              && (TriangleRunner1->second->endpoints[1] == TriangleRunner2->second->endpoints[1])
     2958              && (TriangleRunner1->second->endpoints[2] == TriangleRunner2->second->endpoints[2])
     2959            ) {
     2960              DegeneratedTriangles[TriangleRunner1->second->Nr] = TriangleRunner2->second->Nr;
     2961              DegeneratedTriangles[TriangleRunner2->second->Nr] = TriangleRunner1->second->Nr;
     2962            }
     2963          }
     2964        }
     2965      }
     2966    }
     2967  }
     2968
     2969  cout << Verbose(1) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles.size() << " triangles." << endl;
     2970  map<int,int>::iterator it;
     2971  for (it = DegeneratedTriangles.begin(); it != DegeneratedTriangles.end(); it++)
     2972      cout << Verbose(2) << (*it).first << " => " << (*it).second << endl;
     2973
     2974  return DegeneratedTriangles;
     2975}
     2976
     2977/**
     2978 * Purges degenerated triangles from the tesselation structure if they are not
     2979 * necessary to keep a single point within the structure.
     2980 */
     2981void Tesselation::RemoveDegeneratedTriangles()
     2982{
     2983  map<int, int> DegeneratedTriangles = FindAllDegeneratedTriangles();
     2984
     2985  for (map<int, int>::iterator TriangleKeyRunner = DegeneratedTriangles.begin();
     2986    TriangleKeyRunner != DegeneratedTriangles.end(); ++TriangleKeyRunner
     2987  ) {
     2988    BoundaryTriangleSet *triangle = TrianglesOnBoundary.find(TriangleKeyRunner->first)->second,
     2989      *partnerTriangle = TrianglesOnBoundary.find(TriangleKeyRunner->second)->second;
     2990
     2991    bool trianglesShareLine = false;
     2992    for (int i = 0; i < 3; ++i)
     2993      for (int j = 0; j < 3; ++j)
     2994        trianglesShareLine = trianglesShareLine || triangle->lines[i] == partnerTriangle->lines[j];
     2995
     2996    if (trianglesShareLine
     2997      && (triangle->endpoints[1]->LinesCount > 2)
     2998      && (triangle->endpoints[2]->LinesCount > 2)
     2999      && (triangle->endpoints[0]->LinesCount > 2)
     3000    ) {
     3001      cout << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl;
     3002      RemoveTesselationTriangle(triangle);
     3003      cout << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl;
     3004      RemoveTesselationTriangle(partnerTriangle);
     3005      DegeneratedTriangles.erase(DegeneratedTriangles.find(partnerTriangle->Nr));
     3006    } else {
     3007      cout << Verbose(1) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle
     3008        << " and its partner " << *partnerTriangle << " because it is essential for at"
     3009        << " least one of the endpoints to be kept in the tesselation structure." << endl;
     3010    }
     3011  }
     3012}
     3013
    29293014/** Gets the angle between a point and a reference relative to the provided center.
    29303015 * We have two shanks point and reference between which the angle is calculated
  • src/tesselation.hpp

    rf1cccd r7c14ec  
    2020#include <map>
    2121#include <list>
     22#include <set>
    2223
    2324
     
    217218    bool PickFarthestofTwoBaselines(ofstream *out, class BoundaryLineSet *Base);
    218219    class BoundaryPointSet *IsConvexRectangle(ofstream *out, class BoundaryLineSet *Base);
    219 
     220    map<int, int> FindAllDegeneratedTriangles();
     221    void RemoveDegeneratedTriangles();
    220222
    221223    list<TesselPoint*> * GetCircleOfConnectedPoints(ofstream *out, TesselPoint* Point);
Note: See TracChangeset for help on using the changeset viewer.