Changeset 75d42a for src/Tesselation/tesselation.cpp
- Timestamp:
- Oct 19, 2014, 5:13:10 PM (10 years ago)
- 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:
- dfe054
- Parents:
- c2f306
- git-author:
- Frederik Heber <heber@…> (09/25/14 18:23:50)
- git-committer:
- Frederik Heber <heber@…> (10/19/14 17:13:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tesselation/tesselation.cpp
rc2f306 r75d42a 35 35 #include "CodePatterns/MemDebug.hpp" 36 36 37 #include <algorithm> 38 #include <boost/foreach.hpp> 37 39 #include <fstream> 38 40 #include <iomanip> 41 #include <iterator> 39 42 #include <sstream> 40 43 … … 731 734 * @param *b second endpoint 732 735 * @param n index of Tesselation::BLS giving the line with both endpoints 733 */ 734 void Tesselation::AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) 736 * @return true - inserted a new line, false - present line used 737 */ 738 bool Tesselation::AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) 735 739 { 736 740 bool insertNewLine = true; … … 784 788 AddExistingTesselationTriangleLine(WinningLine, n); 785 789 } 790 791 return insertNewLine; 786 792 } 787 793 ; … … 3198 3204 ; 3199 3205 3206 struct CloserToPiHalf 3207 { 3208 bool operator()(double angle, double smallestangle) { 3209 return (fabs(angle - M_PI/2.) < fabs(smallestangle - M_PI/2.)); 3210 } 3211 }; 3212 3200 3213 /** Removes a boundary point from the envelope while keeping it closed. 3201 3214 * We remove the old triangles connected to the point and re-create new triangles to close the surface following this ansatz: … … 3262 3275 // TriangleMap::iterator NumberRunner = Candidates.begin(); 3263 3276 TesselPointList::iterator StartNode, MiddleNode, EndNode; 3264 double angle;3265 double smallestangle;3266 3277 Vector Point, Reference, OrthogonalVector; 3267 3278 if (count > 2) { // less than three triangles, then nothing will be created … … 3275 3286 // re-create all triangles by going through connected points list 3276 3287 LineList NewLines; 3288 typedef std::vector<double> angles_t; 3289 angles_t angles; 3277 3290 for (; !connectedPath->empty();) { 3278 3291 // search middle node with widest angle to next neighbours 3279 3292 EndNode = connectedPath->end(); 3280 smallestangle = 0.;3281 3293 for (MiddleNode = connectedPath->begin(); MiddleNode != connectedPath->end(); MiddleNode++) { 3282 3294 LOG(1, "INFO: MiddleNode is " << **MiddleNode << "."); … … 3296 3308 OrthogonalVector = ((*MiddleNode)->getPosition()) - OldPoint; 3297 3309 OrthogonalVector.MakeNormalTo(Reference); 3298 angle = GetAngle(Point, Reference, OrthogonalVector); 3299 //if (angle < M_PI) // no wrong-sided triangles, please? 3300 if (fabs(angle - M_PI) < fabs(smallestangle - M_PI)) { // get straightest angle (i.e. construct those triangles with smallest area first) 3301 smallestangle = angle; 3302 EndNode = MiddleNode; 3303 } 3310 angles.push_back( GetAngle(Point, Reference, OrthogonalVector) ); 3304 3311 } 3312 const angles_t::const_iterator maxiter = std::max_element(angles.begin(), angles.end()); 3313 angles_t::const_iterator miniter = angles.begin(); 3314 // distinguish between convex and nonconvex polygon 3315 if (*maxiter > M_PI) { 3316 // connectedPath is not convex 3317 miniter = std::min_element(angles.begin(), angles.end()); 3318 } else { 3319 // is convex 3320 miniter = std::min_element(angles.begin(), angles.end(), CloserToPiHalf()); 3321 } 3322 EndNode = connectedPath->begin(); 3323 std::advance(EndNode, 3324 std::distance(const_cast<const angles_t &>(angles).begin(), miniter)); 3325 angles.clear(); 3326 3305 3327 MiddleNode = EndNode; 3306 if (MiddleNode == connectedPath->end()) { 3307 ELOG(0, "CRITICAL: Could not find a smallest angle!"); 3308 performCriticalExit(); 3309 } 3328 ASSERT( MiddleNode == connectedPath->end(), 3329 "Tesselation::RemovePointFromTesselatedSurface() - Could not find a smallest angle!"); 3310 3330 StartNode = MiddleNode; 3311 3331 if (StartNode == connectedPath->begin()) … … 3347 3367 LOG(3, "Adding new triangle lines."); 3348 3368 AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0); 3349 AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1); 3350 NewLines.push_back(BLS[1]); 3369 // line between start and end must be new (except for very last triangle) 3370 if (AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1)) 3371 NewLines.push_back(BLS[1]); 3351 3372 AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2); 3352 3373 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
Note:
See TracChangeset
for help on using the changeset viewer.