Changes in / [27ac00:a7c344]
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
r27ac00 ra7c344 8 8 9 9 #include "Legacy/oldmenu.hpp" 10 #include "analysis_bonds.hpp" 10 11 #include "analysis_correlation.hpp" 11 12 #include "World.hpp" … … 502 503 Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl; 503 504 Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl; 505 Log() << Verbose(0) << " h - count the number of hydrogen bonds" << endl; 504 506 Log() << Verbose(0) << "all else - go back" << endl; 505 507 Log() << Verbose(0) << "===============================================" << endl; … … 592 594 output->close(); 593 595 delete(output); 596 } 597 break; 598 case 'h': 599 { 600 int Z1; 601 cout << "Please enter first interface element: "; 602 cin >> Z1; 603 const element * InterfaceElement = World::getInstance().getPeriode()->FindElement(Z1); 604 int Z2; 605 cout << "Please enter second interface element: "; 606 cin >> Z2; 607 const element * InterfaceElement2 = World::getInstance().getPeriode()->FindElement(Z2); 608 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; 594 609 } 595 610 break; -
src/analysis_bonds.cpp
r27ac00 ra7c344 123 123 * \param *molecules molecules to count bonds 124 124 * \param *InterfaceElement or NULL 125 */ 126 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL) 125 * \param *Interface2Element or NULL 126 */ 127 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL, const element * Interface2Element = NULL) 127 128 { 128 129 atom *Walker = NULL; … … 132 133 double Otherangle = 0.; 133 134 bool InterfaceFlag = false; 135 bool Interface2Flag = false; 134 136 bool OtherHydrogenFlag = true; 135 137 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) { … … 151 153 OtherHydrogens = 0; 152 154 InterfaceFlag = (InterfaceElement == NULL); 155 Interface2Flag = (Interface2Element == NULL); 153 156 for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) { 154 157 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner); … … 161 164 } 162 165 InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement); 166 Interface2Flag = Interface2Flag || (OtherAtom->type == Interface2Element); 163 167 } 164 168 DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl); … … 174 178 break; 175 179 } 176 if (InterfaceFlag && OtherHydrogenFlag) {180 if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) { 177 181 // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule 178 182 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) { -
src/analysis_bonds.hpp
r27ac00 ra7c344 33 33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max); 34 34 35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, 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
r27ac00 ra7c344 1039 1039 // // Purges surplus triangles. 1040 1040 // TesselStruct->RemoveDegeneratedTriangles(); 1041 1042 // check envelope for consistency1043 status = CheckListOfBaselines(TesselStruct);1041 // 1042 // // check envelope for consistency 1043 // status = CheckListOfBaselines(TesselStruct); 1044 1044 1045 1045 // store before correction -
src/builder.cpp
r27ac00 ra7c344 70 70 #include "molecule.hpp" 71 71 #include "periodentafel.hpp" 72 #include "tesselationhelpers.hpp" 72 73 #include "UIElements/UIFactory.hpp" 73 74 #include "UIElements/MainWindow.hpp" … … 1519 1520 switch(argv[argptr-1][1]) { 1520 1521 case 'h': 1521 case 'H':1522 1522 case '?': 1523 1523 DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl); … … 1538 1538 DoLog(0) && (Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl); 1539 1539 DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl); 1540 DoLog(0) && (Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl); 1540 DoLog(0) && (Log() << Verbose(0) << "\t-h/-?\tGive this help screen." << endl); 1541 DoLog(0) && (Log() << Verbose(0) << "\t-H\tCount Hydrogen bridge bonds." << endl); 1541 1542 DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl); 1542 1543 DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl); … … 1819 1820 } 1820 1821 break; 1822 case 'H': 1823 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (argv[argptr+1][0] == '-')) { 1824 ExitFlag = 255; 1825 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for calculating hydrogen bridge bonds: -H <Z1> <Z2>" << endl); 1826 performCriticalExit(); 1827 } else { 1828 if (ExitFlag == 0) ExitFlag = 1; 1829 const element *elemental = periode->FindElement((const int) atoi(argv[argptr])); 1830 const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+1])); 1831 cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, elemental, elemental2) << " hydrogen bridges with connections to " << (elemental != 0 ? elemental->name : "None") << " and " << (elemental2 != 0 ? elemental2->name : "None") << "." << endl; 1832 argptr+=1; 1833 } 1834 break; 1821 1835 case 'C': 1822 1836 { … … 2089 2103 } else { 2090 2104 class Tesselation *T = NULL; 2105 class Tesselation *Convex = NULL; 2091 2106 const LinkedCell *LCList = NULL; 2107 const LinkedCell *LCListConvex = NULL; 2092 2108 molecule * Boundary = NULL; 2093 2109 //string filename(argv[argptr+1]); … … 2109 2125 if (!FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1])) 2110 2126 ExitFlag = 255; 2127 const double ConvexRadius = 20.; 2128 LCListConvex = new LinkedCell(Boundary, 2.*ConvexRadius); 2129 // setVerbosity(3); 2130 if (!FindNonConvexBorder(Boundary, Convex, LCListConvex, ConvexRadius, "ConvexEnvelope")) 2131 ExitFlag = 255; 2132 CalculateConstrictionPerBoundaryPoint(T, Convex); 2133 StoreTrianglesinFile(mol, (const Tesselation *&)T, argv[argptr+1], ""); 2111 2134 //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str()); 2112 2135 end = clock(); -
src/tesselation.cpp
r27ac00 ra7c344 230 230 { 231 231 Info FunctionInfo(__func__); 232 double angle = CalculateConvexity(); 233 if (angle > -MYEPSILON) { 234 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 235 return true; 236 } else { 237 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 238 return false; 239 } 240 } 241 242 243 /** Calculates the angle between two triangles with respect to their normal vector. 244 * We sum the two angles of each height vector with respect to the center of the baseline. 245 * \return angle > 0 then convex, if < 0 then concave 246 */ 247 double BoundaryLineSet::CalculateConvexity() const 248 { 249 Info FunctionInfo(__func__); 232 250 Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck; 233 251 // get the two triangles … … 278 296 BaseLineNormal.Scale(-1.); 279 297 double angle = GetAngle(helper[0], helper[1], BaseLineNormal); 280 if ((angle - M_PI) > -MYEPSILON) { 281 DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl); 282 return true; 283 } else { 284 DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl); 285 return false; 286 } 298 return (angle - M_PI); 287 299 } 288 300 … … 303 315 /** Returns other endpoint of the line. 304 316 * \param *point other endpoint 305 * \return NULL - if endpoint not contained in BoundaryLineSet , or pointer to BoundaryPointSet otherwise317 * \return NULL - if endpoint not contained in BoundaryLineSet::lines, or pointer to BoundaryPointSet otherwise 306 318 */ 307 319 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const … … 314 326 else 315 327 return NULL; 328 } 329 ; 330 331 /** Returns other triangle of the line. 332 * \param *point other endpoint 333 * \return NULL - if triangle not contained in BoundaryLineSet::triangles, or pointer to BoundaryTriangleSet otherwise 334 */ 335 class BoundaryTriangleSet *BoundaryLineSet::GetOtherTriangle(const BoundaryTriangleSet * const triangle) const 336 { 337 Info FunctionInfo(__func__); 338 if (triangles.size() == 2) { 339 for (TriangleMap::const_iterator TriangleRunner = triangles.begin(); TriangleRunner != triangles.end(); ++TriangleRunner) 340 if (TriangleRunner->second != triangle) 341 return TriangleRunner->second; 342 } 343 return NULL; 316 344 } 317 345 ; … … 662 690 ; 663 691 692 /** Returns the baseline which does not contain the given boundary point \a *point. 693 * \param *point endpoint which is neither endpoint of the desired line 694 * \return pointer to desired third baseline 695 */ 696 class BoundaryLineSet *BoundaryTriangleSet::GetThirdLine(const BoundaryPointSet * const point) const 697 { 698 Info FunctionInfo(__func__); 699 // sanity check 700 if (!ContainsBoundaryPoint(point)) 701 return NULL; 702 for (int i = 0; i < 3; i++) 703 if (!lines[i]->ContainsBoundaryPoint(point)) 704 return lines[i]; 705 // actually, that' impossible :) 706 return NULL; 707 } 708 ; 709 664 710 /** Calculates the center point of the triangle. 665 711 * Is third of the sum of all endpoints. … … 1111 1157 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner)); 1112 1158 1113 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << OtherOptCenter<< ":" << endl);1159 DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << (*VRunner) << ":" << endl); 1114 1160 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1115 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance( OtherOptCenter) << "." << endl);1161 DoLog(1) && (Log() << Verbose(1) << " " << *(*Runner) << " with distance " << (*Runner)->node->distance(*(*VRunner)) << "." << endl); 1116 1162 1117 1163 // remove baseline's endpoints and candidates … … 1129 1175 DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl); 1130 1176 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner) 1131 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << endl); 1177 DoeLog(1) && (eLog() << Verbose(1) << " " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->node->distance(*(*VRunner)) << setprecision(6) << "." << endl); 1178 1179 // check with animate_sphere.tcl VMD script 1180 if (ThirdPoint != NULL) { 1181 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); 1182 } else { 1183 DoeLog(1) && (eLog() << Verbose(1) << "Check by: ... missing third point ..." << endl); 1184 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); 1185 } 1132 1186 } 1133 1187 delete (ListofPoints); 1134 1188 1135 // check with animate_sphere.tcl VMD script1136 if (ThirdPoint != NULL) {1137 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);1138 } else {1139 DoLog(1) && (Log() << Verbose(1) << "Check by: ... missing third point ..." << endl);1140 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);1141 }1142 1189 } 1143 1190 return flag; … … 3318 3365 } 3319 3366 } else { 3320 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);3367 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); 3321 3368 } 3322 3369 } else { … … 4618 4665 4619 4666 DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl); 4620 IndexToIndex::iterator it; 4621 for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 4667 for (IndexToIndex::iterator it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 4622 4668 DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl); 4623 4669 … … 4637 4683 int count = 0; 4638 4684 4639 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) { 4685 // iterate over all degenerated triangles 4686 for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); !DegeneratedTriangles->empty(); TriangleKeyRunner = DegeneratedTriangles->begin()) { 4687 DoLog(0) && (Log() << Verbose(0) << "Checking presence of triangles " << TriangleKeyRunner->first << " and " << TriangleKeyRunner->second << "." << endl); 4688 // both ways are stored in the map, only use one 4689 if (TriangleKeyRunner->first > TriangleKeyRunner->second) 4690 continue; 4691 4692 // determine from the keys in the map the two _present_ triangles 4640 4693 finder = TrianglesOnBoundary.find(TriangleKeyRunner->first); 4641 4694 if (finder != TrianglesOnBoundary.end()) 4642 4695 triangle = finder->second; 4643 4696 else 4644 break;4697 continue; 4645 4698 finder = TrianglesOnBoundary.find(TriangleKeyRunner->second); 4646 4699 if (finder != TrianglesOnBoundary.end()) 4647 4700 partnerTriangle = finder->second; 4648 4701 else 4649 break; 4650 4702 continue; 4703 4704 // determine which lines are shared by the two triangles 4651 4705 bool trianglesShareLine = false; 4652 4706 for (int i = 0; i < 3; ++i) -
src/tesselation.hpp
r27ac00 ra7c344 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
r27ac00 ra7c344 10 10 #include "info.hpp" 11 11 #include "linkedcell.hpp" 12 #include "linearsystemofequations.hpp" 12 13 #include "log.hpp" 13 14 #include "tesselation.hpp" … … 183 184 beta = M_PI - SideC.Angle(SideA); 184 185 gamma = M_PI - SideA.Angle(SideB); 185 //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;186 Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl; 186 187 if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) { 187 188 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); … … 196 197 (*Center) += helper; 197 198 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma))); 199 Log() << Verbose(1) << "INFO: Center (1st algo) is at " << *Center << "." << endl; 200 201 // LinearSystemOfEquations LSofEq(NDIM,NDIM); 202 // double *matrix = new double[NDIM*NDIM]; 203 // matrix[0] = 0.; 204 // matrix[1] = a.DistanceSquared(b); 205 // matrix[2] = a.DistanceSquared(c); 206 // matrix[3] = a.DistanceSquared(b); 207 // matrix[4] = 0.; 208 // matrix[5] = b.DistanceSquared(c); 209 // matrix[6] = a.DistanceSquared(c); 210 // matrix[7] = b.DistanceSquared(c); 211 // matrix[8] = 0.; 212 // cout << "Matrix is: "; 213 // for (int i=0;i<NDIM*NDIM;i++) 214 // cout << matrix[i] << "\t"; 215 // cout << endl; 216 // LSofEq.SetA(matrix); 217 // delete[](matrix); 218 // LSofEq.Setb(new Vector(1.,1.,1.)); 219 // LSofEq.SetSymmetric(true); 220 // helper.Zero(); 221 // if (!LSofEq.GetSolutionAsVector(helper)) { 222 // DoLog(0) && (eLog()<< Verbose(0) << "Could not solve the linear system in GetCenterofCircumCircle()!" << endl); 223 // } 224 // cout << "Solution is " << helper << endl; 225 // is equivalent to the three lines below 226 helper[0] = SideA.NormSquared()*(SideB.NormSquared()+SideC.NormSquared() - SideA.NormSquared()); 227 helper[1] = SideB.NormSquared()*(SideC.NormSquared()+SideA.NormSquared() - SideB.NormSquared()); 228 helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared()); 229 230 Center->Zero(); 231 *Center += helper[0] * a; 232 *Center += helper[1] * b; 233 *Center += helper[2] * c; 234 Center->Scale(1./(helper[0]+helper[1]+helper[2])); 235 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << *Center << "." << endl; 198 236 }; 199 237 … … 417 455 /** Calculates the volume of a general tetraeder. 418 456 * \param *a first vector 419 * \param * a firstvector420 * \param * a firstvector421 * \param * a firstvector457 * \param *b second vector 458 * \param *c third vector 459 * \param *d fourth vector 422 460 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$ 423 461 */ … … 437 475 volume = 1./6. * fabs(Point.ScalarProduct(TetraederVector[2])); 438 476 return volume; 477 }; 478 479 /** Calculates the area of a general triangle. 480 * We use the Heron's formula of area, [Bronstein, S. 138] 481 * \param &A first vector 482 * \param &B second vector 483 * \param &C third vector 484 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$ 485 */ 486 double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C) 487 { 488 Info FunctionInfo(__func__); 489 490 const double sidea = B.distance(C); 491 const double sideb = A.distance(C); 492 const double sidec = A.distance(B); 493 const double s = (sidea+sideb+sidec)/2.; 494 495 const double area = sqrt(s*(s-sidea)*(s-sideb)*(s-sidec)); 496 return area; 439 497 }; 440 498 … … 871 929 class BoundaryPointSet *point = NULL; 872 930 class BoundaryLineSet *line = NULL; 873 874 // calculate remaining concavity 931 class BoundaryTriangleSet *triangle = NULL; 932 double ConcavityPerLine = 0.; 933 double ConcavityPerTriangle = 0.; 934 double area = 0.; 935 double totalarea = 0.; 936 875 937 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 876 938 point = PointRunner->second; 877 939 DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl); 878 point->value = 0; 940 941 // calculate mean concavity over all connected line 942 ConcavityPerLine = 0.; 879 943 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 880 944 line = LineRunner->second; 881 945 //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl; 882 if (!line->CheckConvexityCriterion()) 883 point->value += 1; 884 } 885 } 886 }; 887 946 ConcavityPerLine -= line->CalculateConvexity(); 947 } 948 ConcavityPerLine /= point->lines.size(); 949 950 // weigh with total area of the surrounding triangles 951 totalarea = 0.; 952 TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second); 953 for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 954 totalarea += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node); 955 } 956 ConcavityPerLine *= totalarea; 957 958 // calculate mean concavity over all attached triangles 959 ConcavityPerTriangle = 0.; 960 for (TriangleSet::const_iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) { 961 line = (*TriangleRunner)->GetThirdLine(PointRunner->second); 962 triangle = line->GetOtherTriangle(*TriangleRunner); 963 area = CalculateAreaofGeneralTriangle(*triangle->endpoints[0]->node->node, *triangle->endpoints[1]->node->node, *triangle->endpoints[2]->node->node); 964 area += CalculateAreaofGeneralTriangle(*(*TriangleRunner)->endpoints[0]->node->node, *(*TriangleRunner)->endpoints[1]->node->node, *(*TriangleRunner)->endpoints[2]->node->node); 965 area *= -line->CalculateConvexity(); 966 if (area > 0) 967 ConcavityPerTriangle += area; 968 // else 969 // ConcavityPerTriangle -= area; 970 } 971 ConcavityPerTriangle /= triangles->size()/totalarea; 972 delete(triangles); 973 974 // add up 975 point->value = ConcavityPerLine + ConcavityPerTriangle; 976 } 977 }; 978 979 980 981 /** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation. 982 * Sets BoundaryPointSet::value equal to the nearest distance to convex envelope. 983 * \param *out output stream for debugging 984 * \param *TesselStruct pointer to Tesselation structure 985 * \param *Convex pointer to convex Tesselation structure as reference 986 */ 987 void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex) 988 { 989 Info FunctionInfo(__func__); 990 double distance = 0.; 991 992 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) { 993 DoeLog(1) && (eLog() << Verbose(1) << "INFO: Current point is " << * PointRunner->second << "." << endl); 994 995 distance = 0.; 996 for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) { 997 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(*PointRunner->second->node->node, TriangleRunner->second); 998 if (CurrentDistance < distance) 999 distance = CurrentDistance; 1000 } 1001 1002 PointRunner->second->value = distance; 1003 } 1004 }; 888 1005 889 1006 /** Checks whether each BoundaryLineSet in the Tesselation has two triangles. -
src/tesselationhelpers.hpp
r27ac00 ra7c344 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
r27ac00 ra7c344 167 167 Translator = Vector(3,0,0); 168 168 TestMolecule2->Translate(&Translator); 169 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );170 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen ) );169 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 170 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen, NULL) ); 171 171 //OutputTestMolecule(TestMolecule2, "testmolecule2-1.xyz"); 172 172 Translator = Vector(-3,0,0); … … 176 176 Translator = Vector(0,3,0); 177 177 TestMolecule2->Translate(&Translator); 178 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );178 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 179 179 //OutputTestMolecule(TestMolecule2, "testmolecule2-2.xyz"); 180 180 Translator = Vector(0,-3,0); … … 185 185 TestMolecule2->Scale((const double ** const)&mirror); 186 186 TestMolecule2->Translate(&Translator); 187 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );187 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 188 188 //OutputTestMolecule(TestMolecule2, "testmolecule2-3.xyz"); 189 189 Translator = Vector(0,3,0); … … 194 194 Translator = Vector(2,1,0); 195 195 TestMolecule2->Translate(&Translator); 196 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL ) );196 CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 197 197 //OutputTestMolecule(TestMolecule2, "testmolecule2-4.xyz"); 198 198 Translator = Vector(-2,-1,0); … … 202 202 Translator = Vector(0,0,3); 203 203 TestMolecule2->Translate(&Translator); 204 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );204 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 205 205 //OutputTestMolecule(TestMolecule2, "testmolecule2-5.xyz"); 206 206 Translator = Vector(0,0,-3); … … 211 211 TestMolecule2->Scale((const double ** const)&mirror); 212 212 TestMolecule2->Translate(&Translator); 213 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );213 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 214 214 //OutputTestMolecule(TestMolecule2, "testmolecule2-6.xyz"); 215 215 Translator = Vector(3,0,0); … … 221 221 TestMolecule2->Scale((const double ** const)&mirror); 222 222 TestMolecule2->Translate(&Translator); 223 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );223 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 224 224 //OutputTestMolecule(TestMolecule2, "testmolecule2-7.xyz"); 225 225 Translator = Vector(-3,0,0); … … 232 232 TestMolecule2->Translate(&Translator); 233 233 //OutputTestMolecule(TestMolecule2, "testmolecule2-8.xyz"); 234 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL ) );234 CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL, NULL) ); 235 235 Translator = Vector(0,-3,0); 236 236 TestMolecule2->Translate(&Translator);
Note:
See TracChangeset
for help on using the changeset viewer.