Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.hpp

    rce70970 r27bd2f  
    2323#include <list>
    2424#include <set>
    25 #include <stack>
    2625
    2726#include "atom_particleinfo.hpp"
     
    4342#define DoTecplotOutput 1
    4443#define DoRaster3DOutput 1
    45 #define DoVRMLOutput 0
     44#define DoVRMLOutput 1
    4645#define TecplotSuffix ".dat"
    4746#define Raster3DSuffix ".r3d"
    4847#define VRMLSUffix ".wrl"
    4948
    50 #define ParallelEpsilon 1e-3
    51 
    5249// ======================================================= some template functions =========================================
    5350
    54 #define IndexToIndex map <int, int>
    55 
    5651#define PointMap map < int, class BoundaryPointSet * >
    57 #define PointSet set < class BoundaryPointSet * >
    58 #define PointList list < class BoundaryPointSet * >
    5952#define PointPair pair < int, class BoundaryPointSet * >
    6053#define PointTestPair pair < PointMap::iterator, bool >
    61 
    6254#define CandidateList list <class CandidateForTesselation *>
    6355#define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>
    6456
    6557#define LineMap multimap < int, class BoundaryLineSet * >
    66 #define LineSet set < class BoundaryLineSet * >
    67 #define LineList list < class BoundaryLineSet * >
    6858#define LinePair pair < int, class BoundaryLineSet * >
    6959#define LineTestPair pair < LineMap::iterator, bool >
    7060
    7161#define TriangleMap map < int, class BoundaryTriangleSet * >
    72 #define TriangleSet set < class BoundaryTriangleSet * >
    73 #define TriangleList list < class BoundaryTriangleSet * >
    7462#define TrianglePair pair < int, class BoundaryTriangleSet * >
    7563#define TriangleTestPair pair < TrianglePair::iterator, bool >
    7664
    77 #define PolygonMap map < int, class BoundaryPolygonSet * >
    78 #define PolygonSet set < class BoundaryPolygonSet * >
    79 #define PolygonList list < class BoundaryPolygonSet * >
    80 
    81 #define DistanceToPointMap multimap <double, class BoundaryPointSet * >
    82 #define DistanceToPointPair pair <double, class BoundaryPointSet * >
    83 
    8465#define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
    8566#define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
    8667
    8768#define TesselPointList list <TesselPoint *>
    88 #define TesselPointSet set <TesselPoint *>
    89 
    90 #define ListOfTesselPointList list<list <TesselPoint *> *>
    91 
    92 enum centers {Opt, OtherOpt};
    9369
    9470/********************************************** declarations *******************************/
     
    11086  public:
    11187    BoundaryPointSet();
    112     BoundaryPointSet(TesselPoint * const Walker);
     88    BoundaryPointSet(TesselPoint * Walker);
    11389    ~BoundaryPointSet();
    11490
    115     void AddLine(BoundaryLineSet * const line);
     91    void AddLine(class BoundaryLineSet *line);
    11692
    11793    LineMap lines;
     
    129105  public:
    130106    BoundaryLineSet();
    131     BoundaryLineSet(BoundaryPointSet * const Point[2], const int number);
    132     BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number);
     107    BoundaryLineSet(class BoundaryPointSet *Point[2], const int number);
    133108    ~BoundaryLineSet();
    134109
    135     void AddTriangle(BoundaryTriangleSet * const triangle);
    136     bool IsConnectedTo(const BoundaryLineSet * const line) const;
    137     bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
    138     bool CheckConvexityCriterion() const;
    139     class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;
     110    void AddTriangle(class BoundaryTriangleSet *triangle);
     111    bool IsConnectedTo(class BoundaryLineSet *line);
     112    bool ContainsBoundaryPoint(class BoundaryPointSet *point);
     113    bool CheckConvexityCriterion();
     114    class BoundaryPointSet *GetOtherEndpoint(class BoundaryPointSet *);
    140115
    141116    class BoundaryPointSet *endpoints[2];
     
    152127  public:
    153128    BoundaryTriangleSet();
    154     BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);
     129    BoundaryTriangleSet(class BoundaryLineSet *line[3], int number);
    155130    ~BoundaryTriangleSet();
    156131
    157     void GetNormalVector(const Vector &NormalVector);
    158     void GetCenter(Vector * const center) const;
    159     bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const;
    160     double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const;
    161     bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
    162     bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
    163     bool ContainsBoundaryPoint(const TesselPoint * const point) const;
    164     class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;
    165     bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
    166     bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
     132    void GetNormalVector(Vector &NormalVector);
     133    void GetCenter(Vector *center);
     134    bool GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection);
     135    bool ContainsBoundaryLine(class BoundaryLineSet *line);
     136    bool ContainsBoundaryPoint(class BoundaryPointSet *point);
     137    bool ContainsBoundaryPoint(class TesselPoint *point);
     138    class BoundaryPointSet *GetThirdEndpoint(class BoundaryLineSet *line);
     139    bool IsPresentTupel(class BoundaryPointSet *Points[3]);
     140    bool IsPresentTupel(class BoundaryTriangleSet *T);
    167141
    168142    class BoundaryPointSet *endpoints[3];
    169143    class BoundaryLineSet *lines[3];
    170144    Vector NormalVector;
    171     Vector SphereCenter;
    172145    int Nr;
    173146};
    174147
    175148ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);
    176 
    177 
    178 // ======================================================== class BoundaryTriangleSet =======================================
    179 
    180 /** Set of BoundaryPointSet.
    181  * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has
    182  * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation
    183  * class (i.e. no allocation, no deletion).
    184  * \note we assume that the set of endpoints reside (more or less) on a plane.
    185  */
    186 class BoundaryPolygonSet {
    187   public:
    188     BoundaryPolygonSet();
    189     ~BoundaryPolygonSet();
    190 
    191     Vector * GetNormalVector(const Vector &NormalVector) const;
    192     void GetCenter(Vector *center) const;
    193     bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
    194     bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
    195     bool ContainsBoundaryPoint(const TesselPoint * const point) const;
    196     bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;
    197     bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;
    198     bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;
    199     bool ContainsPresentTupel(const PointSet &endpoints) const;
    200     TriangleSet * GetAllContainedTrianglesFromEndpoints() const;
    201     bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);
    202 
    203     PointSet endpoints;
    204     int Nr;
    205 };
    206 
    207 ostream & operator << (ostream &ost, const BoundaryPolygonSet &a);
    208149
    209150// =========================================================== class TESSELPOINT ===========================================
     
    237178  virtual TesselPoint *GetPoint() const { return NULL; };
    238179  virtual TesselPoint *GetTerminalPoint() const { return NULL; };
    239   virtual int GetMaxId() const { return 0; };
    240180  virtual void GoToNext() const {};
    241181  virtual void GoToPrevious() const {};
     
    251191  public :
    252192  CandidateForTesselation(BoundaryLineSet* currentBaseLine);
    253   CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
     193  CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
    254194  ~CandidateForTesselation();
    255195
    256   bool CheckValidity(const double RADIUS, const LinkedCell *LC) const;
    257 
    258196  TesselPointList pointlist;
    259   const BoundaryLineSet * BaseLine;
    260   const BoundaryPointSet * ThirdPoint;
    261   const BoundaryTriangleSet *T;
    262   Vector OldCenter;
     197  BoundaryLineSet *BaseLine;
    263198  Vector OptCenter;
    264199  Vector OtherOptCenter;
     
    281216    void AddTesselationPoint(TesselPoint* Candidate, const int n);
    282217    void SetTesselationPoint(TesselPoint* Candidate, const int n) const;
    283     void AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
    284     void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
    285     void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n);
     218    void AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
     219    void AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
    286220    void AddTesselationTriangle();
    287221    void AddTesselationTriangle(const int nr);
    288     void AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type);
    289     void AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC);
    290     void AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC);
     222    void AddCandidateTriangle(CandidateForTesselation CandidateLine);
    291223    void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
    292224    void RemoveTesselationLine(class BoundaryLineSet *line);
    293225    void RemoveTesselationPoint(class BoundaryPointSet *point);
    294     bool CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const;
    295226
    296227
    297228    // concave envelope
    298     bool FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
     229    void FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
    299230    void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
    300     void FindThirdPointForTesselation(const Vector &NormalVector, const Vector &SearchDirection, const Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const;
    301     bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
    302     bool FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList);
     231    void FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const;
     232    bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
    303233    int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
    304234    class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]);
     
    312242    double PickFarthestofTwoBaselines(class BoundaryLineSet *Base);
    313243    class BoundaryPointSet *IsConvexRectangle(class BoundaryLineSet *Base);
    314     IndexToIndex * FindAllDegeneratedTriangles();
    315     IndexToIndex * FindAllDegeneratedLines();
     244    map<int, int> * FindAllDegeneratedTriangles();
     245    map<int, int> * FindAllDegeneratedLines();
    316246    void RemoveDegeneratedTriangles();
    317247    void AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC);
    318     int CorrectAllDegeneratedPolygons();
    319 
    320     TesselPointSet * GetAllConnectedPoints(const TesselPoint* const Point) const;
    321     TriangleSet * GetAllTriangles(const BoundaryPointSet * const Point) const;
    322     ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const;
    323     ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const;
    324     TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const;
    325     TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const;
    326     class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const;
    327     TriangleList * FindTriangles(const TesselPoint* const Points[3]) const;
    328     TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const;
    329     BoundaryTriangleSet * FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const;
     248
     249    set<TesselPoint*> * GetAllConnectedPoints(const TesselPoint* const Point) const;
     250    set<BoundaryTriangleSet*> *GetAllTriangles(const BoundaryPointSet * const Point) const;
     251    list<list<TesselPoint*> *> * GetPathsOfConnectedPoints(const TesselPoint* const Point) const;
     252    list<list<TesselPoint*> *> * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const;
     253    list<TesselPoint*> * GetCircleOfSetOfPoints(set<TesselPoint*> *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const;
     254    class BoundaryPointSet *GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const;
     255    list<BoundaryTriangleSet*> *FindTriangles(const TesselPoint* const Points[3]) const;
     256    list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(const Vector *x, const LinkedCell* LC) const;
     257    class BoundaryTriangleSet * FindClosestTriangleToPoint(const Vector *x, const LinkedCell* LC) const;
    330258    bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
    331     double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const;
    332     double GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const;
    333     BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const;
     259    bool IsInnerPoint(const TesselPoint * const Point, const LinkedCell* const LC) const;
    334260    bool AddBoundaryPoint(TesselPoint * Walker, const int n);
    335     DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;
    336     BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const;
    337261
    338262    // print for debugging
     
    375299
    376300    //bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const;
    377     void FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter);
    378301};
    379302
Note: See TracChangeset for help on using the changeset viewer.