Changeset 262bae


Ignore:
Timestamp:
Nov 27, 2009, 2:39:06 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:
856098, af374d
Parents:
523917
Message:

First compiling version of CorrectDegeneratedPolygons.

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.hpp

    r523917 r262bae  
    3535
    3636#define DEBUG 1
    37 #define DoSingleStepOutput 1
     37#define DoSingleStepOutput 0
    3838#define SingleStepWidth 1
    3939
  • src/tesselation.cpp

    r523917 r262bae  
    558558//  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
    559559//      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
     560  return ost;
     561};
     562
     563// ======================================== Polygons on Boundary =================================
     564
     565/** Constructor for BoundaryPolygonSet.
     566 */
     567BoundaryPolygonSet::BoundaryPolygonSet() :
     568  Nr(-1)
     569{
     570  Info FunctionInfo(__func__);
     571};
     572
     573/** Destructor of BoundaryPolygonSet.
     574 * Just clears endpoints.
     575 * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()
     576 */
     577BoundaryPolygonSet::~BoundaryPolygonSet()
     578{
     579  Info FunctionInfo(__func__);
     580  endpoints.clear();
     581  Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl;
     582};
     583
     584/** Calculates the normal vector for this triangle.
     585 * Is made unique by comparison with \a OtherVector to point in the other direction.
     586 * \param &OtherVector direction vector to make normal vector unique.
     587 * \return allocated vector in normal direction
     588 */
     589Vector * BoundaryPolygonSet::GetNormalVector(const Vector &OtherVector) const
     590{
     591  Info FunctionInfo(__func__);
     592  // get normal vector
     593  Vector TemporaryNormal;
     594  Vector *TotalNormal = new Vector;
     595  PointSet::const_iterator Runner[3];
     596  for (int i=0;i<3; i++) {
     597    Runner[i] = endpoints.begin();
     598    for (int j = 0; j<i; j++) { // go as much further
     599      Runner[i]++;
     600      if (Runner[i] == endpoints.end()) {
     601        eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl;
     602        performCriticalExit();
     603      }
     604    }
     605  }
     606  TotalNormal->Zero();
     607  int counter=0;
     608  for (; Runner[2] != endpoints.end(); ) {
     609    TemporaryNormal.MakeNormalVector((*Runner[0])->node->node, (*Runner[1])->node->node, (*Runner[2])->node->node);
     610    for (int i=0;i<3;i++) // increase each of them
     611      Runner[i]++;
     612    TotalNormal->AddVector(&TemporaryNormal);
     613  }
     614  TotalNormal->Scale(1./(double)counter);
     615
     616  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
     617  if (TotalNormal->ScalarProduct(&OtherVector) > 0.)
     618    TotalNormal->Scale(-1.);
     619  Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl;
     620
     621  return TotalNormal;
     622};
     623
     624/** Calculates the center point of the triangle.
     625 * Is third of the sum of all endpoints.
     626 * \param *center central point on return.
     627 */
     628void BoundaryPolygonSet::GetCenter(Vector * const center) const
     629{
     630  Info FunctionInfo(__func__);
     631  center->Zero();
     632  int counter = 0;
     633  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     634    center->AddVector((*Runner)->node->node);
     635    counter++;
     636  }
     637  center->Scale(1./(double)counter);
     638}
     639
     640/** Checks whether the polygons contains all three endpoints of the triangle.
     641 * \param *triangle triangle to test
     642 * \return true - triangle is contained polygon, false - is not
     643 */
     644bool BoundaryPolygonSet::ContainsBoundaryTriangle(const BoundaryTriangleSet * const triangle) const
     645{
     646  Info FunctionInfo(__func__);
     647  return ContainsPresentTupel(triangle->endpoints, 3);
     648};
     649
     650/** Checks whether the polygons contains both endpoints of the line.
     651 * \param *line line to test
     652 * \return true - line is of the triangle, false - is not
     653 */
     654bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
     655{
     656  return ContainsPresentTupel(line->endpoints, 2);
     657};
     658
     659/** Checks whether point is any of the three endpoints this triangle contains.
     660 * \param *point point to test
     661 * \return true - point is of the triangle, false - is not
     662 */
     663bool BoundaryPolygonSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
     664{
     665  Info FunctionInfo(__func__);
     666  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     667    if (point == (*Runner))
     668      return true;
     669  return false;
     670};
     671
     672/** Checks whether point is any of the three endpoints this triangle contains.
     673 * \param *point TesselPoint to test
     674 * \return true - point is of the triangle, false - is not
     675 */
     676bool BoundaryPolygonSet::ContainsBoundaryPoint(const TesselPoint * const point) const
     677{
     678  Info FunctionInfo(__func__);
     679  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     680    if (point == (*Runner)->node)
     681      return true;
     682  return false;
     683};
     684
     685/** Checks whether given array of \a *Points coincide with polygons's endpoints.
     686 * \param **Points pointer to an array of BoundaryPointSet
     687 * \param dim dimension of array
     688 * \return true - set of points is contained in polygon, false - is not
     689 */
     690bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const
     691{
     692  int counter = 0;
     693  for(int i=0;i<dim;i++)
     694    if (ContainsBoundaryPoint(Points[i]))
     695      counter++;
     696
     697  if (counter == dim)
     698    return true;
     699  else
     700    return false;
     701};
     702
     703/** Checks whether given PointList coincide with polygons's endpoints.
     704 * \param &endpoints PointList
     705 * \return true - set of points is contained in polygon, false - is not
     706 */
     707bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const
     708{
     709  size_t counter = 0;
     710  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     711    if (ContainsBoundaryPoint(*Runner))
     712      counter++;
     713  }
     714
     715  if (counter == endpoints.size())
     716    return true;
     717  else
     718    return false;
     719};
     720
     721/** Checks whether given set of \a *Points coincide with polygons's endpoints.
     722 * \param *P pointer to BoundaryPolygonSet
     723 * \return true - is the very triangle, false - is not
     724 */
     725bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const
     726{
     727  Info FunctionInfo(__func__);
     728  return ContainsPresentTupel((const PointSet)P->endpoints);
     729};
     730
     731/** Gathers all the endpoints' triangles in a unique set.
     732 * \return set of all triangles
     733 */
     734TriangleSet * BoundaryPolygonSet::GetAllTrianglesFromEndpoints() const
     735{
     736  Info FunctionInfo(__func__);
     737  TriangleSet *triangles = new TriangleSet;
     738
     739  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     740    for(LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)
     741      for(TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++)
     742        triangles->insert(Sprinter->second);
     743
     744  Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl;
     745  return triangles;
     746};
     747
     748/** Fills the endpoints of this polygon from the triangles attached to \a *line.
     749 * \param *line lines with triangles attached
     750 * \return true - polygon contains four points, false - something went wront, polygon does not contain any points
     751 */
     752bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line)
     753{
     754  for(TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {
     755    for (int i=0;i<3;i++)
     756      endpoints.insert((Runner->second)->endpoints[i]);
     757  }
     758
     759  if (endpoints.size() != 4)  {// remove all points on error
     760    endpoints.clear();
     761    return false;
     762  } else
     763    return true;
     764};
     765
     766/** output operator for BoundaryPolygonSet.
     767 * \param &ost output stream
     768 * \param &a boundary polygon
     769 */
     770ostream &operator <<(ostream &ost, const BoundaryPolygonSet &a)
     771{
     772  ost << "[" << a.Nr << "|";
     773  for(PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
     774   ost << (*Runner)->node->Name;
     775   Runner++;
     776   if (Runner != a.endpoints.end())
     777     ost << ",";
     778  }
     779  ost<< "]";
    560780  return ost;
    561781};
     
    38034023    TriangleFilesWritten++;
    38044024};
     4025
     4026/** Finds all degenerated polygons and calls ReTesselateDegeneratedPolygon()/
     4027 * \return number of polygons found
     4028 */
     4029int Tesselation::CorrectAllDegeneratedPolygons()
     4030{
     4031  Info FunctionInfo(__func__);
     4032
     4033  /// 1. Find all simply degenerated triangles and sort into a list with each endpoint as key
     4034  map<int, int> * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles();
     4035
     4036  /// 2. Go through all lines not contained in degenerated triangles.
     4037  PolygonList ListofFours;
     4038  BoundaryPolygonSet *Four = NULL;
     4039  TriangleSet *T = NULL;
     4040  for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) {
     4041    Four = new BoundaryPolygonSet;
     4042
     4043    /// 2a. Get all four endpoints of the two connected triangles.
     4044    Four->FillPolygonFromTrianglesOfLine((LineRunner->second));
     4045
     4046    /// 2b. Get the triangles of all those endpoints
     4047    T = Four->GetAllTrianglesFromEndpoints();
     4048
     4049    /// 2c. Find all pairs of those triangles that contain the four endpoints
     4050    if (CountTrianglePairContainingPolygon(Four, T) > 1) {
     4051      /// 2d. Check the number of pairs, if greater 1, we have a degenerated polygon (mark down for later use)
     4052      ListofFours.push_back(Four);
     4053    } else
     4054      delete(Four);
     4055
     4056    delete(T);
     4057  }
     4058
     4059  /// 3. Combine all edge-connected degenerated polygons
     4060  PolygonList::iterator PolygonWalker;  // is the inner iterator
     4061  PolygonList::iterator PolygonSprinter; // is the inner advanced iterator
     4062  for (PolygonList::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) {
     4063    PolygonWalker = PolygonRunner;
     4064    PolygonWalker++;
     4065    PolygonSprinter = PolygonWalker;
     4066    while (PolygonWalker != ListofFours.end()) {
     4067      PolygonSprinter++;
     4068      if (ArePolygonsEdgeConnected((*PolygonRunner), (*PolygonWalker))) { // if connected
     4069        CombinePolygons((*PolygonRunner), (*PolygonWalker)); // combined and ...
     4070        ListofFours.erase(PolygonWalker); // ... remove from list
     4071      }
     4072      PolygonWalker = PolygonSprinter;
     4073    }
     4074  }
     4075
     4076  /// 4. Go through all these degenerated polygons
     4077  Vector NormalVector;
     4078  for (PolygonList::iterator PolygonRunner = ListofFours.begin(); PolygonRunner != ListofFours.end(); PolygonRunner++) {
     4079    /// 4a. Gather all triangles of this polygon
     4080    T = Four->GetAllTrianglesFromEndpoints();
     4081
     4082    /// 4a. Get NormalVector for one side (this is "front")
     4083    NormalVector.CopyVector(&(*(T->begin()))->NormalVector);
     4084
     4085    /// 4b. Remove all triangles whose NormalVector is in opposite direction (i.e. "back")
     4086    TriangleSet::const_iterator TriangleWalker;  // is the inner iterator
     4087    TriangleSet::const_iterator TriangleSprinter; // is the inner advanced iterator
     4088    PolygonWalker = PolygonRunner;
     4089    PolygonWalker++;
     4090    PolygonSprinter = PolygonWalker;
     4091    while (PolygonWalker != ListofFours.end()) {
     4092      PolygonSprinter++;
     4093      if ((*TriangleWalker)->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list
     4094        delete(*TriangleWalker);  // remove triangle
     4095        T->erase(TriangleWalker);
     4096      }
     4097    }
     4098    /// 4c. Copy all "front" triangles but with inverse NormalVector
     4099    BoundaryTriangleSet *triangle = NULL;
     4100    TriangleWalker = T->begin();
     4101    TriangleSprinter = T->end();
     4102    TriangleSprinter--; // set onto last "front" triangle
     4103    while (TriangleWalker != TriangleSprinter) {  // go through all front triangles
     4104      triangle = new BoundaryTriangleSet(*(*TriangleWalker)); // copy triangle ...
     4105      triangle->NormalVector.Scale(-1.);
     4106      T->insert(triangle); // ... and add
     4107      /// 4d. Add all degenerated triangles to the list of simply degenerated triangles
     4108      SimplyDegeneratedTriangles->insert(pair <int, int> ((*TriangleWalker)->Nr, triangle->Nr) );
     4109      TriangleWalker++;
     4110    }
     4111    delete(T);  // remove the triangleset
     4112  }
     4113
     4114  /// 5. exit
     4115  PolygonList::iterator PolygonRunner;
     4116  while (ListofFours.empty()) {
     4117    PolygonRunner = ListofFours.begin();
     4118    delete(*PolygonRunner);
     4119    ListofFours.erase(PolygonRunner);
     4120  }
     4121
     4122  int counter = SimplyDegeneratedTriangles->size();
     4123  delete(SimplyDegeneratedTriangles);
     4124  return counter;
     4125};
  • src/tesselation.hpp

    r523917 r262bae  
    5050
    5151#define PointMap map < int, class BoundaryPointSet * >
     52#define PointSet set < class BoundaryPointSet * >
     53#define PointList list < class BoundaryPointSet * >
    5254#define PointPair pair < int, class BoundaryPointSet * >
    5355#define PointTestPair pair < PointMap::iterator, bool >
     56
    5457#define CandidateList list <class CandidateForTesselation *>
    5558#define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>
    5659
    5760#define LineMap multimap < int, class BoundaryLineSet * >
     61#define LineSet set < class BoundaryLineSet * >
     62#define LineList list < class BoundaryLineSet * >
    5863#define LinePair pair < int, class BoundaryLineSet * >
    5964#define LineTestPair pair < LineMap::iterator, bool >
    6065
    6166#define TriangleMap map < int, class BoundaryTriangleSet * >
     67#define TriangleSet set < class BoundaryTriangleSet * >
     68#define TriangleList list < class BoundaryTriangleSet * >
    6269#define TrianglePair pair < int, class BoundaryTriangleSet * >
    6370#define TriangleTestPair pair < TrianglePair::iterator, bool >
    6471
     72#define PolygonMap map < int, class BoundaryPolygonSet * >
     73#define PolygonSet set < class BoundaryPolygonSet * >
     74#define PolygonList list < class BoundaryPolygonSet * >
     75
    6576#define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
    6677#define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
    6778
    6879#define TesselPointList list <TesselPoint *>
     80#define TesselPointSet set <TesselPoint *>
    6981
    7082/********************************************** declarations *******************************/
     
    147159
    148160ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);
     161
     162
     163// ======================================================== class BoundaryTriangleSet =======================================
     164
     165/** Set of BoundaryPointSet.
     166 * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has
     167 * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation
     168 * class (i.e. no allocation, no deletion).
     169 * \note we assume that the set of endpoints reside (more or less) on a plane.
     170 */
     171class BoundaryPolygonSet {
     172  public:
     173    BoundaryPolygonSet();
     174    ~BoundaryPolygonSet();
     175
     176    Vector * GetNormalVector(const Vector &NormalVector) const;
     177    void GetCenter(Vector *center) const;
     178    bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
     179    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
     180    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
     181    bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;
     182    bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;
     183    bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;
     184    bool ContainsPresentTupel(const PointSet &endpoints) const;
     185    TriangleSet * GetAllTrianglesFromEndpoints() const;
     186    bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);
     187
     188    PointSet endpoints;
     189    int Nr;
     190};
     191
     192ostream & operator << (ostream &ost, const BoundaryPolygonSet &a);
    149193
    150194// =========================================================== class TESSELPOINT ===========================================
     
    246290    void RemoveDegeneratedTriangles();
    247291    void AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC);
     292    int CorrectAllDegeneratedPolygons();
    248293
    249294    set<TesselPoint*> * GetAllConnectedPoints(const TesselPoint* const Point) const;
  • src/tesselationhelpers.cpp

    r523917 r262bae  
    937937}
    938938
     939/** Counts the number of triangle pairs that contain the given polygon.
     940 * \param *P polygon with endpoints to look for
     941 * \param *T set of triangles to create pairs from containing \a *P
     942 */
     943int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T)
     944{
     945  Info FunctionInfo(__func__);
     946  // check number of endpoints in *P
     947  if (P->endpoints.size() != 4) {
     948    eLog() << Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl;
     949    return 0;
     950  }
     951
     952  // check number of triangles in *T
     953  if (T->size() < 2) {
     954    eLog() << Verbose(1) << "Not enough triangles to have pairs!" << endl;
     955    return 0;
     956  }
     957
     958  // create each pair, get the endpoints and check whether *P is contained.
     959  int counter = 0;
     960  PointSet Trianglenodes;
     961  class BoundaryPolygonSet PairTrianglenodes;
     962  for(TriangleSet::iterator Walker = T->begin(); Walker != T->end(); Walker++) {
     963    for (int i=0;i<3;i++)
     964      Trianglenodes.insert((*Walker)->endpoints[i]);
     965
     966    for(TriangleSet::iterator PairWalker = Walker; PairWalker != T->end(); PairWalker++) {
     967      if (Walker != PairWalker) { // skip first
     968        PairTrianglenodes.endpoints = Trianglenodes;
     969        for (int i=0;i<3;i++)
     970          PairTrianglenodes.endpoints.insert((*PairWalker)->endpoints[i]);
     971        Log() << Verbose(1) << "Current pair of triangles: " << PairTrianglenodes << "." << endl;
     972        // now check
     973        if (PairTrianglenodes.ContainsPresentTupel(P)) {
     974          counter++;
     975          Log() << Verbose(1) << "Matches with " << *P << endl;
     976        } else {
     977          Log() << Verbose(1) << "No match with " << *P << endl;
     978        }
     979      }
     980    }
     981    PairTrianglenodes.endpoints.clear();
     982  }
     983  return counter;
     984};
     985
     986/** Checks whether two give polygons have two or more points in common.
     987 * \param *P1 first polygon
     988 * \param *P2 second polygon
     989 * \return true - are connected, false = are note
     990 */
     991bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2)
     992{
     993  Info FunctionInfo(__func__);
     994  int counter = 0;
     995  for(PointSet::const_iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) {
     996    if (P2->ContainsBoundaryPoint((*Runner))) {
     997      counter++;
     998      Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl;
     999      return true;
     1000    }
     1001  }
     1002  return false;
     1003};
     1004
     1005/** Combines second into the first and deletes the second.
     1006 * \param *P1 first polygon, contains all nodes on return
     1007 * \param *&P2 second polygon, is deleted.
     1008 */
     1009void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2)
     1010{
     1011  Info FunctionInfo(__func__);
     1012  for(PointSet::iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) {
     1013    P1->endpoints.insert((*Runner));
     1014  }
     1015  P2->endpoints.clear();
     1016  delete(P2);
     1017};
     1018
  • src/tesselationhelpers.hpp

    r523917 r262bae  
    7272bool CheckListOfBaselines(const Tesselation * const TesselStruct);
    7373
     74int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T);
     75bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2);
     76void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2);
     77
    7478
    7579#endif /* TESSELATIONHELPERS_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.