Changeset 478683 for molecuilder/src/tesselation.cpp
- Timestamp:
- Jan 26, 2010, 12:52:31 PM (16 years ago)
- Children:
- 8d0b25, d34341
- Parents:
- 551a58
- File:
-
- 1 edited
-
molecuilder/src/tesselation.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/tesselation.cpp
r551a58 r478683 939 939 TesselPoint::TesselPoint() 940 940 { 941 Info FunctionInfo(__func__);941 //Info FunctionInfo(__func__); 942 942 node = NULL; 943 943 nr = -1; … … 949 949 TesselPoint::~TesselPoint() 950 950 { 951 Info FunctionInfo(__func__);951 //Info FunctionInfo(__func__); 952 952 }; 953 953 … … 976 976 PointCloud::PointCloud() 977 977 { 978 Info FunctionInfo(__func__);978 //Info FunctionInfo(__func__); 979 979 }; 980 980 … … 983 983 PointCloud::~PointCloud() 984 984 { 985 Info FunctionInfo(__func__);985 //Info FunctionInfo(__func__); 986 986 }; 987 987 … … 1174 1174 * \param PointsOnBoundary set of boundary points defining the convex envelope of the cluster 1175 1175 */ 1176 void 1177 Tesselation::GuessStartingTriangle() 1176 void Tesselation::GuessStartingTriangle() 1178 1177 { 1179 1178 Info FunctionInfo(__func__); … … 3378 3377 * @param *LC LinkedCell structure 3379 3378 * 3380 * @return >0 if outside, ==0 if on surface, <0 if inside (Note that distance can be at most LinkedCell::RADIUS.)3381 */ 3382 double Tesselation::GetDistanceSquaredTo Surface(const Vector &Point, const LinkedCell* const LC) const3379 * @return >0 if outside, ==0 if on surface, <0 if inside 3380 */ 3381 double Tesselation::GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const 3383 3382 { 3384 3383 Info FunctionInfo(__func__); 3385 class BoundaryTriangleSet *result = FindClosestTriangleToVector(&Point, LC);3386 3384 Vector Center; 3387 3385 Vector helper; … … 3390 3388 double distance = 0.; 3391 3389 3392 if ( result== NULL) {// is boundary point or only point in point cloud?3393 Log() << Verbose(1) << Point << " is the only point in vicinity." << endl;3394 return LC->RADIUS;3390 if (triangle == NULL) {// is boundary point or only point in point cloud? 3391 Log() << Verbose(1) << "No triangle given!" << endl; 3392 return -1.; 3395 3393 } else { 3396 Log() << Verbose(1) << "INFO: Closest triangle found is " << * result << " with normal vector " << result->NormalVector << "." << endl;3397 } 3398 3399 result->GetCenter(&Center);3394 Log() << Verbose(1) << "INFO: Closest triangle found is " << *triangle << " with normal vector " << triangle->NormalVector << "." << endl; 3395 } 3396 3397 triangle->GetCenter(&Center); 3400 3398 Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl; 3401 3399 DistanceToCenter.CopyVector(&Center); … … 3404 3402 3405 3403 // check whether we are on boundary 3406 if (fabs(DistanceToCenter.ScalarProduct(& result->NormalVector)) < MYEPSILON) {3404 if (fabs(DistanceToCenter.ScalarProduct(&triangle->NormalVector)) < MYEPSILON) { 3407 3405 // calculate whether inside of triangle 3408 3406 DistanceToCenter.CopyVector(&Point); 3409 3407 Center.CopyVector(&Point); 3410 Center.SubtractVector(& result->NormalVector); // points towards MolCenter3411 DistanceToCenter.AddVector(& result->NormalVector); // points outside3408 Center.SubtractVector(&triangle->NormalVector); // points towards MolCenter 3409 DistanceToCenter.AddVector(&triangle->NormalVector); // points outside 3412 3410 Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl; 3413 if ( result->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) {3411 if (triangle->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) { 3414 3412 Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl; 3415 3413 return 0.; … … 3420 3418 } else { 3421 3419 // calculate smallest distance 3422 distance = result->GetClosestPointInsideTriangle(&Point, &Intersection);3420 distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection); 3423 3421 Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl; 3424 distance = Min(distance, (LC->RADIUS*LC->RADIUS));3425 3422 3426 3423 // then check direction to boundary 3427 if (DistanceToCenter.ScalarProduct(& result->NormalVector) > MYEPSILON) {3424 if (DistanceToCenter.ScalarProduct(&triangle->NormalVector) > MYEPSILON) { 3428 3425 Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl; 3429 3426 return -distance; … … 3433 3430 } 3434 3431 } 3432 }; 3433 3434 /** Calculates distance to a tesselated surface. 3435 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle(). 3436 * \param &Point point to calculate distance from 3437 * \param *LC needed for finding closest points fast 3438 * \return distance squared to closest point on surface 3439 */ 3440 double Tesselation::GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const 3441 { 3442 BoundaryTriangleSet *triangle = FindClosestTriangleToVector(&Point, LC); 3443 const double distance = GetDistanceSquaredToTriangle(Point, triangle); 3444 return Min(distance, LC->RADIUS); 3435 3445 }; 3436 3446 … … 3695 3705 * @return list of the all points linked to the provided one 3696 3706 */ 3697 list< TesselPointList *>* Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const3707 ListOfTesselPointList * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const 3698 3708 { 3699 3709 Info FunctionInfo(__func__); … … 3811 3821 * @return list of the closed paths 3812 3822 */ 3813 list<TesselPointList *>* Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const3823 ListOfTesselPointList * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const 3814 3824 { 3815 3825 Info FunctionInfo(__func__);
Note:
See TracChangeset
for help on using the changeset viewer.
