Ignore:
Timestamp:
Mar 1, 2010, 10:10:13 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
e49719
Parents:
075d08
git-author:
Frederik Heber <heber@…> (03/01/10 20:48:40)
git-committer:
Frederik Heber <heber@…> (03/01/10 22:10:13)
Message:

New class TriangleIntersection List and (hopefully) final fix of CorrelationToSurface().

  • Distances to surface were still calculated between the vector and the triangle plane not the triangle itself. Although functions such as BoundaryTriangleSet::GetClosestPointInsideTriangle had already been written.
  • As in class Tesselation there were many functions that all did the same: Calculate intersections between a point and all closeby triangles and then get the intersection or calculate this minimum distance and so ...
  • ... this was all put into a new class (in a new file): TriangleIntersectionList whose constructor scans all nearby triangles and put the calculates Intersections in the triangle into a list.
  • Functions as IsInside(), GetSmallestDistance(), GetClosestIntersection() and GetClosestTriangle() bring the desired functionality to the outside.
  • Respective functions in class Tesselation just make use of this new class and its member functions.
  • CorrelationToSurface() also directly instantiates this class to effectively use two of its functions.
  • Makefile.am has this new file in its SOURCES and HEADERS.
  • Tesselation:GetDistanceSquaredToSurface() -> Tesselation:GetDistanceToSurface(), FillBoxWithMolecule() has been adapted to this change.

AnalysisCorrelationToSurfaceUnitTest:

  • still has errors in it, as the distance were wrong before (because with respect to triangle plane, not triangle). Hence, the test was corrected.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/analysis_correlation.cpp

    r075d08 rf7b476  
    1515#include "tesselation.hpp"
    1616#include "tesselationhelpers.hpp"
     17#include "triangleintersectionlist.hpp"
    1718#include "vector.hpp"
    1819#include "verbose.hpp"
     
    255256
    256257  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
    257     Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
     258    eLog() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
    258259    return outmap;
    259260  }
     
    261262  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    262263    if ((*MolWalker)->ActiveFlag) {
    263       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    264       atom *Walker = (*MolWalker)->start;
    265       while (Walker->next != (*MolWalker)->end) {
    266         Walker = Walker->next;
    267         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     264      Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl;
     265      atom *Walker = (*MolWalker)->start;
     266      while (Walker->next != (*MolWalker)->end) {
     267        Walker = Walker->next;
     268        //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl;
    268269        if ((type == NULL) || (Walker->type == type)) {
    269           triangle = Surface->FindClosestTriangleToVector(Walker->node, LC );
    270           if (triangle != NULL) {
    271             distance = DistanceToTrianglePlane(Walker->node, triangle);
    272             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
    273           }
    274         }
    275       }
    276     }
     270          TriangleIntersectionList Intersections(Walker->node,Surface,LC);
     271          distance = Intersections.GetSmallestDistance();
     272          triangle = Intersections.GetClosestTriangle();
     273          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     274        }
     275      }
     276    } else
     277      Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl;
     278
    277279
    278280  return outmap;
     
    413415  Info FunctionInfo(__func__);
    414416  *file << "BinStart\tTriangle" << endl;
    415   for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    416     *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
    417   }
    418 };
    419 
     417  if (!map->empty())
     418    for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
     419      *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
     420    }
     421};
     422
Note: See TracChangeset for help on using the changeset viewer.