- Timestamp:
- Jun 28, 2010, 3:38:05 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:
- 13892b, 51a5c8
- Parents:
- b2531f (diff), c39cc4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (06/28/10 14:53:18)
- git-committer:
- Frederik Heber <heber@…> (06/28/10 15:38:05)
- Location:
- src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
rb2531f rbdb143 10 10 11 11 #include "Legacy/oldmenu.hpp" 12 #include "analysis_bonds.hpp" 12 13 #include "analysis_correlation.hpp" 13 14 #include "World.hpp" … … 509 510 Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl; 510 511 Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl; 512 Log() << Verbose(0) << " h - count the number of hydrogen bonds" << endl; 511 513 Log() << Verbose(0) << "all else - go back" << endl; 512 514 Log() << Verbose(0) << "===============================================" << endl; … … 597 599 output->close(); 598 600 delete(output); 601 } 602 break; 603 case 'h': 604 { 605 int Z1; 606 cout << "Please enter first interface element: "; 607 cin >> Z1; 608 const element * InterfaceElement = World::getInstance().getPeriode()->FindElement(Z1); 609 int Z2; 610 cout << "Please enter second interface element: "; 611 cin >> Z2; 612 const element * InterfaceElement2 = World::getInstance().getPeriode()->FindElement(Z2); 613 cout << endl << "There are " << CountHydrogenBridgeBonds(World::getInstance().getMolecules(), InterfaceElement, InterfaceElement2) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << " and " << (InterfaceElement2 != 0 ? InterfaceElement2->name : "None") << "." << endl; 599 614 } 600 615 break; -
src/analysis_bonds.cpp
rb2531f rbdb143 121 121 * \param *molecules molecules to count bonds 122 122 * \param *InterfaceElement or NULL 123 */ 124 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL) 123 * \param *Interface2Element or NULL 124 */ 125 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL, const element * Interface2Element = NULL) 125 126 { 126 127 int count = 0; … … 128 129 double Otherangle = 0.; 129 130 bool InterfaceFlag = false; 131 bool Interface2Flag = false; 130 132 bool OtherHydrogenFlag = true; 131 133 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) { … … 145 147 OtherHydrogens = 0; 146 148 InterfaceFlag = (InterfaceElement == NULL); 149 Interface2Flag = (Interface2Element == NULL); 147 150 for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) { 148 151 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner); … … 155 158 } 156 159 InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement); 160 Interface2Flag = Interface2Flag || (OtherAtom->type == Interface2Element); 157 161 } 158 162 DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl); … … 168 172 break; 169 173 } 170 if (InterfaceFlag && OtherHydrogenFlag) {174 if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) { 171 175 // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule 172 176 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) { -
src/analysis_bonds.hpp
rb2531f rbdb143 33 33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max); 34 34 35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement );35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement, const element * Interface2Element); 36 36 int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second); 37 37 int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third); -
src/boundary.cpp
rb2531f rbdb143 1004 1004 // // Purges surplus triangles. 1005 1005 // TesselStruct->RemoveDegeneratedTriangles(); 1006 1007 // check envelope for consistency1008 status = CheckListOfBaselines(TesselStruct);1006 // 1007 // // check envelope for consistency 1008 // status = CheckListOfBaselines(TesselStruct); 1009 1009 1010 1010 cout << "before correction" << endl; -
src/builder.cpp
rb2531f rbdb143 63 63 #include "molecule.hpp" 64 64 #include "periodentafel.hpp" 65 #include "tesselationhelpers.hpp" 65 66 #include "UIElements/UIFactory.hpp" 66 67 #include "UIElements/TextUI/TextUIFactory.hpp" -
src/tesselation.cpp
rb2531f rbdb143 231 231 { 232 232 Info FunctionInfo(__func__); 233 double angle = CalculateConvexity(); 234 if (angle > -MYEPSILON) { 235 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 236 return true; 237 } else { 238 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 239 return false; 240 } 241 } 242 243 244 /** Calculates the angle between two triangles with respect to their normal vector. 245 * We sum the two angles of each height vector with respect to the center of the baseline. 246 * \return angle > 0 then convex, if < 0 then concave 247 */ 248 double BoundaryLineSet::CalculateConvexity() const 249 { 250 Info FunctionInfo(__func__); 233 251 Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck; 234 252 // get the two triangles … … 279 297 BaseLineNormal.Scale(-1.); 280 298 double angle = GetAngle(helper[0], helper[1], BaseLineNormal); 281 if ((angle - M_PI) > -MYEPSILON) { 282 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 283 return true; 284 } else { 285 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 286 return false; 287 } 299 return (angle - M_PI); 288 300 } 289 301 … … 304 316 /** Returns other endpoint of the line. 305 317 * \param *point other endpoint 306 * \return NULL - if endpoint not contained in BoundaryLineSet , or pointer to BoundaryPointSet otherwise318 * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise 307 319 */ 308 320 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const … … 315 327 else 316 328 return NULL; 329 } 330 ; 331 332 /** Returns other triangle of the line. 333 * \param *point other endpoint 334 * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise 335 */ 336 class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const 337 { 338 Info FunctionInfo(__func__); 339 if (triangles.size() == 2) { 340 for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner) 341 if (TriangleRunner->second != triangle) 342 return TriangleRunner->second; 343 } 344 return NULL; 317 345 } 318 346 ; … … 661 689 ; 662 690 691 /** Returns the baseline which does not contain the given boundary point \a *point. 692 * \param *point endpoint which is neither endpoint of the desired line 693 * \return pointer to desired third baseline 694 */ 695 class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const 696 { 697 Info FunctionInfo(__func__); 698 // sanity check 699 if (!ContainsBoundaryPoint(point)) 700 return NULL; 701 for (int i = 0; i < 3; i++) 702 if (!lines[i]->ContainsBoundaryPoint(point)) 703 return lines[i]; 704 // actually, that' impossible :) 705 return NULL; 706 } 707 ; 708 663 709 /** Calculates the center point of the triangle. 664 710 * Is third of the sum of all endpoints. … … 1110 1156 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner)); 1111 1157 1112 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << OtherOptCenter<< ":" << endl);1158 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl); 1113 1159 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1114 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance( OtherOptCenter) << "." << endl);1160 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl); 1115 1161 1116 1162 // remove baseline's endpoints and candidates … … 1128 1174 DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl); 1129 1175 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1130 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << endl); 1176 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl); 1177 1178 // check with animate_sphere.tcl VMD script 1179 if (ThirdPoint != NULL) { 1180 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl); 1181 } else { 1182 DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl); 1183 DoeLog(1) && (eLog() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl); 1184 } 1131 1185 } 1132 1186 delete (ListofPoints); 1133 1187 1134 // check with animate_sphere.tcl VMD script1135 if (ThirdPoint != NULL) {1136 DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);1137 } else {1138 DoLog(1) && (Log() << Verbose(1) << "Check by: ... missing third point ..." << endl);1139 DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2) << endl);1140 }1141 1188 } 1142 1189 return flag; … … 3290 3337 } 3291 3338 } else { 3292 Do Log(1) && (Log() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);3339 DoeLog(0) && (eLog() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl); 3293 3340 } 3294 3341 } else { … … 4590 4637 4591 4638 DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl); 4592 IndexToIndex::iterator it; 4593 for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 4639 for (IndexToIndex::iterator it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 4594 4640 DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl); 4595 4641 … … 4609 4655 int count = 0; 4610 4656 4611 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) { 4657 // iterate over all degenerated triangles 4658 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); !DegeneratedTriangles->empty(); TriangleKeyRunner = DegeneratedTriangles->begin()) { 4659 DoLog(0) && (Log() << Verbose(0) << "Checking presence of triangles " << TriangleKeyRunner->first << " and " << TriangleKeyRunner->second << "." << endl); 4660 // both ways are stored in the map, only use one 4661 if (TriangleKeyRunner->first > TriangleKeyRunner->second) 4662 continue; 4663 4664 // determine from the keys in the map the two _present_ triangles 4612 4665 finder = TrianglesOnBoundary.find(TriangleKeyRunner->first); 4613 4666 if (finder != TrianglesOnBoundary.end()) 4614 4667 triangle = finder->second; 4615 4668 else 4616 break;4669 continue; 4617 4670 finder = TrianglesOnBoundary.find(TriangleKeyRunner->second); 4618 4671 if (finder != TrianglesOnBoundary.end()) 4619 4672 partnerTriangle = finder->second; 4620 4673 else 4621 break; 4622 4674 continue; 4675 4676 // determine which lines are shared by the two triangles 4623 4677 bool trianglesShareLine = false; 4624 4678 for (int i = 0; i < 3; ++i) -
src/tesselation.hpp
rb2531f rbdb143 138 138 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const; 139 139 bool CheckConvexityCriterion() const; 140 double CalculateConvexity() const; 140 141 class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const; 142 class BoundaryTriangleSet *GetOtherTriangle(const BoundaryTriangleSet * const triangle) const; 141 143 142 144 class BoundaryPointSet *endpoints[2]; … … 164 166 bool ContainsBoundaryPoint(const TesselPoint * const point) const; 165 167 class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const; 168 class BoundaryLineSet *GetThirdLine(const BoundaryPointSet * const point) const; 166 169 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const; 167 170 bool IsPresentTupel(const BoundaryTriangleSet * const T) const; -
src/tesselationhelpers.cpp
rb2531f rbdb143 12 12 #include "info.hpp" 13 13 #include "linkedcell.hpp" 14 #include "linearsystemofequations.hpp" 14 15 #include "log.hpp" 15 16 #include "tesselation.hpp" … … 185 186 beta = M_PI - SideC.Angle(SideA); 186 187 gamma = M_PI - SideA.Angle(SideB); 187 //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;188 Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl; 188 189 if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) { 189 190 DoeLog(2) && (eLog()<< Verbose(2) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl); … … 198 199 (*Center) += helper; 199 200 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma))); 201 Log() << Verbose(1) << "INFO: Center (1st algo) is at " << *Center << "." << endl; 202 203 // LinearSystemOfEquations LSofEq(NDIM,NDIM); 204 // double *matrix = new double[NDIM*NDIM]; 205 // matrix[0] = 0.; 206 // matrix[1] = a.DistanceSquared(b); 207 // matrix[2] = a.DistanceSquared(c); 208 // matrix[3] = a.DistanceSquared(b); 209 // matrix[4] = 0.; 210 // matrix[5] = b.DistanceSquared(c); 211 // matrix[6] = a.DistanceSquared(c); 212 // matrix[7] = b.DistanceSquared(c); 213 // matrix[8] = 0.; 214 // cout << "Matrix is: "; 215 // for (int i=0;i<NDIM*NDIM;i++) 216 // cout << matrix[i] << "\t"; 217 // cout << endl; 218 // LSofEq.SetA(matrix); 219 // delete[](matrix); 220 // LSofEq.Setb(new Vector(1.,1.,1.)); 221 // LSofEq.SetSymmetric(true); 222 // helper.Zero(); 223 // if (!LSofEq.GetSolutionAsVector(helper)) { 224 // DoLog(0) && (eLog()<< Verbose(0) << "Could not solve the linear system in GetCenterofCircumCircle()!" << endl); 225 // } 226 // cout << "Solution is " << helper << endl; 227 // is equivalent to the three lines below 228 helper[0] = SideA.NormSquared()*(SideB.NormSquared()+SideC.NormSquared() - SideA.NormSquared()); 229 helper[1] = SideB.NormSquared()*(SideC.NormSquared()+SideA.NormSquared() - SideB.NormSquared()); 230 helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared()); 231 232 Center->Zero(); 233 *Center += helper[0] * a; 234 *Center += helper[1] * b; 235 *Center += helper[2] * c; 236 Center->Scale(1./(helper[0]+helper[1]+helper[2])); 237 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl; 200 238 }; 201 239 … … 419 457 /** Calculates the volume of a general tetraeder. 420 458 * \param *a first vector 421 * \param * a firstvector422 * \param * a firstvector423 * \param * a firstvector459 * \param *b second vector 460 * \param *c third vector 461 * \param *d fourth vector 424 462 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$ 425 463 */ … … 439 477 volume = 1./6. * fabs(Point.ScalarProduct(TetraederVector[2])); 440 478 return volume; 479 }; 480 481 /** Calculates the area of a general triangle. 482 * We use the Heron's formula of area, [Bronstein, S. 138] 483 * \param &A first vector 484 * \param &B second vector 485 * \param &C third vector 486 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$ 487 */ 488 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C) 489 { 490 Info FunctionInfo(__func__); 491 492 const double sidea = B.distance(C); 493 const double sideb = A.distance(C); 494 const double sidec = A.distance(B); 495 const double s = (sidea+sideb+sidec)/2.; 496 497 const double area = sqrt(s*(s-sidea)*(s-sideb)*(s-sidec)); 498 return area; 441 499 }; 442 500 … … 882 940 class BoundaryPointSet *point = NULL; 883 941 class BoundaryLineSet *line = NULL; 884 885 // calculate remaining concavity 942 class BoundaryTriangleSet *triangle = NULL; 943 double ConcavityPerLine = 0.; 944 double ConcavityPerTriangle = 0.; 945 double area = 0.; 946 double totalarea = 0.; 947 886 948 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 887 949 point = PointRunner->second; 888 950 DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl); 889 point->value = 0; 951 952 // calculate mean concavity over all connected line 953 ConcavityPerLine = 0.; 890 954 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 891 955 line = LineRunner->second; 892 956 //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl; 893 if (!line->CheckConvexityCriterion()) 894 point->value += 1; 895 } 896 } 897 }; 898 957 ConcavityPerLine -= line->CalculateConvexity(); 958 } 959 ConcavityPerLine /= point->lines.size(); 960 961 // weigh with total area of the surrounding triangles 962 totalarea = 0.; 963 TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second); 964 for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 965 totalarea += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node); 966 } 967 ConcavityPerLine *= totalarea; 968 969 // calculate mean concavity over all attached triangles 970 ConcavityPerTriangle = 0.; 971 for (TriangleSet::const_iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 972 line = (*TriangleRunner)->GetThirdLine(PointRunner->second); 973 triangle = line->GetOtherTriangle(*TriangleRunner); 974 area = CalculateAreaofGeneralTriangle(*triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node); 975 area += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node); 976 area *= -line->CalculateConvexity(); 977 if (area > 0) 978 ConcavityPerTriangle += area; 979 // else 980 // ConcavityPerTriangle -= area; 981 } 982 ConcavityPerTriangle /= triangles->size()/totalarea; 983 delete(triangles); 984 985 // add up 986 point->value = ConcavityPerLine + ConcavityPerTriangle; 987 } 988 }; 989 990 991 992 /** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation. 993 * Sets BoundaryPointSet::value equal to the nearest distance to convex envelope. 994 * \param *out output stream for debugging 995 * \param *TesselStruct pointer to Tesselation structure 996 * \param *Convex pointer to convex Tesselation structure as reference 997 */ 998 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex) 999 { 1000 Info FunctionInfo(__func__); 1001 double distance = 0.; 1002 1003 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 1004 DoeLog(1) && (eLog() << Verbose(1) << "INFO: Current point is " << * PointRunner->second << "." << endl); 1005 1006 distance = 0.; 1007 for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) { 1008 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(*PointRunner->second->node->node, TriangleRunner->second); 1009 if (CurrentDistance < distance) 1010 distance = CurrentDistance; 1011 } 1012 1013 PointRunner->second->value = distance; 1014 } 1015 }; 899 1016 900 1017 /** Checks whether each BoundaryLineSet in the Tesselation has two triangles. -
src/tesselationhelpers.hpp
rb2531f rbdb143 43 43 /********************************************** definitions *********************************/ 44 44 45 #define HULLEPSILON 1e- 1045 #define HULLEPSILON 1e-9 //!< TODO: Get rid of HULLEPSILON, points to numerical instabilities 46 46 47 47 /********************************************** declarations *******************************/ … … 55 55 bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4); 56 56 double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d); 57 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C); 57 58 double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector); 58 59 … … 68 69 void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud); 69 70 void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct); 71 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex); 70 72 double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle); 71 73 -
src/unittests/CountBondsUnitTest.cpp
rb2531f rbdb143 154 154 Translator = Vector(3,0,0); 155 155 TestMolecule2->Translate(&Translator); 156 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );157 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen ) );156 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 157 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) ); 158 158 //OutputTestMolecule(TestMolecule2, "testmolecule2-1.xyz"); 159 159 Translator = Vector(-3,0,0); … … 163 163 Translator = Vector(0,3,0); 164 164 TestMolecule2->Translate(&Translator); 165 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );165 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 166 166 //OutputTestMolecule(TestMolecule2, "testmolecule2-2.xyz"); 167 167 Translator = Vector(0,-3,0); … … 172 172 TestMolecule2->Scale((const double ** const)&mirror); 173 173 TestMolecule2->Translate(&Translator); 174 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );174 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 175 175 //OutputTestMolecule(TestMolecule2, "testmolecule2-3.xyz"); 176 176 Translator = Vector(0,3,0); … … 181 181 Translator = Vector(2,1,0); 182 182 TestMolecule2->Translate(&Translator); 183 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );183 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 184 184 //OutputTestMolecule(TestMolecule2, "testmolecule2-4.xyz"); 185 185 Translator = Vector(-2,-1,0); … … 189 189 Translator = Vector(0,0,3); 190 190 TestMolecule2->Translate(&Translator); 191 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );191 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 192 192 //OutputTestMolecule(TestMolecule2, "testmolecule2-5.xyz"); 193 193 Translator = Vector(0,0,-3); … … 198 198 TestMolecule2->Scale((const double ** const)&mirror); 199 199 TestMolecule2->Translate(&Translator); 200 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );200 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 201 201 //OutputTestMolecule(TestMolecule2, "testmolecule2-6.xyz"); 202 202 Translator = Vector(3,0,0); … … 208 208 TestMolecule2->Scale((const double ** const)&mirror); 209 209 TestMolecule2->Translate(&Translator); 210 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );210 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 211 211 //OutputTestMolecule(TestMolecule2, "testmolecule2-7.xyz"); 212 212 Translator = Vector(-3,0,0); … … 219 219 TestMolecule2->Translate(&Translator); 220 220 //OutputTestMolecule(TestMolecule2, "testmolecule2-8.xyz"); 221 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );221 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 222 222 Translator = Vector(0,-3,0); 223 223 TestMolecule2->Translate(&Translator); -
src/unittests/TestRunnerMain.cpp
rb2531f rbdb143 17 17 #include "../../../TestRunnerClient.h" 18 18 #include "../../../TestRunnerClient.cpp" 19 19 20 #else 20 #include "UnitTestMain.cpp"21 #endif22 21 22 #include "unittests/UnitTestMain.cpp" 23 24 #endif /* HAVE_ECUT */ -
src/unittests/UnitTestMain.cpp
rb2531f rbdb143 6 6 */ 7 7 8 #include <cppunit/CompilerOutputter.h>9 #include <cppunit/extensions/TestFactoryRegistry.h>10 #include <cppunit/ui/text/TestRunner.h>11 12 8 // include config.h 13 9 #ifdef HAVE_CONFIG_H 14 10 #include <config.h> 15 11 #endif 12 13 #include <cppunit/CompilerOutputter.h> 14 #include <cppunit/extensions/TestFactoryRegistry.h> 15 #include <cppunit/ui/text/TestRunner.h> 16 16 17 17 /********************************************** Main routine **************************************/ … … 35 35 return wasSucessful ? 0 : 1; 36 36 }; 37
Note:
See TracChangeset
for help on using the changeset viewer.