Changeset 34c43a for src/tesselation.cpp
- Timestamp:
- Mar 1, 2011, 10:16:38 AM (14 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:
- caa06ef
- Parents:
- ba5215
- git-author:
- Frederik Heber <heber@…> (02/21/11 18:02:41)
- git-committer:
- Frederik Heber <heber@…> (03/01/11 10:16:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tesselation.cpp
rba5215 r34c43a 23 23 #include <iomanip> 24 24 25 #include "Helpers/helpers.hpp"26 #include "CodePatterns/Info.hpp"27 25 #include "BoundaryPointSet.hpp" 28 26 #include "BoundaryLineSet.hpp" 29 27 #include "BoundaryTriangleSet.hpp" 30 28 #include "BoundaryPolygonSet.hpp" 31 #include "TesselPoint.hpp"32 29 #include "CandidateForTesselation.hpp" 33 #include "PointCloud.hpp" 34 #include "linkedcell.hpp" 30 #include "CodePatterns/Assert.hpp" 31 #include "CodePatterns/Info.hpp" 32 #include "CodePatterns/IteratorAdaptors.hpp" 35 33 #include "CodePatterns/Log.hpp" 36 #include "tesselation.hpp" 37 #include "tesselationhelpers.hpp" 38 #include "triangleintersectionlist.hpp" 34 #include "CodePatterns/Verbose.hpp" 35 #include "Exceptions/LinearDependenceException.hpp" 36 #include "Helpers/fast_functions.hpp" 37 #include "Helpers/helpers.hpp" 38 #include "IPointCloud.hpp" 39 39 #include "LinearAlgebra/Vector.hpp" 40 40 #include "LinearAlgebra/Line.hpp" 41 41 #include "LinearAlgebra/vector_ops.hpp" 42 #include "CodePatterns/Verbose.hpp"43 42 #include "LinearAlgebra/Plane.hpp" 44 #include "Exceptions/LinearDependenceException.hpp" 45 #include "CodePatterns/Assert.hpp" 46 47 #include "Helpers/fast_functions.hpp" 43 #include "linkedcell.hpp" 44 #include "PointCloudAdaptor.hpp" 45 #include "tesselation.hpp" 46 #include "tesselationhelpers.hpp" 47 #include "TesselPoint.hpp" 48 #include "triangleintersectionlist.hpp" 48 49 49 50 class molecule; … … 86 87 DoLog(0) && (Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl); 87 88 } 88 ;89 90 TesselPoint * Tesselation::getValue(const_iterator &rhs) const91 {92 return (*rhs).second->node;93 }94 95 TesselPoint * Tesselation::getValue(iterator &rhs) const96 {97 return (*rhs).second->node;98 }99 100 const char * const Tesselation::GetName() const101 {102 return "unknown";103 }104 105 /** PointCloud implementation of GetCenter106 * Uses PointsOnBoundary and STL stuff.107 */108 Vector * Tesselation::GetCenter() const109 {110 Info FunctionInfo(__func__);111 Vector *Center = new Vector(0., 0., 0.);112 int num = 0;113 for (GoToFirst(); (!IsEnd()); GoToNext()) {114 (*Center) += (GetPoint()->getPosition());115 num++;116 }117 Center->Scale(1. / num);118 return Center;119 }120 ;121 122 /** PointCloud implementation of GoPoint123 * Uses PointsOnBoundary and STL stuff.124 */125 TesselPoint * Tesselation::GetPoint() const126 {127 Info FunctionInfo(__func__);128 return (InternalPointer->second->node);129 }130 ;131 132 int Tesselation::GetMaxId() const133 {134 int max_id = 0;135 for (PointMap::const_iterator iter = PointsOnBoundary.begin();136 iter != PointsOnBoundary.end();137 ++iter) {138 if ((iter->second)->node->nr > max_id)139 (iter->second)->node->nr = max_id;140 }141 return max_id;142 }143 144 /** PointCloud implementation of GoToNext.145 * Uses PointsOnBoundary and STL stuff.146 */147 void Tesselation::GoToNext() const148 {149 Info FunctionInfo(__func__);150 if (InternalPointer != PointsOnBoundary.end())151 InternalPointer++;152 }153 ;154 155 /** PointCloud implementation of GoToFirst.156 * Uses PointsOnBoundary and STL stuff.157 */158 void Tesselation::GoToFirst() const159 {160 Info FunctionInfo(__func__);161 InternalPointer = PointsOnBoundary.begin();162 }163 ;164 165 /** PointCloud implementation of IsEmpty.166 * Uses PointsOnBoundary and STL stuff.167 */168 bool Tesselation::IsEmpty() const169 {170 Info FunctionInfo(__func__);171 return (PointsOnBoundary.empty());172 }173 ;174 175 /** PointCloud implementation of IsLast.176 * Uses PointsOnBoundary and STL stuff.177 */178 bool Tesselation::IsEnd() const179 {180 Info FunctionInfo(__func__);181 return (InternalPointer == PointsOnBoundary.end());182 }183 ;184 89 185 90 /** Gueses first starting triangle of the convex envelope. … … 318 223 * \param *cloud cluster of points 319 224 */ 320 void Tesselation::TesselateOnBoundary( const PointCloud * constcloud)225 void Tesselation::TesselateOnBoundary(IPointCloud & cloud) 321 226 { 322 227 Info FunctionInfo(__func__); … … 328 233 LineMap::iterator LineChecker[2]; 329 234 330 Center = cloud ->GetCenter();235 Center = cloud.GetCenter(); 331 236 // create a first tesselation with the given BoundaryPoints 332 237 do { … … 509 414 * \return true - all straddling points insert, false - something went wrong 510 415 */ 511 bool Tesselation::InsertStraddlingPoints( const PointCloud *cloud, const LinkedCell *LC)416 bool Tesselation::InsertStraddlingPoints(IPointCloud & cloud, const LinkedCell *LC) 512 417 { 513 418 Info FunctionInfo(__func__); 514 419 Vector Intersection, Normal; 515 420 TesselPoint *Walker = NULL; 516 Vector *Center = cloud ->GetCenter();421 Vector *Center = cloud.GetCenter(); 517 422 TriangleList *triangles = NULL; 518 423 bool AddFlag = false; … … 520 425 bool SuccessFlag = true; 521 426 522 cloud->GoToFirst(); 523 BoundaryPoints = new LinkedCell(*this, 5.); 524 while (!cloud->IsEnd()) { // we only have to go once through all points, as boundary can become only bigger 427 cloud.GoToFirst(); 428 PointCloudAdaptor< Tesselation, MapValueIterator<Tesselation::iterator> > newcloud(this); 429 BoundaryPoints = new LinkedCell(newcloud, 5.); 430 while (!cloud.IsEnd()) { // we only have to go once through all points, as boundary can become only bigger 525 431 if (AddFlag) { 526 432 delete (BoundaryPoints); 527 BoundaryPoints = new LinkedCell( *this, 5.);433 BoundaryPoints = new LinkedCell(newcloud, 5.); 528 434 AddFlag = false; 529 435 } 530 Walker = cloud ->GetPoint();436 Walker = cloud.GetPoint(); 531 437 DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl); 532 438 // get the next triangle … … 539 445 if ((BTS == NULL) || (BTS->ContainsBoundaryPoint(Walker))) { 540 446 DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl); 541 cloud ->GoToNext();447 cloud.GoToNext(); 542 448 continue; 543 449 } else { … … 610 516 break; 611 517 } 612 cloud ->GoToNext();518 cloud.GoToNext(); 613 519 } 614 520 … … 1122 1028 for (LC->n[map[1]] = 0; LC->n[map[1]] < LC->N[map[1]]; LC->n[map[1]]++) 1123 1029 for (LC->n[map[2]] = 0; LC->n[map[2]] < LC->N[map[2]]; LC->n[map[2]]++) { 1124 const LinkedCell::LinkedNodes*List = LC->GetCurrentCell();1030 const TesselPointSTLList *List = LC->GetCurrentCell(); 1125 1031 //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 1126 1032 if (List != NULL) { 1127 for ( LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {1033 for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 1128 1034 if ((*Runner)->at(map[0]) > maxCoordinate[map[0]]) { 1129 1035 DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << (*Runner)->getPosition() << "." << endl); … … 1982 1888 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 1983 1889 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 1984 const LinkedCell::LinkedNodes*List = LC->GetCurrentCell();1890 const TesselPointSTLList *List = LC->GetCurrentCell(); 1985 1891 //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 1986 1892 if (List != NULL) { 1987 for ( LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {1893 for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 1988 1894 Candidate = (*Runner); 1989 1895 // check if we only have one unique point yet ... … … 2140 2046 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 2141 2047 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2142 const LinkedCell::LinkedNodes*List = LC->GetCurrentCell();2048 const TesselPointSTLList *List = LC->GetCurrentCell(); 2143 2049 //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2144 2050 if (List != NULL) { 2145 for ( LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {2051 for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2146 2052 Candidate = (*Runner); 2147 2053 … … 2313 2219 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 2314 2220 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2315 const LinkedCell::LinkedNodes*List = LC->GetCurrentCell();2221 const TesselPointSTLList *List = LC->GetCurrentCell(); 2316 2222 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl; 2317 2223 if (List != NULL) { 2318 for ( LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {2224 for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { 2319 2225 FindPoint = PointsOnBoundary.find((*Runner)->nr); 2320 2226 if (FindPoint != PointsOnBoundary.end()) { … … 3710 3616 * \param *out otuput stream for debugging 3711 3617 * \param *filename basename of output file 3712 * \param *cloud PointCloud structure with all nodes3713 */ 3714 void Tesselation::Output(const char *filename, const PointCloud * constcloud)3618 * \param *cloud IPointCloud structure with all nodes 3619 */ 3620 void Tesselation::Output(const char *filename, IPointCloud & cloud) 3715 3621 { 3716 3622 Info FunctionInfo(__func__);
Note:
See TracChangeset
for help on using the changeset viewer.