Changes in / [76102e:124e14]
- Location:
- src
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r76102e r124e14 789 789 * \param configuration contains box dimensions 790 790 * \param distance[NDIM] distance between filling molecules in each direction 791 * \param boundary length of boundary zone between molecule and filling mollecules 791 792 * \param epsilon distance to surface which is not filled 792 793 * \param RandAtomDisplacement maximum distance for random displacement per atom … … 795 796 * \return *mol pointer to new molecule with filled atoms 796 797 */ 797 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)798 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation) 798 799 { 799 800 Info FunctionInfo(__func__); … … 856 857 FillIt = false; 857 858 } else { 858 const bool FillResult = (!TesselStruct[i]->IsInnerPoint(CurrentPosition, LCList[i]));859 FillIt = FillIt && FillResult;860 if (Fill Result) {859 const double distance = (TesselStruct[i]->GetDistanceSquaredToSurface(CurrentPosition, LCList[i])); 860 FillIt = FillIt && (distance > boundary*boundary); 861 if (FillIt) { 861 862 Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is outer point." << endl; 862 863 } else { 863 Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is inner point." << endl; 864 Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is inner point or within boundary." << endl; 865 break; 864 866 } 865 867 i++; -
src/boundary.hpp
r76102e r124e14 49 49 50 50 double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename); 51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation); 52 52 void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename); 53 53 Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol); -
src/builder.cpp
r76102e r124e14 1738 1738 if (argptr+6 >=argc) { 1739 1739 ExitFlag = 255; 1740 eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> < randatom> <randmol> <DoRotate>" << endl;1740 eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl; 1741 1741 performCriticalExit(); 1742 1742 } else { … … 1769 1769 for (int i=0;i<NDIM;i++) 1770 1770 distance[i] = atof(argv[argptr+i]); 1771 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), ato i(argv[argptr+5]));1771 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atof(argv[argptr+5]), atoi(argv[argptr+6])); 1772 1772 if (Filling != NULL) { 1773 1773 Filling->ActiveFlag = false; -
src/tesselation.cpp
r76102e r124e14 35 35 * \param *Walker TesselPoint this boundary point represents 36 36 */ 37 BoundaryPointSet::BoundaryPointSet(TesselPoint * Walker) :37 BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) : 38 38 LinesCount(0), 39 39 node(Walker), … … 61 61 * \param *line line to add 62 62 */ 63 void BoundaryPointSet::AddLine( class BoundaryLineSet *line)63 void BoundaryPointSet::AddLine(BoundaryLineSet * const line) 64 64 { 65 65 Info FunctionInfo(__func__); … … 105 105 * \param number number of the list 106 106 */ 107 BoundaryLineSet::BoundaryLineSet( class BoundaryPointSet *Point[2], const int number)107 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number) 108 108 { 109 109 Info FunctionInfo(__func__); … … 115 115 Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding. 116 116 Point[1]->AddLine(this); // 117 // set skipped to false 118 skipped = false; 119 // clear triangles list 120 Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl; 121 }; 122 123 /** Constructor of BoundaryLineSet with two endpoints. 124 * Adds line automatically to each endpoints' LineMap 125 * \param *Point1 first boundary point 126 * \param *Point2 second boundary point 127 * \param number number of the list 128 */ 129 BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number) 130 { 131 Info FunctionInfo(__func__); 132 // set number 133 Nr = number; 134 // set endpoints in ascending order 135 SetEndpointsOrdered(endpoints, Point1, Point2); 136 // add this line to the hash maps of both endpoints 137 Point1->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding. 138 Point2->AddLine(this); // 117 139 // set skipped to false 118 140 skipped = false; … … 171 193 * \param *triangle to add 172 194 */ 173 void BoundaryLineSet::AddTriangle( class BoundaryTriangleSet *triangle)195 void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle) 174 196 { 175 197 Info FunctionInfo(__func__); … … 182 204 * \return true - common endpoint present, false - not connected 183 205 */ 184 bool BoundaryLineSet::IsConnectedTo(c lass BoundaryLineSet *line)206 bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const 185 207 { 186 208 Info FunctionInfo(__func__); … … 197 219 * \return true - triangles are convex, false - concave or less than two triangles connected 198 220 */ 199 bool BoundaryLineSet::CheckConvexityCriterion() 221 bool BoundaryLineSet::CheckConvexityCriterion() const 200 222 { 201 223 Info FunctionInfo(__func__); … … 221 243 int i=0; 222 244 class BoundaryPointSet *node = NULL; 223 for(TriangleMap:: iterator runner = triangles.begin(); runner != triangles.end(); runner++) {245 for(TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) { 224 246 //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl; 225 247 NormalCheck.AddVector(&runner->second->NormalVector); … … 264 286 * \return true - point is of the line, false - is not 265 287 */ 266 bool BoundaryLineSet::ContainsBoundaryPoint(c lass BoundaryPointSet *point)288 bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 267 289 { 268 290 Info FunctionInfo(__func__); … … 277 299 * \return NULL - if endpoint not contained in BoundaryLineSet, or pointer to BoundaryPointSet otherwise 278 300 */ 279 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(c lass BoundaryPointSet *point)301 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const 280 302 { 281 303 Info FunctionInfo(__func__); … … 317 339 * \param number number of triangle 318 340 */ 319 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * line[3],int number) :341 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) : 320 342 Nr(number) 321 343 { … … 376 398 * \param &OtherVector direction vector to make normal vector unique. 377 399 */ 378 void BoundaryTriangleSet::GetNormalVector( Vector &OtherVector)400 void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector) 379 401 { 380 402 Info FunctionInfo(__func__); … … 390 412 /** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses. 391 413 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane 392 * Th is we test if it's really on the plane and whether it's inside the triangle on the plane or not.414 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not. 393 415 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line 394 416 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between … … 400 422 * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle. 401 423 */ 402 bool BoundaryTriangleSet::GetIntersectionInsideTriangle( Vector *MolCenter, Vector *x, Vector *Intersection)424 bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const 403 425 { 404 426 Info FunctionInfo(__func__); … … 452 474 }; 453 475 476 /** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses. 477 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane 478 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not. 479 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line 480 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between 481 * the first two basepoints) or not. 482 * \param *x point 483 * \param *ClosestPoint desired closest point inside triangle to \a *x, is absolute vector 484 * \return Distance squared between \a *x and closest point inside triangle 485 */ 486 double BoundaryTriangleSet::GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const 487 { 488 Info FunctionInfo(__func__); 489 Vector Direction; 490 491 // 1. get intersection with plane 492 Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl; 493 GetCenter(&Direction); 494 if (!ClosestPoint->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, x, &Direction)) { 495 ClosestPoint->CopyVector(x); 496 } 497 498 // 2. Calculate in plane part of line (x, intersection) 499 Vector InPlane; 500 InPlane.CopyVector(x); 501 InPlane.SubtractVector(ClosestPoint); // points from plane intersection to straight-down point 502 InPlane.ProjectOntoPlane(&NormalVector); 503 InPlane.AddVector(ClosestPoint); 504 505 Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl; 506 Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl; 507 Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl; 508 509 // Calculate cross point between one baseline and the desired point such that distance is shortest 510 double ShortestDistance = -1.; 511 bool InsideFlag = false; 512 Vector CrossDirection[3]; 513 Vector CrossPoint[3]; 514 Vector helper; 515 for (int i=0;i<3;i++) { 516 // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point 517 Direction.CopyVector(endpoints[(i+1)%3]->node->node); 518 Direction.SubtractVector(endpoints[i%3]->node->node); 519 // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal); 520 CrossPoint[i].GetIntersectionWithPlane(&Direction, &InPlane, endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node); 521 CrossDirection[i].CopyVector(&CrossPoint[i]); 522 CrossDirection[i].SubtractVector(&InPlane); 523 CrossPoint[i].SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector 524 const double s = CrossPoint[i].ScalarProduct(&Direction)/Direction.NormSquared(); 525 Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl; 526 if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) { 527 CrossPoint[i].AddVector(endpoints[i%3]->node->node); // make cross point absolute again 528 Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i%3]->node->node << " and " << *endpoints[(i+1)%3]->node->node << "." << endl; 529 const double distance = CrossPoint[i].DistanceSquared(x); 530 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 531 ShortestDistance = distance; 532 ClosestPoint->CopyVector(&CrossPoint[i]); 533 } 534 } else 535 CrossPoint[i].Zero(); 536 } 537 InsideFlag = true; 538 for (int i=0;i<3;i++) { 539 const double sign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+1)%3]); 540 const double othersign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+2)%3]);; 541 if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign 542 InsideFlag = false; 543 } 544 if (InsideFlag) { 545 ClosestPoint->CopyVector(&InPlane); 546 ShortestDistance = InPlane.DistanceSquared(x); 547 } else { // also check endnodes 548 for (int i=0;i<3;i++) { 549 const double distance = x->DistanceSquared(endpoints[i]->node->node); 550 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 551 ShortestDistance = distance; 552 ClosestPoint->CopyVector(endpoints[i]->node->node); 553 } 554 } 555 } 556 Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl; 557 return ShortestDistance; 558 }; 559 454 560 /** Checks whether lines is any of the three boundary lines this triangle contains. 455 561 * \param *line line to test 456 562 * \return true - line is of the triangle, false - is not 457 563 */ 458 bool BoundaryTriangleSet::ContainsBoundaryLine(c lass BoundaryLineSet *line)564 bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const 459 565 { 460 566 Info FunctionInfo(__func__); … … 469 575 * \return true - point is of the triangle, false - is not 470 576 */ 471 bool BoundaryTriangleSet::ContainsBoundaryPoint(c lass BoundaryPointSet *point)577 bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const 472 578 { 473 579 Info FunctionInfo(__func__); … … 482 588 * \return true - point is of the triangle, false - is not 483 589 */ 484 bool BoundaryTriangleSet::ContainsBoundaryPoint(c lass TesselPoint *point)590 bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const 485 591 { 486 592 Info FunctionInfo(__func__); … … 495 601 * \return true - is the very triangle, false - is not 496 602 */ 497 bool BoundaryTriangleSet::IsPresentTupel(c lass BoundaryPointSet *Points[3])603 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const 498 604 { 499 605 Info FunctionInfo(__func__); … … 518 624 * \return true - is the very triangle, false - is not 519 625 */ 520 bool BoundaryTriangleSet::IsPresentTupel(c lass BoundaryTriangleSet *T)626 bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const 521 627 { 522 628 Info FunctionInfo(__func__); … … 540 646 * \return pointer third endpoint or NULL if line does not belong to triangle. 541 647 */ 542 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(c lass BoundaryLineSet *line)648 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const 543 649 { 544 650 Info FunctionInfo(__func__); … … 557 663 * \param *center central point on return. 558 664 */ 559 void BoundaryTriangleSet::GetCenter(Vector * center)665 void BoundaryTriangleSet::GetCenter(Vector * const center) const 560 666 { 561 667 Info FunctionInfo(__func__); … … 564 670 center->AddVector(endpoints[i]->node->node); 565 671 center->Scale(1./3.); 672 Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl; 566 673 } 567 674 … … 3135 3242 // for each point, check its lines, remember closest 3136 3243 Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl; 3137 BoundaryLineSet *ClosestLine = NULL;3244 LineSet ClosestLines; 3138 3245 double MinDistance = 1e+16; 3139 3246 Vector BaseLineIntersection; … … 3157 3264 3158 3265 if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) { // intersection would be outside, take closer endpoint 3159 if ((lengthEndA < MinDistance) && (lengthEndA < lengthEndB)) { 3160 ClosestLine = LineRunner->second; 3161 MinDistance = lengthEndA; 3162 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEndA << "." << endl; 3163 } else if (lengthEndB < MinDistance) { 3164 ClosestLine = LineRunner->second; 3165 MinDistance = lengthEndB; 3166 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is closer with " << lengthEndB << "." << endl; 3167 } else { 3266 const double lengthEnd = Min(lengthEndA, lengthEndB); 3267 if (lengthEnd - MinDistance < -MYEPSILON) { // new best line 3268 ClosestLines.clear(); 3269 ClosestLines.insert(LineRunner->second); 3270 MinDistance = lengthEnd; 3271 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl; 3272 } else if (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate 3273 ClosestLines.insert(LineRunner->second); 3274 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl; 3275 } else { // line is worse 3168 3276 Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl; 3169 3277 } … … 3179 3287 eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl; 3180 3288 } 3181 if ((ClosestLine == NULL) || (distance < MinDistance)) {3182 ClosestLine = LineRunner->second;3289 if ((ClosestLines.empty()) || (distance < MinDistance)) { 3290 ClosestLines.insert(LineRunner->second); 3183 3291 MinDistance = distance; 3184 Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl;3292 Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl; 3185 3293 } else { 3186 3294 Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl; … … 3192 3300 3193 3301 // check whether closest line is "too close" :), then it's inside 3194 if (ClosestLine == NULL) {3302 if (ClosestLines.empty()) { 3195 3303 Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl; 3196 3304 return NULL; 3197 3305 } 3198 3306 TriangleList * candidates = new TriangleList; 3199 for (TriangleMap::iterator Runner = ClosestLine->triangles.begin(); Runner != ClosestLine->triangles.end(); Runner++) { 3307 for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++) 3308 for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) { 3200 3309 candidates->push_back(Runner->second); 3201 3310 } … … 3241 3350 }; 3242 3351 3243 /** Checks whether the provided Vector is within the tesselation structure. 3352 /** Checks whether the provided Vector is within the Tesselation structure. 3353 * Basically calls Tesselation::GetDistanceToSurface() and checks the sign of the return value. 3354 * @param point of which to check the position 3355 * @param *LC LinkedCell structure 3356 * 3357 * @return true if the point is inside the Tesselation structure, false otherwise 3358 */ 3359 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const 3360 { 3361 return (GetDistanceSquaredToSurface(Point, LC) > MYEPSILON); 3362 } 3363 3364 /** Returns the distance to the surface given by the tesselation. 3244 3365 * Calls FindClosestTriangleToVector() and checks whether the resulting triangle's BoundaryTriangleSet#NormalVector points 3245 * towards or away from the given \a &Point. 3366 * towards or away from the given \a &Point. Additionally, we check whether it's normal to the normal vector, i.e. on the 3367 * closest triangle's plane. Then, we have to check whether \a Point is inside the triangle or not to determine whether it's 3368 * an inside or outside point. This is done by calling BoundaryTriangleSet::GetIntersectionInsideTriangle(). 3369 * In the end we additionally find the point on the triangle who was smallest distance to \a Point: 3370 * -# Separate distance from point to center in vector in NormalDirection and on the triangle plane. 3371 * -# Check whether vector on triangle plane points inside the triangle or crosses triangle bounds. 3372 * -# If inside, take it to calculate closest distance 3373 * -# If not, take intersection with BoundaryLine as distance 3374 * 3375 * @note distance is squared despite it still contains a sign to determine in-/outside! 3246 3376 * 3247 3377 * @param point of which to check the position 3248 3378 * @param *LC LinkedCell structure 3249 3379 * 3250 * @return true if the point is inside the tesselation structure, false otherwise3251 */ 3252 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const3380 * @return >0 if outside, ==0 if on surface, <0 if inside (Note that distance can be at most LinkedCell::RADIUS.) 3381 */ 3382 double Tesselation::GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const 3253 3383 { 3254 3384 Info FunctionInfo(__func__); … … 3258 3388 Vector DistanceToCenter; 3259 3389 Vector Intersection; 3390 double distance = 0.; 3260 3391 3261 3392 if (result == NULL) {// is boundary point or only point in point cloud? 3262 3393 Log() << Verbose(1) << Point << " is the only point in vicinity." << endl; 3263 return false;3394 return LC->RADIUS; 3264 3395 } else { 3265 3396 Log() << Verbose(1) << "INFO: Closest triangle found is " << *result << " with normal vector " << result->NormalVector << "." << endl; … … 3282 3413 if (result->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) { 3283 3414 Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl; 3284 return true;3415 return 0.; 3285 3416 } else { 3286 3417 Log() << Verbose(1) << Point << " is NOT an inner point: on triangle plane but outside of triangle bounds." << endl; 3287 3418 return false; 3288 3419 } 3289 }3290 3291 // then check direction to boundary3292 if (DistanceToCenter.ScalarProduct(&result->NormalVector) > MYEPSILON) {3293 Log() << Verbose(1) << Point << " is an inner point." << endl;3294 return true;3295 3420 } else { 3296 Log() << Verbose(1) << Point << " is NOT an inner point." << endl; 3297 return false; 3298 } 3299 } 3421 // calculate smallest distance 3422 distance = result->GetClosestPointInsideTriangle(&Point, &Intersection); 3423 Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl; 3424 distance = Min(distance, (LC->RADIUS*LC->RADIUS)); 3425 3426 // then check direction to boundary 3427 if (DistanceToCenter.ScalarProduct(&result->NormalVector) > MYEPSILON) { 3428 Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl; 3429 return -distance; 3430 } else { 3431 Log() << Verbose(1) << Point << " is NOT an inner point, " << distance << " above surface." << endl; 3432 return +distance; 3433 } 3434 } 3435 }; 3300 3436 3301 3437 /** Gets all points connected to the provided point by triangulation lines. -
src/tesselation.hpp
r76102e r124e14 106 106 public: 107 107 BoundaryPointSet(); 108 BoundaryPointSet(TesselPoint * Walker);108 BoundaryPointSet(TesselPoint * const Walker); 109 109 ~BoundaryPointSet(); 110 110 111 void AddLine( class BoundaryLineSet *line);111 void AddLine(BoundaryLineSet * const line); 112 112 113 113 LineMap lines; … … 125 125 public: 126 126 BoundaryLineSet(); 127 BoundaryLineSet(class BoundaryPointSet *Point[2], const int number); 127 BoundaryLineSet(BoundaryPointSet * const Point[2], const int number); 128 BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number); 128 129 ~BoundaryLineSet(); 129 130 130 void AddTriangle( class BoundaryTriangleSet *triangle);131 bool IsConnectedTo(c lass BoundaryLineSet *line);132 bool ContainsBoundaryPoint(c lass BoundaryPointSet *point);133 bool CheckConvexityCriterion() ;134 class BoundaryPointSet *GetOtherEndpoint(c lass BoundaryPointSet *);131 void AddTriangle(BoundaryTriangleSet * const triangle); 132 bool IsConnectedTo(const BoundaryLineSet * const line) const; 133 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const; 134 bool CheckConvexityCriterion() const; 135 class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const; 135 136 136 137 class BoundaryPointSet *endpoints[2]; … … 147 148 public: 148 149 BoundaryTriangleSet(); 149 BoundaryTriangleSet(class BoundaryLineSet * line[3],int number);150 BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number); 150 151 ~BoundaryTriangleSet(); 151 152 152 void GetNormalVector(Vector &NormalVector); 153 void GetCenter(Vector *center); 154 bool GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection); 155 bool ContainsBoundaryLine(class BoundaryLineSet *line); 156 bool ContainsBoundaryPoint(class BoundaryPointSet *point); 157 bool ContainsBoundaryPoint(class TesselPoint *point); 158 class BoundaryPointSet *GetThirdEndpoint(class BoundaryLineSet *line); 159 bool IsPresentTupel(class BoundaryPointSet *Points[3]); 160 bool IsPresentTupel(class BoundaryTriangleSet *T); 153 void GetNormalVector(const Vector &NormalVector); 154 void GetCenter(Vector * const center) const; 155 bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const; 156 double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const; 157 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const; 158 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const; 159 bool ContainsBoundaryPoint(const TesselPoint * const point) const; 160 class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const; 161 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const; 162 bool IsPresentTupel(const BoundaryTriangleSet * const T) const; 161 163 162 164 class BoundaryPointSet *endpoints[3]; … … 313 315 class BoundaryTriangleSet * FindClosestTriangleToPoint(const Vector *x, const LinkedCell* LC) const; 314 316 bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const; 317 double GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const; 315 318 bool AddBoundaryPoint(TesselPoint * Walker, const int n); 316 319 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const; -
src/unittests/Makefile.am
r76102e r124e14 22 22 StackClassUnitTest \ 23 23 TesselationUnitTest \ 24 TesselationInOutsideUnitTest \ 24 Tesselation_BoundaryTriangleUnitTest \ 25 Tesselation_InOutsideUnitTest \ 25 26 VectorUnitTest 26 27 … … 79 80 TesselationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 80 81 81 TesselationInOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp 82 TesselationInOutsideUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 82 Tesselation_BoundaryTriangleUnitTest_SOURCES = tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp 83 Tesselation_BoundaryTriangleUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 84 85 Tesselation_InOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp 86 Tesselation_InOutsideUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 83 87 84 88 VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp -
src/vector.cpp
r76102e r124e14 222 222 * \param *Origin first vector of line 223 223 * \param *LineVector second vector of line 224 * \return true - \a this contains intersection point on return, false - line is parallel to plane 224 * \return true - \a this contains intersection point on return, false - line is parallel to plane (even if in-plane) 225 225 */ 226 226 bool Vector::GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector) … … 235 235 Direction.Normalize(); 236 236 Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl; 237 //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl; 237 238 factor = Direction.ScalarProduct(PlaneNormal); 238 if (fa ctor< MYEPSILON) { // Uniqueness: line parallel to plane?239 eLog() << Verbose(2) << "Line is parallel to plane, no intersection." << endl;239 if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane? 240 Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl; 240 241 return false; 241 242 } … … 243 244 helper.SubtractVector(Origin); 244 245 factor = helper.ScalarProduct(PlaneNormal)/factor; 245 if (fa ctor< MYEPSILON) { // Origin is in-plane246 Log() << Verbose(1) << " Origin of line is in-plane, simple." << endl;246 if (fabs(factor) < MYEPSILON) { // Origin is in-plane 247 Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl; 247 248 CopyVector(Origin); 248 249 return true; … … 258 259 helper.SubtractVector(PlaneOffset); 259 260 if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) { 260 Log() << Verbose(1) << " INFO: Intersection at " << *this << " is good." << endl;261 Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl; 261 262 return true; 262 263 } else { … … 353 354 Vector parallel; 354 355 double factor = 0.; 355 double pfactor = 0.;356 356 if (fabs(a.ScalarProduct(&b)*a.ScalarProduct(&b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) { 357 357 parallel.CopyVector(Line1a);
Note:
See TracChangeset
for help on using the changeset viewer.