Changeset 9473f6


Ignore:
Timestamp:
Jan 14, 2010, 5:36:09 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
e9c677
Parents:
7b36fe
Message:

FillBoxWithMolecule now allows boundary between filler molecules and the surface.

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r7b36fe r9473f6  
    789789 * \param configuration contains box dimensions
    790790 * \param distance[NDIM] distance between filling molecules in each direction
     791 * \param boundary length of boundary zone between molecule and filling mollecules
    791792 * \param epsilon distance to surface which is not filled
    792793 * \param RandAtomDisplacement maximum distance for random displacement per atom
     
    795796 * \return *mol pointer to new molecule with filled atoms
    796797 */
    797 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
     798molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
    798799{
    799800        Info FunctionInfo(__func__);
     
    856857            FillIt = false;
    857858          } else {
    858             const bool FillResult = (!TesselStruct[i]->IsInnerPoint(CurrentPosition, LCList[i]));
    859             FillIt = FillIt && FillResult;
    860             if (FillResult) {
     859            const double distance = (TesselStruct[i]->GetDistanceSquaredToSurface(CurrentPosition, LCList[i]));
     860            FillIt = FillIt && (distance > boundary*boundary);
     861            if (FillIt) {
    861862              Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is outer point." << endl;
    862863            } 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;
    864866            }
    865867            i++;
  • src/boundary.hpp

    r7b36fe r9473f6  
    4949
    5050double 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);
     51molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);
    5252void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
    5353Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol);
  • src/builder.cpp

    r7b36fe r9473f6  
    17381738              if (argptr+6 >=argc) {
    17391739                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;
    17411741                performCriticalExit();
    17421742              } else {
     
    17691769                for (int i=0;i<NDIM;i++)
    17701770                  distance[i] = atof(argv[argptr+i]);
    1771                 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atoi(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]));
    17721772                if (Filling != NULL) {
    17731773                  Filling->ActiveFlag = false;
  • src/tesselation.cpp

    r7b36fe r9473f6  
    3535 * \param *Walker TesselPoint this boundary point represents
    3636 */
    37 BoundaryPointSet::BoundaryPointSet(TesselPoint * Walker) :
     37BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) :
    3838  LinesCount(0),
    3939  node(Walker),
     
    6161 * \param *line line to add
    6262 */
    63 void BoundaryPointSet::AddLine(class BoundaryLineSet *line)
     63void BoundaryPointSet::AddLine(BoundaryLineSet * const line)
    6464{
    6565        Info FunctionInfo(__func__);
     
    105105 * \param number number of the list
    106106 */
    107 BoundaryLineSet::BoundaryLineSet(class BoundaryPointSet *Point[2], const int number)
     107BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number)
    108108{
    109109        Info FunctionInfo(__func__);
     
    115115  Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
    116116  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 */
     129BoundaryLineSet::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); //
    117139  // set skipped to false
    118140  skipped = false;
     
    171193 * \param *triangle to add
    172194 */
    173 void BoundaryLineSet::AddTriangle(class BoundaryTriangleSet *triangle)
     195void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle)
    174196{
    175197        Info FunctionInfo(__func__);
     
    182204 * \return true - common endpoint present, false - not connected
    183205 */
    184 bool BoundaryLineSet::IsConnectedTo(class BoundaryLineSet *line)
     206bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const
    185207{
    186208        Info FunctionInfo(__func__);
     
    197219 * \return true - triangles are convex, false - concave or less than two triangles connected
    198220 */
    199 bool BoundaryLineSet::CheckConvexityCriterion()
     221bool BoundaryLineSet::CheckConvexityCriterion() const
    200222{
    201223        Info FunctionInfo(__func__);
     
    221243  int i=0;
    222244  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++) {
    224246    //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
    225247    NormalCheck.AddVector(&runner->second->NormalVector);
     
    264286 * \return true - point is of the line, false - is not
    265287 */
    266 bool BoundaryLineSet::ContainsBoundaryPoint(class BoundaryPointSet *point)
     288bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
    267289{
    268290        Info FunctionInfo(__func__);
     
    277299 * \return NULL - if endpoint not contained in BoundaryLineSet, or pointer to BoundaryPointSet otherwise
    278300 */
    279 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(class BoundaryPointSet *point)
     301class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
    280302{
    281303        Info FunctionInfo(__func__);
     
    317339 * \param number number of triangle
    318340 */
    319 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet *line[3], int number) :
     341BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) :
    320342  Nr(number)
    321343{
     
    376398 * \param &OtherVector direction vector to make normal vector unique.
    377399 */
    378 void BoundaryTriangleSet::GetNormalVector(Vector &OtherVector)
     400void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector)
    379401{
    380402        Info FunctionInfo(__func__);
     
    390412/** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
    391413 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane
    392  * This 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.
    393415 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
    394416 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between
     
    400422 * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle.
    401423 */
    402 bool BoundaryTriangleSet::GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection)
     424bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const
    403425{
    404426  Info FunctionInfo(__func__);
     
    452474};
    453475
     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 */
     486double 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
    454560/** Checks whether lines is any of the three boundary lines this triangle contains.
    455561 * \param *line line to test
    456562 * \return true - line is of the triangle, false - is not
    457563 */
    458 bool BoundaryTriangleSet::ContainsBoundaryLine(class BoundaryLineSet *line)
     564bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
    459565{
    460566        Info FunctionInfo(__func__);
     
    469575 * \return true - point is of the triangle, false - is not
    470576 */
    471 bool BoundaryTriangleSet::ContainsBoundaryPoint(class BoundaryPointSet *point)
     577bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
    472578{
    473579        Info FunctionInfo(__func__);
     
    482588 * \return true - point is of the triangle, false - is not
    483589 */
    484 bool BoundaryTriangleSet::ContainsBoundaryPoint(class TesselPoint *point)
     590bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const
    485591{
    486592        Info FunctionInfo(__func__);
     
    495601 * \return true - is the very triangle, false - is not
    496602 */
    497 bool BoundaryTriangleSet::IsPresentTupel(class BoundaryPointSet *Points[3])
     603bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const
    498604{
    499605        Info FunctionInfo(__func__);
     
    518624 * \return true - is the very triangle, false - is not
    519625 */
    520 bool BoundaryTriangleSet::IsPresentTupel(class BoundaryTriangleSet *T)
     626bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const
    521627{
    522628        Info FunctionInfo(__func__);
     
    540646 * \return pointer third endpoint or NULL if line does not belong to triangle.
    541647 */
    542 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(class BoundaryLineSet *line)
     648class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const
    543649{
    544650        Info FunctionInfo(__func__);
     
    557663 * \param *center central point on return.
    558664 */
    559 void BoundaryTriangleSet::GetCenter(Vector *center)
     665void BoundaryTriangleSet::GetCenter(Vector * const center) const
    560666{
    561667        Info FunctionInfo(__func__);
     
    564670    center->AddVector(endpoints[i]->node->node);
    565671  center->Scale(1./3.);
     672  Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl;
    566673}
    567674
     
    32433350};
    32443351
    3245 /** 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 */
     3359bool 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.
    32463365 * Calls FindClosestTriangleToVector() and checks whether the resulting triangle's BoundaryTriangleSet#NormalVector points
    3247  * 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!
    32483376 *
    32493377 * @param point of which to check the position
    32503378 * @param *LC LinkedCell structure
    32513379 *
    3252  * @return true if the point is inside the tesselation structure, false otherwise
    3253  */
    3254 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const
     3380 * @return >0 if outside, ==0 if on surface, <0 if inside (Note that distance can be at most LinkedCell::RADIUS.)
     3381 */
     3382double Tesselation::GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const
    32553383{
    32563384  Info FunctionInfo(__func__);
     
    32603388  Vector DistanceToCenter;
    32613389  Vector Intersection;
     3390  double distance = 0.;
    32623391
    32633392  if (result == NULL) {// is boundary point or only point in point cloud?
    32643393    Log() << Verbose(1) << Point << " is the only point in vicinity." << endl;
    3265     return false;
     3394    return LC->RADIUS;
    32663395  } else {
    32673396    Log() << Verbose(1) << "INFO: Closest triangle found is " << *result << " with normal vector " << result->NormalVector << "." << endl;
     
    32843413    if (result->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) {
    32853414      Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl;
    3286       return true;
     3415      return 0.;
    32873416    } else {
    32883417      Log() << Verbose(1) << Point << " is NOT an inner point: on triangle plane but outside of triangle bounds." << endl;
    32893418      return false;
    32903419    }
    3291   }
    3292 
    3293   // then check direction to boundary
    3294   if (DistanceToCenter.ScalarProduct(&result->NormalVector) > MYEPSILON) {
    3295     Log() << Verbose(1) << Point << " is an inner point." << endl;
    3296     return true;
    32973420  } else {
    3298     Log() << Verbose(1) << Point << " is NOT an inner point." << endl;
    3299     return false;
    3300   }
    3301 }
     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};
    33023436
    33033437/** Gets all points connected to the provided point by triangulation lines.
  • src/tesselation.hpp

    r7b36fe r9473f6  
    106106  public:
    107107    BoundaryPointSet();
    108     BoundaryPointSet(TesselPoint * Walker);
     108    BoundaryPointSet(TesselPoint * const Walker);
    109109    ~BoundaryPointSet();
    110110
    111     void AddLine(class BoundaryLineSet *line);
     111    void AddLine(BoundaryLineSet * const line);
    112112
    113113    LineMap lines;
     
    125125  public:
    126126    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);
    128129    ~BoundaryLineSet();
    129130
    130     void AddTriangle(class BoundaryTriangleSet *triangle);
    131     bool IsConnectedTo(class BoundaryLineSet *line);
    132     bool ContainsBoundaryPoint(class BoundaryPointSet *point);
    133     bool CheckConvexityCriterion();
    134     class BoundaryPointSet *GetOtherEndpoint(class 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;
    135136
    136137    class BoundaryPointSet *endpoints[2];
     
    147148  public:
    148149    BoundaryTriangleSet();
    149     BoundaryTriangleSet(class BoundaryLineSet *line[3], int number);
     150    BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);
    150151    ~BoundaryTriangleSet();
    151152
    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;
    161163
    162164    class BoundaryPointSet *endpoints[3];
     
    313315    class BoundaryTriangleSet * FindClosestTriangleToPoint(const Vector *x, const LinkedCell* LC) const;
    314316    bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
     317    double GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const;
    315318    bool AddBoundaryPoint(TesselPoint * Walker, const int n);
    316319    DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;
Note: See TracChangeset for help on using the changeset viewer.