Changeset a7c344 for src/tesselation.cpp


Ignore:
Timestamp:
Jun 19, 2010, 4:06:59 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:
c39cc4
Parents:
b32dbb (diff), 27ac00 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'StructureRefactoring' of jupiter:espack into StructureRefactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    rb32dbb ra7c344  
    1717#include "triangleintersectionlist.hpp"
    1818#include "vector.hpp"
     19#include "Line.hpp"
    1920#include "vector_ops.hpp"
    2021#include "verbose.hpp"
     
    469470
    470471  try {
    471     *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(*MolCenter, *x);
    472   }
    473   catch (LinearDependenceException &excp) {
    474     Log() << Verbose(1) << excp;
    475     DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl);
    476     return false;
    477   }
    478 
    479   DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl);
    480   DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl);
    481   DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl);
    482 
    483   if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) {
    484     DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl);
    485     return true;
    486   }   else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) {
    487     DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl);
    488     return true;
    489   }   else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) {
    490     DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl);
    491     return true;
    492   }
    493   // Calculate cross point between one baseline and the line from the third endpoint to intersection
    494   int i = 0;
    495   do {
    496     try {
    497       CrossPoint = GetIntersectionOfTwoLinesOnPlane(*(endpoints[i%3]->node->node),
    498                                                     *(endpoints[(i+1)%3]->node->node),
    499                                                     *(endpoints[(i+2)%3]->node->node),
    500                                                     *Intersection);
     472    Line centerLine = makeLineThrough(*MolCenter, *x);
     473    *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(centerLine);
     474
     475    DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl);
     476    DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl);
     477    DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl);
     478
     479    if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) {
     480      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl);
     481      return true;
     482    }   else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) {
     483      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl);
     484      return true;
     485    }   else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) {
     486      DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl);
     487      return true;
     488    }
     489    // Calculate cross point between one baseline and the line from the third endpoint to intersection
     490    int i = 0;
     491    do {
     492      Line line1 = makeLineThrough(*(endpoints[i%3]->node->node),*(endpoints[(i+1)%3]->node->node));
     493      Line line2 = makeLineThrough(*(endpoints[(i+2)%3]->node->node),*Intersection);
     494      CrossPoint = line1.getIntersection(line2);
    501495      helper = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);
    502496      CrossPoint -= (*endpoints[i%3]->node->node);  // cross point was returned as absolute vector
     
    505499      if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
    506500        DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl);
    507         i=4;
    508         break;
     501        return false;
    509502      }
    510503      i++;
    511     } catch (LinearDependenceException &excp){
    512       break;
    513     }
    514   } while (i < 3);
    515   if (i == 3) {
     504    } while (i < 3);
    516505    DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl);
    517506    return true;
    518   } else {
    519     DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl);
     507  }
     508  catch (MathException &excp) {
     509    Log() << Verbose(1) << excp;
     510    DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl);
    520511    return false;
    521512  }
     
    544535  GetCenter(&Direction);
    545536  try {
    546     *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(*x, Direction);
    547   }
    548   catch (LinearDependenceException &excp) {
     537    Line l = makeLineThrough(*x, Direction);
     538    *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(l);
     539  }
     540  catch (MathException &excp) {
    549541    (*ClosestPoint) = (*x);
    550542  }
     
    569561    Direction = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);
    570562    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
    571     CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node));
     563    Line l = makeLineThrough(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node));
     564    CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l);
    572565    CrossDirection[i] = CrossPoint[i] - InPlane;
    573566    CrossPoint[i] -= (*endpoints[i%3]->node->node);  // cross point was returned as absolute vector
     
    740733}
    741734
     735Vector BoundaryTriangleSet::getEndpoint(int i) const{
     736  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
     737
     738  return *endpoints[i]->node->node;
     739}
     740
     741string BoundaryTriangleSet::getEndpointName(int i) const{
     742  ASSERT(i>=0 && i<3,"Index of Endpoint out of Range");
     743
     744  return endpoints[i]->node->getName();
     745}
     746
    742747/** output operator for BoundaryTriangleSet.
    743748 * \param &ost output stream
     
    746751ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)
    747752{
    748   ost << "[" << a.Nr << "|" << a.endpoints[0]->node->getName() << "," << a.endpoints[1]->node->getName() << "," << a.endpoints[2]->node->getName() << "]";
     753  ost << "[" << a.Nr << "|" << a.getEndpointName(0) << "," << a.getEndpointName(1) << "," << a.getEndpointName(2) << "]";
    749754  //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
    750755  //      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
     
    15141519        CenterVector.Zero();
    15151520        for (int i = 0; i < 3; i++)
    1516           CenterVector += (*BTS->endpoints[i]->node->node);
     1521          CenterVector += BTS->getEndpoint(i);
    15171522        CenterVector.Scale(1. / 3.);
    15181523        DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl);
     
    48684873  if (LastTriangle != NULL) {
    48694874    stringstream sstr;
    4870     sstr << "-"<< TrianglesOnBoundary.size() << "-" << LastTriangle->endpoints[0]->node->getName() << "_" << LastTriangle->endpoints[1]->node->getName() << "_" << LastTriangle->endpoints[2]->node->getName();
     4875    sstr << "-"<< TrianglesOnBoundary.size() << "-" << LastTriangle->getEndpointName(0) << "_" << LastTriangle->getEndpointName(1) << "_" << LastTriangle->getEndpointName(2);
    48714876    NumberName = sstr.str();
    48724877    if (DoTecplotOutput) {
Note: See TracChangeset for help on using the changeset viewer.