- Timestamp:
- Aug 19, 2009, 2:31:29 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:
- 34e0592
- Parents:
- 99c484
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r99c484 r1d9b7aa 624 624 625 625 // First step: RemovePointFromTesselatedSurface 626 PointRunner = TesselStruct->PointsOnBoundary.begin(); 627 PointAdvance = PointRunner; // we need an advanced point, as the PointRunner might get removed 628 while (PointRunner != TesselStruct->PointsOnBoundary.end()) { 629 PointAdvance++; 630 point = PointRunner->second; 631 *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl; 632 Concavity = true; 633 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 626 do { 627 Concavity = false; 628 PointRunner = TesselStruct->PointsOnBoundary.begin(); 629 PointAdvance = PointRunner; // we need an advanced point, as the PointRunner might get removed 630 while (PointRunner != TesselStruct->PointsOnBoundary.end()) { 631 PointAdvance++; 632 point = PointRunner->second; 633 *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl; 634 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 635 line = LineRunner->second; 636 *out << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl; 637 } 638 if (!line->CheckConvexityCriterion(out)) { 639 *out << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl; 640 // remove the point 641 Concavity = true; 642 TesselStruct->RemovePointFromTesselatedSurface(out, point); 643 } 644 PointRunner = PointAdvance; 645 } 646 647 //CalculateConcavityPerBoundaryPoint(out, TesselStruct); 648 //StoreTrianglesinFile(out, mol, filename, "-second"); 649 650 // second step: PickFarthestofTwoBaselines 651 LineRunner = TesselStruct->LinesOnBoundary.begin(); 652 LineAdvance = LineRunner; // we need an advanced line, as the LineRunner might get removed 653 while (LineRunner != TesselStruct->LinesOnBoundary.end()) { 654 LineAdvance++; 634 655 line = LineRunner->second; 635 *out << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl; 636 Concavity = Concavity && (!line->CheckConvexityCriterion(out)); 637 } 638 if (Concavity) { 639 *out << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl; 640 // remove the point 641 TesselStruct->RemovePointFromTesselatedSurface(out, point); 642 } 643 PointRunner = PointAdvance; 644 } 645 646 //CalculateConcavityPerBoundaryPoint(out, TesselStruct); 647 StoreTrianglesinFile(out, mol, filename, "-second"); 648 649 // second step: PickFarthestofTwoBaselines 650 LineRunner = TesselStruct->LinesOnBoundary.begin(); 651 LineAdvance = LineRunner; // we need an advanced line, as the LineRunner might get removed 652 while (LineRunner != TesselStruct->LinesOnBoundary.end()) { 653 LineAdvance++; 654 line = LineRunner->second; 655 *out << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl; 656 // take highest of both lines 657 if (TesselStruct->IsConvexRectangle(out, line) == NULL) 658 TesselStruct->PickFarthestofTwoBaselines(out, line); 659 LineRunner = LineAdvance; 660 } 661 662 //CalculateConcavityPerBoundaryPoint(out, TesselStruct); 656 *out << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl; 657 // take highest of both lines 658 if (TesselStruct->IsConvexRectangle(out, line) == NULL) { 659 TesselStruct->PickFarthestofTwoBaselines(out, line); 660 Concavity = true; 661 } 662 LineRunner = LineAdvance; 663 } 664 } while (Concavity); 665 CalculateConcavityPerBoundaryPoint(out, TesselStruct); 663 666 StoreTrianglesinFile(out, mol, filename, "-third"); 664 667 … … 670 673 line = LineRunner->second; 671 674 *out << Verbose(1) << "INFO: Current line is " << *line << "." << endl; 672 if (LineAdvance != TesselStruct->LinesOnBoundary.end())673 *out << Verbose(1) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl;675 //if (LineAdvance != TesselStruct->LinesOnBoundary.end()) 676 //*out << Verbose(1) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl; 674 677 if (!line->CheckConvexityCriterion(out)) { 675 678 *out << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl; … … 684 687 685 688 CalculateConcavityPerBoundaryPoint(out, TesselStruct); 689 StoreTrianglesinFile(out, mol, filename, "-fourth"); 686 690 687 691 // end -
src/tesselation.cpp
r99c484 r1d9b7aa 16 16 LinesCount = 0; 17 17 Nr = -1; 18 value = 0.; 18 19 }; 19 20 … … 26 27 LinesCount = 0; 27 28 Nr = Walker->nr; 29 value = 0.; 28 30 }; 29 31 … … 148 150 void BoundaryLineSet::AddTriangle(class BoundaryTriangleSet *triangle) 149 151 { 150 cout << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." 151 << endl; 152 cout << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." << endl; 152 153 triangles.insert(TrianglePair(triangle->Nr, triangle)); 153 154 }; … … 177 178 if (triangles.size() != 2) { 178 179 *out << Verbose(1) << "ERROR: Baseline " << *this << " is connect to less than two triangles, Tesselation incomplete!" << endl; 179 return false;180 return true; 180 181 } 181 182 // check normal vectors 182 183 // have a normal vector on the base line pointing outwards 183 *out << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;184 //*out << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl; 184 185 BaseLineCenter.CopyVector(endpoints[0]->node->node); 185 186 BaseLineCenter.AddVector(endpoints[1]->node->node); … … 187 188 BaseLine.CopyVector(endpoints[0]->node->node); 188 189 BaseLine.SubtractVector(endpoints[1]->node->node); 189 *out << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;190 //*out << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl; 190 191 191 192 BaseLineNormal.Zero(); … … 195 196 class BoundaryPointSet *node = NULL; 196 197 for(TriangleMap::iterator runner = triangles.begin(); runner != triangles.end(); runner++) { 197 *out << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;198 //*out << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl; 198 199 NormalCheck.AddVector(&runner->second->NormalVector); 199 200 NormalCheck.Scale(sign); … … 202 203 node = runner->second->GetThirdEndpoint(this); 203 204 if (node != NULL) { 204 *out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;205 //*out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl; 205 206 helper[i].CopyVector(node->node->node); 206 207 helper[i].SubtractVector(&BaseLineCenter); 207 208 helper[i].MakeNormalVector(&BaseLine); // we want to compare the triangle's heights' angles! 208 *out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;209 //*out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl; 209 210 i++; 210 211 } else { 211 *out << Verbose(2) << "WARNING: I cannot find third node in triangle, something's wrong." << endl;212 //*out << Verbose(2) << "WARNING: I cannot find third node in triangle, something's wrong." << endl; 212 213 return true; 213 214 } 214 215 } 215 *out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;216 //*out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl; 216 217 if (NormalCheck.NormSquared() < MYEPSILON) { 217 *out << Verbose( 3) << "Normalvectors of both triangles are the same: convex." << endl;218 *out << Verbose(2) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl; 218 219 return true; 219 220 } 220 221 double angle = getAngle(helper[0], helper[1], BaseLineNormal); 221 if ((angle - M_PI) > -MYEPSILON) 222 if ((angle - M_PI) > -MYEPSILON) { 223 *out << Verbose(2) << "ACCEPT: Angle is greater than pi: convex." << endl; 222 224 return true; 223 else 225 } else { 226 *out << Verbose(2) << "REJECT: Angle is less than pi: concave." << endl; 224 227 return false; 228 } 225 229 } 226 230 … … 1767 1771 1768 1772 // delete the temporary other base line 1769 delete(ClosestPoint);1770 1773 delete(OtherBase); 1771 1774 … … 1780 1783 distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]); 1781 1784 } 1782 if ((distance[0] * distance[1]) > MYEPSILON) { // have same sign? 1783 *out << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << " is concave." << endl; 1785 delete(ClosestPoint); 1786 if ((distance[0] * distance[1]) > 0) { // have same sign? 1787 *out << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl; 1784 1788 if (distance[0] < distance[1]) { 1785 1789 Spot = Base->endpoints[0]; … … 1903 1907 Vector NewOffset; 1904 1908 NewOffset.CopyVector(OtherBase->endpoints[0]->node->node); 1909 NewOffset.SubtractVector(Base->endpoints[0]->node->node); 1905 1910 NewOffset.ProjectOntoPlane(&Normal); 1906 1911 NewOffset.AddVector(Base->endpoints[0]->node->node); 1912 Vector NewDirection; 1913 NewDirection.CopyVector(&NewOffset); 1914 NewDirection.AddVector(&OtherBaseline); 1907 1915 1908 1916 // calculate the intersection between this projected baseline and Base 1909 1917 Vector *Intersection = new Vector; 1910 Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, & OtherBaseline, &Normal);1918 Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, &NewDirection, &Normal); 1911 1919 Normal.CopyVector(Intersection); 1912 1920 Normal.SubtractVector(Base->endpoints[0]->node->node); … … 2622 2630 int i; 2623 2631 2632 if (point == NULL) { 2633 *out << Verbose(1) << "ERROR: Cannot remove the point " << point << ", it's NULL!" << endl; 2634 return 0.; 2635 } else 2636 *out << Verbose(2) << "Removing point " << *point << " from tesselated boundary ..." << endl; 2637 2624 2638 // copy old location for the volume 2625 2639 OldPoint.CopyVector(point->node->node); … … 2636 2650 count+=LineRunner->second->triangles.size(); 2637 2651 numbers = new int[count]; 2652 class BoundaryTriangleSet **Candidates = new BoundaryTriangleSet*[count]; 2638 2653 i=0; 2639 2654 for (LineMap::iterator LineRunner = point->lines.begin(); (point != NULL) && (LineRunner != point->lines.end()); LineRunner++) { … … 2641 2656 for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) { 2642 2657 triangle = TriangleRunner->second; 2643 *out << Verbose(2) << "Erasing triangle " << *triangle << "." << endl;2658 Candidates[i] = triangle; 2644 2659 numbers[i++] = triangle->Nr; 2645 RemoveTesselationTriangle(triangle); 2646 triangle = NULL; 2647 } 2648 } 2660 } 2661 } 2662 for (int j=0;j<i;j++) { 2663 RemoveTesselationTriangle(Candidates[j]); 2664 } 2665 delete[](Candidates); 2649 2666 *out << Verbose(1) << i << " triangles were removed." << endl; 2650 2667
Note:
See TracChangeset
for help on using the changeset viewer.