Changeset 34c43a for src/tesselation.cpp


Ignore:
Timestamp:
Mar 1, 2011, 10:16:38 AM (14 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:
caa06ef
Parents:
ba5215
git-author:
Frederik Heber <heber@…> (02/21/11 18:02:41)
git-committer:
Frederik Heber <heber@…> (03/01/11 10:16:38)
Message:

Bigger change: Replaced PointCloud by PointCloudAdaptor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    rba5215 r34c43a  
    2323#include <iomanip>
    2424
    25 #include "Helpers/helpers.hpp"
    26 #include "CodePatterns/Info.hpp"
    2725#include "BoundaryPointSet.hpp"
    2826#include "BoundaryLineSet.hpp"
    2927#include "BoundaryTriangleSet.hpp"
    3028#include "BoundaryPolygonSet.hpp"
    31 #include "TesselPoint.hpp"
    3229#include "CandidateForTesselation.hpp"
    33 #include "PointCloud.hpp"
    34 #include "linkedcell.hpp"
     30#include "CodePatterns/Assert.hpp"
     31#include "CodePatterns/Info.hpp"
     32#include "CodePatterns/IteratorAdaptors.hpp"
    3533#include "CodePatterns/Log.hpp"
    36 #include "tesselation.hpp"
    37 #include "tesselationhelpers.hpp"
    38 #include "triangleintersectionlist.hpp"
     34#include "CodePatterns/Verbose.hpp"
     35#include "Exceptions/LinearDependenceException.hpp"
     36#include "Helpers/fast_functions.hpp"
     37#include "Helpers/helpers.hpp"
     38#include "IPointCloud.hpp"
    3939#include "LinearAlgebra/Vector.hpp"
    4040#include "LinearAlgebra/Line.hpp"
    4141#include "LinearAlgebra/vector_ops.hpp"
    42 #include "CodePatterns/Verbose.hpp"
    4342#include "LinearAlgebra/Plane.hpp"
    44 #include "Exceptions/LinearDependenceException.hpp"
    45 #include "CodePatterns/Assert.hpp"
    46 
    47 #include "Helpers/fast_functions.hpp"
     43#include "linkedcell.hpp"
     44#include "PointCloudAdaptor.hpp"
     45#include "tesselation.hpp"
     46#include "tesselationhelpers.hpp"
     47#include "TesselPoint.hpp"
     48#include "triangleintersectionlist.hpp"
    4849
    4950class molecule;
     
    8687  DoLog(0) && (Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl);
    8788}
    88 ;
    89 
    90 TesselPoint * Tesselation::getValue(const_iterator &rhs) const
    91 {
    92   return (*rhs).second->node;
    93 }
    94 
    95 TesselPoint * Tesselation::getValue(iterator &rhs) const
    96 {
    97   return (*rhs).second->node;
    98 }
    99 
    100 const char * const Tesselation::GetName() const
    101 {
    102   return "unknown";
    103 }
    104 
    105 /** PointCloud implementation of GetCenter
    106  * Uses PointsOnBoundary and STL stuff.
    107  */
    108 Vector * Tesselation::GetCenter() const
    109 {
    110   Info FunctionInfo(__func__);
    111   Vector *Center = new Vector(0., 0., 0.);
    112   int num = 0;
    113   for (GoToFirst(); (!IsEnd()); GoToNext()) {
    114     (*Center) += (GetPoint()->getPosition());
    115     num++;
    116   }
    117   Center->Scale(1. / num);
    118   return Center;
    119 }
    120 ;
    121 
    122 /** PointCloud implementation of GoPoint
    123  * Uses PointsOnBoundary and STL stuff.
    124  */
    125 TesselPoint * Tesselation::GetPoint() const
    126 {
    127   Info FunctionInfo(__func__);
    128   return (InternalPointer->second->node);
    129 }
    130 ;
    131 
    132 int Tesselation::GetMaxId() const
    133 {
    134   int max_id = 0;
    135   for (PointMap::const_iterator iter = PointsOnBoundary.begin();
    136       iter != PointsOnBoundary.end();
    137       ++iter) {
    138     if ((iter->second)->node->nr > max_id)
    139       (iter->second)->node->nr = max_id;
    140   }
    141   return max_id;
    142 }
    143 
    144 /** PointCloud implementation of GoToNext.
    145  * Uses PointsOnBoundary and STL stuff.
    146  */
    147 void Tesselation::GoToNext() const
    148 {
    149   Info FunctionInfo(__func__);
    150   if (InternalPointer != PointsOnBoundary.end())
    151     InternalPointer++;
    152 }
    153 ;
    154 
    155 /** PointCloud implementation of GoToFirst.
    156  * Uses PointsOnBoundary and STL stuff.
    157  */
    158 void Tesselation::GoToFirst() const
    159 {
    160   Info FunctionInfo(__func__);
    161   InternalPointer = PointsOnBoundary.begin();
    162 }
    163 ;
    164 
    165 /** PointCloud implementation of IsEmpty.
    166  * Uses PointsOnBoundary and STL stuff.
    167  */
    168 bool Tesselation::IsEmpty() const
    169 {
    170   Info FunctionInfo(__func__);
    171   return (PointsOnBoundary.empty());
    172 }
    173 ;
    174 
    175 /** PointCloud implementation of IsLast.
    176  * Uses PointsOnBoundary and STL stuff.
    177  */
    178 bool Tesselation::IsEnd() const
    179 {
    180   Info FunctionInfo(__func__);
    181   return (InternalPointer == PointsOnBoundary.end());
    182 }
    183 ;
    18489
    18590/** Gueses first starting triangle of the convex envelope.
     
    318223 * \param *cloud cluster of points
    319224 */
    320 void Tesselation::TesselateOnBoundary(const PointCloud * const cloud)
     225void Tesselation::TesselateOnBoundary(IPointCloud & cloud)
    321226{
    322227  Info FunctionInfo(__func__);
     
    328233  LineMap::iterator LineChecker[2];
    329234
    330   Center = cloud->GetCenter();
     235  Center = cloud.GetCenter();
    331236  // create a first tesselation with the given BoundaryPoints
    332237  do {
     
    509414 * \return true - all straddling points insert, false - something went wrong
    510415 */
    511 bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC)
     416bool Tesselation::InsertStraddlingPoints(IPointCloud & cloud, const LinkedCell *LC)
    512417{
    513418  Info FunctionInfo(__func__);
    514419  Vector Intersection, Normal;
    515420  TesselPoint *Walker = NULL;
    516   Vector *Center = cloud->GetCenter();
     421  Vector *Center = cloud.GetCenter();
    517422  TriangleList *triangles = NULL;
    518423  bool AddFlag = false;
     
    520425  bool SuccessFlag = true;
    521426
    522   cloud->GoToFirst();
    523   BoundaryPoints = new LinkedCell(*this, 5.);
    524   while (!cloud->IsEnd()) { // we only have to go once through all points, as boundary can become only bigger
     427  cloud.GoToFirst();
     428  PointCloudAdaptor< Tesselation, MapValueIterator<Tesselation::iterator> > newcloud(this);
     429  BoundaryPoints = new LinkedCell(newcloud, 5.);
     430  while (!cloud.IsEnd()) { // we only have to go once through all points, as boundary can become only bigger
    525431    if (AddFlag) {
    526432      delete (BoundaryPoints);
    527       BoundaryPoints = new LinkedCell(*this, 5.);
     433      BoundaryPoints = new LinkedCell(newcloud, 5.);
    528434      AddFlag = false;
    529435    }
    530     Walker = cloud->GetPoint();
     436    Walker = cloud.GetPoint();
    531437    DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl);
    532438    // get the next triangle
     
    539445    if ((BTS == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
    540446      DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl);
    541       cloud->GoToNext();
     447      cloud.GoToNext();
    542448      continue;
    543449    } else {
     
    610516      break;
    611517    }
    612     cloud->GoToNext();
     518    cloud.GoToNext();
    613519  }
    614520
     
    11221028    for (LC->n[map[1]] = 0; LC->n[map[1]] < LC->N[map[1]]; LC->n[map[1]]++)
    11231029      for (LC->n[map[2]] = 0; LC->n[map[2]] < LC->N[map[2]]; LC->n[map[2]]++) {
    1124         const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
     1030        const TesselPointSTLList *List = LC->GetCurrentCell();
    11251031        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    11261032        if (List != NULL) {
    1127           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     1033          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    11281034            if ((*Runner)->at(map[0]) > maxCoordinate[map[0]]) {
    11291035              DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << (*Runner)->getPosition() << "." << endl);
     
    19821888    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    19831889      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    1984         const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
     1890        const TesselPointSTLList *List = LC->GetCurrentCell();
    19851891        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    19861892        if (List != NULL) {
    1987           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     1893          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    19881894            Candidate = (*Runner);
    19891895            // check if we only have one unique point yet ...
     
    21402046        for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    21412047          for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2142             const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
     2048            const TesselPointSTLList *List = LC->GetCurrentCell();
    21432049            //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    21442050            if (List != NULL) {
    2145               for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     2051              for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    21462052                Candidate = (*Runner);
    21472053
     
    23132219    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    23142220      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2315         const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
     2221        const TesselPointSTLList *List = LC->GetCurrentCell();
    23162222        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    23172223        if (List != NULL) {
    2318           for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     2224          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    23192225            FindPoint = PointsOnBoundary.find((*Runner)->nr);
    23202226            if (FindPoint != PointsOnBoundary.end()) {
     
    37103616 * \param *out otuput stream for debugging
    37113617 * \param *filename basename of output file
    3712  * \param *cloud PointCloud structure with all nodes
    3713  */
    3714 void Tesselation::Output(const char *filename, const PointCloud * const cloud)
     3618 * \param *cloud IPointCloud structure with all nodes
     3619 */
     3620void Tesselation::Output(const char *filename, IPointCloud & cloud)
    37153621{
    37163622  Info FunctionInfo(__func__);
Note: See TracChangeset for help on using the changeset viewer.