- Timestamp:
- Nov 28, 2009, 3:45:59 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, fad93c
- Parents:
- 262bae
- git-author:
- Frederik Heber <heber@…> (11/28/09 14:58:40)
- git-committer:
- Frederik Heber <heber@…> (11/28/09 15:45:59)
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r262bae r856098 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 r856098 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; 4134 UniquePolygonSet TestedPolygons; 4040 4135 for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) { 4041 Four = new BoundaryPolygonSet; 4136 Log() << Verbose(1) << "Current Line is: " << *(LineRunner->second) << endl; 4137 4138 BoundaryPolygonSet *Four = new BoundaryPolygonSet; 4042 4139 4043 4140 /// 2a. Get all four endpoints of the two connected triangles. 4044 4141 Four->FillPolygonFromTrianglesOfLine((LineRunner->second)); 4142 if (Four->endpoints.size() != 4) { 4143 Log() << Verbose(0) << "REJECT: There were no four endpoints:" << *Four << endl; 4144 delete(Four); 4145 continue; 4146 } 4045 4147 4046 4148 /// 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 4149 TriangleSet *T = Four->GetAllContainedTrianglesFromEndpoints(); 4150 4151 /// 2c1. Check whether all triangles have (besides sign) same normal vector) 4152 TriangleSet::const_iterator Runner = T->begin(); 4153 Vector NormalVector; 4154 NormalVector.CopyVector(&(*Runner)->NormalVector); 4155 Runner++; 4156 bool IsPlanar = true; 4157 for (; Runner != T->end(); Runner++) { 4158 if (fabs(fabs(NormalVector.ScalarProduct(&(*Runner)->NormalVector)) - 1.) > MYEPSILON) // check whether all NormalVectors are parallel 4159 IsPlanar = false; 4160 } 4161 4162 /// 2c2. check whether triangles are not already simply degenerated. 4163 size_t DegeneratedCount = 0; 4164 for (TriangleSet::const_iterator Runner = T->begin(); Runner != T->end(); Runner++) { 4165 if (SimplyDegeneratedTriangles->find((*Runner)->Nr) != SimplyDegeneratedTriangles->end()) 4166 DegeneratedCount++; 4167 } 4168 Log() << Verbose(1) << "Found " << DegeneratedCount << " degenerated triangles." << endl; 4169 4170 if (IsPlanar) { 4171 if(DegeneratedCount == 0) { 4172 /// 2c. Find all pairs of those triangles that contain the four endpoints 4173 const int counter = CountTrianglePairContainingPolygon(Four, T); 4174 Log() << Verbose(1) << "There are " << counter << " pairs for this polygon of four." << endl; 4175 if (counter %3 == 0) { 4176 /// 2d. Check the number of pairs, if greater 1, we have a degenerated polygon (mark down for later use) 4177 pair < UniquePolygonSet::iterator, bool > Tester = ListofFours.insert(Four); 4178 if (Tester.second) { 4179 Log() << Verbose(0) << "ACCEPT: We have a degenerated polygon." << *Four << endl; 4180 } else { 4181 Log() << Verbose(0) << "REJECT: Degenerated polygon already present." << *Four << endl; 4182 delete(Four); 4183 } 4184 } else { 4185 Log() << Verbose(0) << "REJECT: Seems to be the edge line of a degenerated polygon only." << *Four << endl; 4186 delete(Four); 4187 } 4188 } else { 4189 Log() << Verbose(0) << "REJECT: This polygon contains some simply degenerated triangles." << endl; 4190 delete(Four); 4191 } 4192 } else { 4193 Log() << Verbose(0) << "REJECT: This polygon does not lay on a plane." << endl; 4054 4194 delete(Four); 4195 } 4055 4196 4056 4197 delete(T); … … 4058 4199 4059 4200 /// 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 4201 { 4202 UniquePolygonSet::iterator PolygonWalker; // is the inner iterator 4203 UniquePolygonSet::iterator PolygonSprinter; // is the inner advanced iterator 4204 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4205 const BoundaryPolygonSet *P1 = *PolygonRunner; 4206 Log() << Verbose(1) << "Current Polygon is : " << *P1 << endl; 4207 PolygonWalker = PolygonRunner; 4208 PolygonWalker++; 4209 PolygonSprinter = PolygonWalker; 4210 while (PolygonWalker != ListofFours.end()) { 4211 BoundaryPolygonSet *P2 = *PolygonWalker; 4212 Log() << Verbose(1) << "Current Other Polygon is : " << *P2 << endl; 4213 PolygonSprinter++; 4214 Log() << Verbose(1) << "Are " << *P1 << " and " << *P2 << " edge-connected?" << endl; 4215 if (ArePolygonsEdgeConnected((*PolygonRunner), (P2))) { // if connected 4216 Log() << Verbose(0) << "Yes!" << endl; 4217 CombinePolygons((*PolygonRunner), (P2)); // combined and ... 4218 ListofFours.erase(PolygonWalker); // ... remove from list 4219 Log() << Verbose(1) << " New current Polygon is : " << *P1 << endl; 4220 } else { 4221 Log() << Verbose(0) << "No." << endl; 4222 } 4223 PolygonWalker = PolygonSprinter; 4071 4224 } 4072 PolygonWalker = PolygonSprinter; 4073 } 4074 } 4225 } 4226 } 4227 4228 Log() << Verbose(0) << "The following degenerated polygons have been found: " << endl; 4229 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) 4230 Log() << Verbose(0) << " " << **PolygonRunner << endl; 4075 4231 4076 4232 /// 4. Go through all these degenerated polygons 4077 Vector NormalVector; 4078 for (PolygonList::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4233 for (UniquePolygonSet::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) { 4234 stack <int> TriangleNrs; 4235 Vector NormalVector; 4079 4236 /// 4a. Gather all triangles of this polygon 4080 T = Four->GetAllTrianglesFromEndpoints(); 4081 4237 TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints(); 4238 4239 TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator 4082 4240 /// 4a. Get NormalVector for one side (this is "front") 4083 NormalVector.CopyVector(&(*(T->begin()))->NormalVector); 4084 4241 NormalVector.CopyVector(&(*TriangleWalker)->NormalVector); 4242 Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl; 4243 TriangleWalker++; 4244 TriangleSet::iterator TriangleSprinter = TriangleWalker; // is the inner advanced iterator 4085 4245 /// 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 triangle4246 BoundaryTriangleSet *triangle = NULL; 4247 while (TriangleSprinter != T->end()) { 4248 TriangleWalker = TriangleSprinter; 4249 triangle = *TriangleWalker; 4250 TriangleSprinter++; 4251 Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl; 4252 if (triangle->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list 4253 Log() << Verbose(1) << " Removing ... " << endl; 4254 TriangleNrs.push(triangle->Nr); 4095 4255 T->erase(TriangleWalker); 4096 } 4256 RemoveTesselationTriangle(triangle); 4257 } else 4258 Log() << Verbose(1) << " Keeping ... " << endl; 4097 4259 } 4098 4260 /// 4c. Copy all "front" triangles but with inverse NormalVector 4099 BoundaryTriangleSet *triangle = NULL;4100 4261 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 4262 while (TriangleWalker != T->end()) { // go through all front triangles 4263 Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << BTS->NormalVector << endl; 4264 for (int i = 0; i < 3; i++) 4265 AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i); 4266 AddTesselationLine(TPS[0], TPS[1], 0); 4267 AddTesselationLine(TPS[0], TPS[2], 1); 4268 AddTesselationLine(TPS[1], TPS[2], 2); 4269 BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ... 4270 AddTesselationTriangle(); // ... and add 4271 TriangleNrs.pop(); 4272 BTS->NormalVector.CopyVector(&(*TriangleWalker)->NormalVector); 4273 BTS->NormalVector.Scale(-1.); 4107 4274 /// 4d. Add all degenerated triangles to the list of simply degenerated triangles 4108 SimplyDegeneratedTriangles->insert(pair <int, int> ((*TriangleWalker)->Nr, triangle->Nr) ); 4275 SimplyDegeneratedTriangles->insert(pair <int, int> ((*TriangleWalker)->Nr, BTS->Nr) ); 4276 SimplyDegeneratedTriangles->insert(pair <int, int> (BTS->Nr, (*TriangleWalker)->Nr) ); 4109 4277 TriangleWalker++; 4110 4278 } 4279 if (!TriangleNrs.empty()) { 4280 eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl; 4281 } 4111 4282 delete(T); // remove the triangleset 4112 4283 } 4113 4284 4285 Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl; 4286 map<int,int>::iterator it; 4287 for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++) 4288 Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl; 4289 4114 4290 /// 5. exit 4115 PolygonList::iterator PolygonRunner;4116 while ( ListofFours.empty()) {4291 UniquePolygonSet::iterator PolygonRunner; 4292 while (!ListofFours.empty()) { 4117 4293 PolygonRunner = ListofFours.begin(); 4118 4294 delete(*PolygonRunner); … … 4120 4296 } 4121 4297 4122 int counter = SimplyDegeneratedTriangles->size();4298 const int counter = SimplyDegeneratedTriangles->size(); 4123 4299 delete(SimplyDegeneratedTriangles); 4124 4300 return counter; -
src/tesselation.hpp
r262bae r856098 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 r856098 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.