Changeset af374d
- Timestamp:
- Nov 28, 2009, 3:07:42 PM (15 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:
- 2130dd
- Parents:
- 262bae
- git-author:
- Frederik Heber <heber@…> (11/28/09 14:58:40)
- git-committer:
- Frederik Heber <heber@…> (11/28/09 15:07:42)
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r262bae raf374d 1041 1041 // TesselStruct->RemoveDegeneratedTriangles(); 1042 1042 1043 // correct degenerated polygons 1044 TesselStruct->CorrectAllDegeneratedPolygons(); 1045 1043 1046 // check envelope for consistency 1044 1047 status = CheckListOfBaselines(TesselStruct); -
src/tesselation.cpp
r262bae raf374d 636 636 } 637 637 center->Scale(1./(double)counter); 638 Log() << Verbose(1) << "Center is at " << *center << "." << endl; 638 639 } 639 640 … … 654 655 bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const 655 656 { 657 Info FunctionInfo(__func__); 656 658 return ContainsPresentTupel(line->endpoints, 2); 657 659 }; … … 664 666 { 665 667 Info FunctionInfo(__func__); 666 for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) 667 if (point == (*Runner)) 668 for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 669 Log() << Verbose(0) << "Checking against " << **Runner << endl; 670 if (point == (*Runner)) { 671 Log() << Verbose(0) << " Contained." << endl; 668 672 return true; 673 } 674 } 675 Log() << Verbose(0) << " Not contained." << endl; 669 676 return false; 670 677 }; … … 678 685 Info FunctionInfo(__func__); 679 686 for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) 680 if (point == (*Runner)->node) 687 if (point == (*Runner)->node) { 688 Log() << Verbose(0) << " Contained." << endl; 681 689 return true; 690 } 691 Log() << Verbose(0) << " Not contained." << endl; 682 692 return false; 683 693 }; … … 690 700 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const 691 701 { 702 Info FunctionInfo(__func__); 692 703 int counter = 0; 693 for(int i=0;i<dim;i++) 694 if (ContainsBoundaryPoint(Points[i])) 704 Log() << Verbose(1) << "Polygon is " << *this << endl; 705 for(int i=0;i<dim;i++) { 706 Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl; 707 if (ContainsBoundaryPoint(Points[i])) { 695 708 counter++; 709 } 710 } 696 711 697 712 if (counter == dim) … … 707 722 bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const 708 723 { 724 Info FunctionInfo(__func__); 709 725 size_t counter = 0; 726 Log() << Verbose(1) << "Polygon is " << *this << endl; 710 727 for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) { 728 Log() << Verbose(1) << " Testing endpoint " << **Runner << endl; 711 729 if (ContainsBoundaryPoint(*Runner)) 712 730 counter++; … … 725 743 bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const 726 744 { 727 Info FunctionInfo(__func__);728 745 return ContainsPresentTupel((const PointSet)P->endpoints); 729 746 }; … … 732 749 * \return set of all triangles 733 750 */ 734 TriangleSet * BoundaryPolygonSet::GetAll TrianglesFromEndpoints() const751 TriangleSet * BoundaryPolygonSet::GetAllContainedTrianglesFromEndpoints() const 735 752 { 736 753 Info FunctionInfo(__func__); 754 pair <TriangleSet::iterator, bool> Tester; 737 755 TriangleSet *triangles = new TriangleSet; 738 756 739 757 for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) 740 758 for(LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++) 741 for(TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) 742 triangles->insert(Sprinter->second); 759 for(TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) { 760 //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl; 761 if (ContainsBoundaryTriangle(Sprinter->second)) { 762 Tester = triangles->insert(Sprinter->second); 763 if (Tester.second) 764 Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl; 765 } 766 } 743 767 744 768 Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl; … … 748 772 /** Fills the endpoints of this polygon from the triangles attached to \a *line. 749 773 * \param *line lines with triangles attached 750 * \return true - polygon contains four points, false - something went wront, polygon does not contain any points774 * \return true - polygon contains endpoints, false - line was NULL 751 775 */ 752 776 bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line) 753 777 { 778 Info FunctionInfo(__func__); 779 pair <PointSet::iterator, bool> Tester; 780 if (line == NULL) 781 return false; 782 Log() << Verbose(1) << "Filling polygon from line " << *line << endl; 754 783 for(TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) { 755 for (int i=0;i<3;i++) 756 endpoints.insert((Runner->second)->endpoints[i]); 757 } 758 759 if (endpoints.size() != 4) {// remove all points on error 760 endpoints.clear(); 761 return false; 762 } else 763 return true; 784 for (int i=0;i<3;i++) { 785 Tester = endpoints.insert((Runner->second)->endpoints[i]); 786 if (Tester.second) 787 Log() << Verbose(1) << " Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl; 788 } 789 } 790 791 return true; 764 792 }; 765 793 … … 1577 1605 // remove existing line from OpenLines 1578 1606 CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]); 1579 delete(CandidateLine->second); 1580 OpenLines.erase(CandidateLine); 1607 if (CandidateLine != OpenLines.end()) { 1608 Log() << Verbose(1) << " Removing line from OpenLines." << endl; 1609 delete(CandidateLine->second); 1610 OpenLines.erase(CandidateLine); 1611 } else { 1612 eLog() << Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl; 1613 } 1581 1614 1582 1615 break; … … 1670 1703 } else { 1671 1704 Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: "; 1705 OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL)); 1672 1706 for(TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++) 1673 1707 Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t"; … … 2332 2366 Sprinter++; 2333 2367 } 2368 delete(connectedClosestPoints); 2334 2369 }; 2335 2370 … … 3707 3742 } 3708 3743 3744 struct BoundaryLineSetCompare { 3745 bool operator() (const BoundaryLineSet * const a, const BoundaryLineSet * const b) { 3746 int lowerNra = -1; 3747 int lowerNrb = -1; 3748 3749 if (a->endpoints[0] < a->endpoints[1]) 3750 lowerNra = 0; 3751 else 3752 lowerNra = 1; 3753 3754 if (b->endpoints[0] < b->endpoints[1]) 3755 lowerNrb = 0; 3756 else 3757 lowerNrb = 1; 3758 3759 if (a->endpoints[lowerNra] < b->endpoints[lowerNrb]) 3760 return true; 3761 else if (a->endpoints[lowerNra] > b->endpoints[lowerNrb]) 3762 return false; 3763 else { // both lower-numbered endpoints are the same ... 3764 if (a->endpoints[(lowerNra+1)%2] < b->endpoints[(lowerNrb+1)%2]) 3765 return true; 3766 else if (a->endpoints[(lowerNra+1)%2] > b->endpoints[(lowerNrb+1)%2]) 3767 return false; 3768 } 3769 return false; 3770 }; 3771 }; 3772 3773 #define UniqueLines set < class BoundaryLineSet *, BoundaryLineSetCompare> 3774 3709 3775 /** 3710 3776 * Finds all degenerated lines within the tesselation structure. … … 3716 3782 { 3717 3783 Info FunctionInfo(__func__); 3718 map<int, class BoundaryLineSet *>AllLines;3784 UniqueLines AllLines; 3719 3785 map<int, int> * DegeneratedLines = new map<int, int>; 3720 3786 … … 3726 3792 3727 3793 LineMap::iterator LineRunner1; 3728 pair< LineMap::iterator, bool> tester;3794 pair< UniqueLines::iterator, bool> tester; 3729 3795 for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) { 3730 tester = AllLines.insert( pair<int,BoundaryLineSet *> (LineRunner1->second->endpoints[0]->Nr, LineRunner1->second));3731 if ( (!tester.second) && (tester.first->second->endpoints[1]->Nr == LineRunner1->second->endpoints[1]->Nr)) { // found degenerated line3732 DegeneratedLines->insert ( pair<int, int> (LineRunner1->second->Nr, tester.first->second->Nr) );3733 DegeneratedLines->insert ( pair<int, int> ( tester.first->second->Nr, LineRunner1->second->Nr) );3796 tester = AllLines.insert( LineRunner1->second ); 3797 if (!tester.second) { // found degenerated line 3798 DegeneratedLines->insert ( pair<int, int> (LineRunner1->second->Nr, (*tester.first)->Nr) ); 3799 DegeneratedLines->insert ( pair<int, int> ((*tester.first)->Nr, LineRunner1->second->Nr) ); 3734 3800 } 3735 3801 } … … 3739 3805 Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl; 3740 3806 map<int,int>::iterator it; 3741 for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) 3742 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl; 3807 for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) { 3808 const LineMap::const_iterator Line1 = LinesOnBoundary.find((*it).first); 3809 const LineMap::const_iterator Line2 = LinesOnBoundary.find((*it).second); 3810 if (Line1 != LinesOnBoundary.end() && Line2 != LinesOnBoundary.end()) 3811 Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl; 3812 else 3813 eLog() << Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl; 3814 } 3743 3815 3744 3816 return DegeneratedLines; … … 4024 4096 }; 4025 4097 4098 struct BoundaryPolygonSetCompare { 4099 bool operator()(const BoundaryPolygonSet * s1, const BoundaryPolygonSet * s2) const { 4100 if (s1->endpoints.size() < s2->endpoints.size()) 4101 return true; 4102 else if (s1->endpoints.size() > s2->endpoints.size()) 4103 return false; 4104 else { // equality of number of endpoints 4105 PointSet::const_iterator Walker1 = s1->endpoints.begin(); 4106 PointSet::const_iterator Walker2 = s2->endpoints.begin(); 4107 while ((Walker1 != s1->endpoints.end()) || (Walker2 != s2->endpoints.end())) { 4108 if ((*Walker1)->Nr < (*Walker2)->Nr) 4109 return true; 4110 else if ((*Walker1)->Nr > (*Walker2)->Nr) 4111 return false; 4112 Walker1++; 4113 Walker2++; 4114 } 4115 return false; 4116 } 4117 } 4118 }; 4119 4120 #define UniquePolygonSet set < BoundaryPolygonSet *, BoundaryPolygonSetCompare> 4121 4026 4122 /** Finds all degenerated polygons and calls ReTesselateDegeneratedPolygon()/ 4027 4123 * \return number of polygons found … … 4035 4131 4036 4132 /// 2. Go through all lines not contained in degenerated triangles. 4037 PolygonList ListofFours; 4038 BoundaryPolygonSet *Four = NULL; 4039 TriangleSet *T = NULL; 4133 UniquePolygonSet ListofFours; 4040 4134 for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) { 4041 Four = new BoundaryPolygonSet; 4135 Log() << Verbose(1) << "Current Line is: " << *(LineRunner->second) << endl; 4136 4137 BoundaryPolygonSet *Four = new BoundaryPolygonSet; 4042 4138 4043 4139 /// 2a. Get all four endpoints of the two connected triangles. 4044 4140 Four->FillPolygonFromTrianglesOfLine((LineRunner->second)); 4141 if (Four->endpoints.size() != 4) { 4142 Log() << Verbose(0) << "REJECT: There were no four endpoints:" << *Four << endl; 4143 delete(Four); 4144 continue; 4145 } 4045 4146 4046 4147 /// 2b. Get the triangles of all those endpoints 4047 T = Four->GetAllTrianglesFromEndpoints(); 4048 4049 /// 2c. Find all pairs of those triangles that contain the four endpoints 4050 if (CountTrianglePairContainingPolygon(Four, T) > 1) { 4051 /// 2d. Check the number of pairs, if greater 1, we have a degenerated polygon (mark down for later use) 4052 ListofFours.push_back(Four); 4053 } else 4148 TriangleSet *T = Four->GetAllContainedTrianglesFromEndpoints(); 4149 4150 /// 2c. check whether triangles are not already simply degenerated. 4151 size_t DegeneratedCount = 0; 4152 for (TriangleSet::const_iterator Runner = T->begin(); Runner != T->end(); Runner++) { 4153 if (SimplyDegeneratedTriangles->find((*Runner)->Nr) != SimplyDegeneratedTriangles->end()) 4154 DegeneratedCount++; 4155 } 4156 Log() << Verbose(1) << "Found " << DegeneratedCount << " degenerated triangles." << endl; 4157 if (DegeneratedCount == 0) { 4158 /// 2c. Find all pairs of those triangles that contain the four endpoints 4159 const int counter = CountTrianglePairContainingPolygon(Four, T); 4160 Log() << Verbose(1) << "There are " << counter << " pairs for this polygon of four." << endl; 4161 if (counter %3 == 0) { 4162 /// 2d. Check the number of pairs, if greater 1, we have a degenerated polygon (mark down for later use) 4163 pair < UniquePolygonSet::iterator, bool > Tester = ListofFours.insert(Four); 4164 if (Tester.second) { 4165 Log() << Verbose(0) << "ACCEPT: We have a degenerated polygon." << *Four << endl; 4166 } else { 4167 Log() << Verbose(0) << "REJECT: Degenerated polygon already present." << *Four << endl; 4168 delete(Four); 4169 } 4170 } else { 4171 Log() << Verbose(0) << "REJECT: Seems to be the edge line of a degenerated polygon only." << *Four << endl; 4172 delete(Four); 4173 } 4174 } else { 4175 Log() << Verbose(0) << "REJECT: This polygon contains some simply degenerated triangles." << endl; 4054 4176 delete(Four); 4177 } 4055 4178 4056 4179 delete(T); … … 4058 4181 4059 4182 /// 3. Combine all edge-connected degenerated polygons 4060 PolygonList::iterator PolygonWalker; // is the inner iterator 4061 PolygonList::iterator PolygonSprinter; // is the inner advanced iterator 4062 for (PolygonList::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4063 PolygonWalker = PolygonRunner; 4064 PolygonWalker++; 4065 PolygonSprinter = PolygonWalker; 4066 while (PolygonWalker != ListofFours.end()) { 4067 PolygonSprinter++; 4068 if (ArePolygonsEdgeConnected((*PolygonRunner), (*PolygonWalker))) { // if connected 4069 CombinePolygons((*PolygonRunner), (*PolygonWalker)); // combined and ... 4070 ListofFours.erase(PolygonWalker); // ... remove from list 4183 { 4184 UniquePolygonSet::iterator PolygonWalker; // is the inner iterator 4185 UniquePolygonSet::iterator PolygonSprinter; // is the inner advanced iterator 4186 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4187 const BoundaryPolygonSet *P1 = *PolygonRunner; 4188 Log() << Verbose(1) << "Current Polygon is : " << *P1 << endl; 4189 PolygonWalker = PolygonRunner; 4190 PolygonWalker++; 4191 PolygonSprinter = PolygonWalker; 4192 while (PolygonWalker != ListofFours.end()) { 4193 BoundaryPolygonSet *P2 = *PolygonWalker; 4194 Log() << Verbose(1) << "Current Other Polygon is : " << *P2 << endl; 4195 PolygonSprinter++; 4196 Log() << Verbose(1) << "Are " << *P1 << " and " << *P2 << " edge-connected?" << endl; 4197 if (ArePolygonsEdgeConnected((*PolygonRunner), (P2))) { // if connected 4198 Log() << Verbose(0) << "Yes!" << endl; 4199 CombinePolygons((*PolygonRunner), (P2)); // combined and ... 4200 ListofFours.erase(PolygonWalker); // ... remove from list 4201 Log() << Verbose(1) << " New current Polygon is : " << *P1 << endl; 4202 } else { 4203 Log() << Verbose(0) << "No." << endl; 4204 } 4205 PolygonWalker = PolygonSprinter; 4071 4206 } 4072 PolygonWalker = PolygonSprinter; 4073 } 4074 } 4207 } 4208 } 4209 4210 Log() << Verbose(0) << "The following degenerated polygons have been found: " << endl; 4211 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) 4212 Log() << Verbose(0) << " " << **PolygonRunner << endl; 4075 4213 4076 4214 /// 4. Go through all these degenerated polygons 4077 Vector NormalVector; 4078 for (PolygonList::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4215 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4216 stack <int> TriangleNrs; 4217 Vector NormalVector; 4079 4218 /// 4a. Gather all triangles of this polygon 4080 T = Four->GetAllTrianglesFromEndpoints(); 4081 4219 TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints(); 4220 4221 TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator 4082 4222 /// 4a. Get NormalVector for one side (this is "front") 4083 NormalVector.CopyVector(&(*(T->begin()))->NormalVector); 4084 4223 NormalVector.CopyVector(&(*TriangleWalker)->NormalVector); 4224 Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl; 4225 TriangleWalker++; 4226 TriangleSet::iterator TriangleSprinter = TriangleWalker; // is the inner advanced iterator 4085 4227 /// 4b. Remove all triangles whose NormalVector is in opposite direction (i.e. "back") 4086 TriangleSet::const_iterator TriangleWalker; // is the inner iterator4087 TriangleSet::const_iterator TriangleSprinter; // is the inner advanced iterator4088 PolygonWalker = PolygonRunner;4089 PolygonWalker++;4090 PolygonSprinter = PolygonWalker;4091 while (PolygonWalker != ListofFours.end()) {4092 PolygonSprinter++;4093 if ((*TriangleWalker)->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list4094 delete(*TriangleWalker); // remove triangle4228 BoundaryTriangleSet *triangle = NULL; 4229 while (TriangleSprinter != T->end()) { 4230 TriangleWalker = TriangleSprinter; 4231 triangle = *TriangleWalker; 4232 TriangleSprinter++; 4233 Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl; 4234 if (triangle->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list 4235 Log() << Verbose(1) << " Removing ... " << endl; 4236 TriangleNrs.push(triangle->Nr); 4095 4237 T->erase(TriangleWalker); 4096 } 4238 RemoveTesselationTriangle(triangle); 4239 } else 4240 Log() << Verbose(1) << " Keeping ... " << endl; 4097 4241 } 4098 4242 /// 4c. Copy all "front" triangles but with inverse NormalVector 4099 BoundaryTriangleSet *triangle = NULL;4100 4243 TriangleWalker = T->begin(); 4101 TriangleSprinter = T->end(); 4102 TriangleSprinter--; // set onto last "front" triangle 4103 while (TriangleWalker != TriangleSprinter) { // go through all front triangles 4104 triangle = new BoundaryTriangleSet(*(*TriangleWalker)); // copy triangle ... 4105 triangle->NormalVector.Scale(-1.); 4106 T->insert(triangle); // ... and add 4244 while (TriangleWalker != T->end()) { // go through all front triangles 4245 Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << BTS->NormalVector << endl; 4246 for (int i = 0; i < 3; i++) 4247 AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i); 4248 AddTesselationLine(TPS[0], TPS[1], 0); 4249 AddTesselationLine(TPS[0], TPS[2], 1); 4250 AddTesselationLine(TPS[1], TPS[2], 2); 4251 BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ... 4252 AddTesselationTriangle(); // ... and add 4253 TriangleNrs.pop(); 4254 BTS->NormalVector.CopyVector(&(*TriangleWalker)->NormalVector); 4255 BTS->NormalVector.Scale(-1.); 4107 4256 /// 4d. Add all degenerated triangles to the list of simply degenerated triangles 4108 SimplyDegeneratedTriangles->insert(pair <int, int> ((*TriangleWalker)->Nr, triangle->Nr) ); 4257 SimplyDegeneratedTriangles->insert(pair <int, int> ((*TriangleWalker)->Nr, BTS->Nr) ); 4258 SimplyDegeneratedTriangles->insert(pair <int, int> (BTS->Nr, (*TriangleWalker)->Nr) ); 4109 4259 TriangleWalker++; 4110 4260 } 4261 if (!TriangleNrs.empty()) { 4262 eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl; 4263 } 4111 4264 delete(T); // remove the triangleset 4112 4265 } 4113 4266 4267 Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl; 4268 map<int,int>::iterator it; 4269 for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++) 4270 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl; 4271 4114 4272 /// 5. exit 4115 PolygonList::iterator PolygonRunner;4116 while ( ListofFours.empty()) {4273 UniquePolygonSet::iterator PolygonRunner; 4274 while (!ListofFours.empty()) { 4117 4275 PolygonRunner = ListofFours.begin(); 4118 4276 delete(*PolygonRunner); … … 4120 4278 } 4121 4279 4122 int counter = SimplyDegeneratedTriangles->size();4280 const int counter = SimplyDegeneratedTriangles->size(); 4123 4281 delete(SimplyDegeneratedTriangles); 4124 4282 return counter; -
src/tesselation.hpp
r262bae raf374d 23 23 #include <list> 24 24 #include <set> 25 #include <stack> 25 26 26 27 #include "atom_particleinfo.hpp" … … 183 184 bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const; 184 185 bool ContainsPresentTupel(const PointSet &endpoints) const; 185 TriangleSet * GetAll TrianglesFromEndpoints() const;186 TriangleSet * GetAllContainedTrianglesFromEndpoints() const; 186 187 bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line); 187 188 -
src/tesselationhelpers.cpp
r262bae raf374d 956 956 } 957 957 958 Log() << Verbose(0) << "Polygon is " << *P << endl; 958 959 // create each pair, get the endpoints and check whether *P is contained. 959 960 int counter = 0; … … 969 970 for (int i=0;i<3;i++) 970 971 PairTrianglenodes.endpoints.insert((*PairWalker)->endpoints[i]); 971 Log() << Verbose(1) << "Current pair of triangles: " << PairTrianglenodes << "." << endl; 972 // now check 973 if (PairTrianglenodes.ContainsPresentTupel(P)) { 974 counter++; 975 Log() << Verbose(1) << "Matches with " << *P << endl; 972 const int size = PairTrianglenodes.endpoints.size(); 973 if (size == 4) { 974 Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl; 975 // now check 976 if (PairTrianglenodes.ContainsPresentTupel(P)) { 977 counter++; 978 Log() << Verbose(0) << " ACCEPT: Matches with " << *P << endl; 979 } else { 980 Log() << Verbose(0) << " REJECT: No match with " << *P << endl; 981 } 976 982 } else { 977 Log() << Verbose( 1) << "No match with " << *P<< endl;983 Log() << Verbose(0) << " REJECT: Less than four endpoints." << endl; 978 984 } 979 985 } 980 986 } 981 PairTrianglenodes.endpoints.clear();987 Trianglenodes.clear(); 982 988 } 983 989 return counter; … … 1010 1016 { 1011 1017 Info FunctionInfo(__func__); 1012 for(PointSet::iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) { 1013 P1->endpoints.insert((*Runner)); 1018 pair <PointSet::iterator, bool> Tester; 1019 for(PointSet::iterator Runner = P2->endpoints.begin(); Runner != P2->endpoints.end(); Runner++) { 1020 Tester = P1->endpoints.insert((*Runner)); 1021 if (Tester.second) 1022 Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl; 1014 1023 } 1015 1024 P2->endpoints.clear();
Note:
See TracChangeset
for help on using the changeset viewer.