Ignore:
Timestamp:
Jan 26, 2010, 12:52:31 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
8d0b25, d34341
Parents:
551a58
Message:

GetDistanceToSurface() separated, filling now with water instead of boron, DissectMoleculeIntoConnectedSubgraphs() now working on list of molecules instead of single one.

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/tesselation.cpp

    r551a58 r478683  
    939939TesselPoint::TesselPoint()
    940940{
    941   Info FunctionInfo(__func__);
     941  //Info FunctionInfo(__func__);
    942942  node = NULL;
    943943  nr = -1;
     
    949949TesselPoint::~TesselPoint()
    950950{
    951   Info FunctionInfo(__func__);
     951  //Info FunctionInfo(__func__);
    952952};
    953953
     
    976976PointCloud::PointCloud()
    977977{
    978         Info FunctionInfo(__func__);
     978        //Info FunctionInfo(__func__);
    979979};
    980980
     
    983983PointCloud::~PointCloud()
    984984{
    985         Info FunctionInfo(__func__);
     985        //Info FunctionInfo(__func__);
    986986};
    987987
     
    11741174 * \param PointsOnBoundary set of boundary points defining the convex envelope of the cluster
    11751175 */
    1176 void
    1177 Tesselation::GuessStartingTriangle()
     1176void Tesselation::GuessStartingTriangle()
    11781177{
    11791178        Info FunctionInfo(__func__);
     
    33783377 * @param *LC LinkedCell structure
    33793378 *
    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::GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const
     3379 * @return >0 if outside, ==0 if on surface, <0 if inside
     3380 */
     3381double Tesselation::GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const
    33833382{
    33843383  Info FunctionInfo(__func__);
    3385   class BoundaryTriangleSet *result = FindClosestTriangleToVector(&Point, LC);
    33863384  Vector Center;
    33873385  Vector helper;
     
    33903388  double distance = 0.;
    33913389
    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.;
    33953393  } 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);
    34003398  Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl;
    34013399  DistanceToCenter.CopyVector(&Center);
     
    34043402
    34053403  // check whether we are on boundary
    3406   if (fabs(DistanceToCenter.ScalarProduct(&result->NormalVector)) < MYEPSILON) {
     3404  if (fabs(DistanceToCenter.ScalarProduct(&triangle->NormalVector)) < MYEPSILON) {
    34073405    // calculate whether inside of triangle
    34083406    DistanceToCenter.CopyVector(&Point);
    34093407    Center.CopyVector(&Point);
    3410     Center.SubtractVector(&result->NormalVector); // points towards MolCenter
    3411     DistanceToCenter.AddVector(&result->NormalVector); // points outside
     3408    Center.SubtractVector(&triangle->NormalVector); // points towards MolCenter
     3409    DistanceToCenter.AddVector(&triangle->NormalVector); // points outside
    34123410    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)) {
    34143412      Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl;
    34153413      return 0.;
     
    34203418  } else {
    34213419    // calculate smallest distance
    3422     distance = result->GetClosestPointInsideTriangle(&Point, &Intersection);
     3420    distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection);
    34233421    Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl;
    3424     distance = Min(distance, (LC->RADIUS*LC->RADIUS));
    34253422
    34263423    // then check direction to boundary
    3427     if (DistanceToCenter.ScalarProduct(&result->NormalVector) > MYEPSILON) {
     3424    if (DistanceToCenter.ScalarProduct(&triangle->NormalVector) > MYEPSILON) {
    34283425      Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl;
    34293426      return -distance;
     
    34333430    }
    34343431  }
     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 */
     3440double 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);
    34353445};
    34363446
     
    36953705 * @return list of the all points linked to the provided one
    36963706 */
    3697 list< TesselPointList *> * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const
     3707ListOfTesselPointList * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const
    36983708{
    36993709        Info FunctionInfo(__func__);
     
    38113821 * @return list of the closed paths
    38123822 */
    3813 list<TesselPointList *> * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const
     3823ListOfTesselPointList * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const
    38143824{
    38153825        Info FunctionInfo(__func__);
Note: See TracChangeset for help on using the changeset viewer.