Changeset d33bb8


Ignore:
Timestamp:
Oct 19, 2014, 5:13:10 PM (11 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:
32d7e4
Parents:
f1ae15
git-author:
Frederik Heber <heber@…> (10/14/14 16:37:03)
git-committer:
Frederik Heber <heber@…> (10/19/14 17:13:10)
Message:

Added Tesselation::IsPointBelowSurroundingPolygon().

Location:
src/Tesselation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Tesselation/tesselation.cpp

    rf1ae15 rd33bb8  
    12341234    try {
    12351235      SearchDirection = Plane(CirclePlaneNormal, NormalVector, 0).getNormal(); // whether we look "left" first or "right" first is not important ...
    1236     } catch (LinearAlgebraException) {
     1236    } catch (LinearAlgebraException &e) {
    12371237      ELOG(1, "Vectors are linear dependent: " << CirclePlaneNormal << ", " << NormalVector << ".");
    12381238      delete BaseLine;
     
    31783178};
    31793179
     3180bool Tesselation::IsPointBelowSurroundingPolygon(const BoundaryPointSet *_point) const
     3181{
     3182  // check for NULL
     3183  if (_point == NULL) {
     3184    return false;
     3185  }
     3186
     3187  // get list of connected points
     3188  if (_point->lines.empty()) {
     3189    LOG(1, "INFO: point " << *_point << " is not connected to any lines.");
     3190    return false;
     3191  }
     3192  bool PointIsBelow = true;
     3193
     3194  // create Orthogonal vector as reference for angle (pointing into [pi,2pi) interval)
     3195  Vector OrthogonalVector;
     3196  for (LineMap::const_iterator lineiter = _point->lines.begin();
     3197      lineiter != _point->lines.end(); ++lineiter)
     3198    for (TriangleMap::const_iterator triangleiter = lineiter->second->triangles.begin();
     3199        triangleiter != lineiter->second->triangles.end();
     3200        ++triangleiter)
     3201        OrthogonalVector += triangleiter->second->NormalVector;
     3202  OrthogonalVector.Normalize();
     3203
     3204  // go through all closed paths for this point
     3205  typedef list<TesselPointList *> TPL_list_t;
     3206  const TPL_list_t *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(_point->node);
     3207  for (TPL_list_t::const_iterator closedpathsiter = ListOfClosedPaths->begin();
     3208      (closedpathsiter != ListOfClosedPaths->end()) && PointIsBelow;
     3209      ++closedpathsiter) {
     3210    const TesselPointList *connectedPath = *closedpathsiter;
     3211
     3212    TesselPointList::const_iterator ListAdvance = connectedPath->begin(); // gives angle direction
     3213    TesselPointList::const_iterator ListRunner = ListAdvance++;
     3214    for (; (ListAdvance != connectedPath->end()) && PointIsBelow;
     3215        ListRunner = ListAdvance++) { // go through all closed paths
     3216      LOG(2, "DEBUG: Current reference node is " << **ListRunner
     3217          << ", advanced node is " << **ListAdvance);
     3218
     3219      // reference vector to point to check for this point of connected path
     3220      const Vector Reference =
     3221          ((*ListAdvance)->getPosition()) - ((*ListRunner)->getPosition());
     3222
     3223      // go through all other points in this connected path
     3224      for (TesselPointList::const_iterator OtherRunner = ListAdvance;
     3225          (OtherRunner != ListRunner) && PointIsBelow;
     3226          ++OtherRunner == connectedPath->end() ?
     3227              OtherRunner = connectedPath->begin() :
     3228              OtherRunner) {
     3229        if (OtherRunner == ListAdvance)
     3230          continue;
     3231        LOG(3, "DEBUG: Current other node is " << **OtherRunner);
     3232
     3233        // build the plane with normal vector
     3234        const Vector onebeam =
     3235            ((*OtherRunner)->getPosition()) - ((*ListAdvance)->getPosition());
     3236        Vector NormalVector = Reference;
     3237        NormalVector.VectorProduct(onebeam);
     3238        // needs to point in same general direction as average NormalVector of all triangles
     3239        if (NormalVector.ScalarProduct(OrthogonalVector) < 0)
     3240          NormalVector *= -1.;
     3241        try {
     3242          Plane plane(NormalVector, ((*ListRunner)->getPosition()));
     3243
     3244          // check whether point is below
     3245          if (plane.SignedDistance(_point->node->getPosition()) > 0) {
     3246            LOG(2, "DEBUG: For plane " << plane << " point " << *_point
     3247                << " would remain above.");
     3248            PointIsBelow = false;
     3249          }
     3250        } catch (ZeroVectorException &e) {
     3251          ELOG(3, "Vectors are linear dependent, skipping.");
     3252        }
     3253      }
     3254    }
     3255  }
     3256  delete ListOfClosedPaths;
     3257
     3258  return PointIsBelow;
     3259}
     3260
    31803261/** Removes a boundary point from the envelope while keeping it closed.
    31813262 * We remove the old triangles connected to the point and re-create new triangles to close the surface following this ansatz:
  • src/Tesselation/tesselation.hpp

    rf1ae15 rd33bb8  
    132132    BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell_deprecated* LC) const;
    133133
     134    bool IsPointBelowSurroundingPolygon(const BoundaryPointSet *_point) const;
     135
    134136    // print for debugging
    135137    void PrintAllBoundaryPoints(ofstream *out) const;
Note: See TracChangeset for help on using the changeset viewer.