[357fba] | 1 | /*
|
---|
| 2 | * tesselation.hpp
|
---|
| 3 | *
|
---|
[d74077] | 4 | * The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors.
|
---|
| 5 | * As we actually mean this stuff for atoms, we have to encapsulate it all a bit.
|
---|
[357fba] | 6 | *
|
---|
| 7 | * Created on: Aug 3, 2009
|
---|
| 8 | * Author: heber
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #ifndef TESSELATION_HPP_
|
---|
| 12 | #define TESSELATION_HPP_
|
---|
| 13 |
|
---|
| 14 | using namespace std;
|
---|
| 15 |
|
---|
[f66195] | 16 | /*********************************************** includes ***********************************/
|
---|
| 17 |
|
---|
[357fba] | 18 | // include config.h
|
---|
| 19 | #ifdef HAVE_CONFIG_H
|
---|
| 20 | #include <config.h>
|
---|
| 21 | #endif
|
---|
| 22 |
|
---|
| 23 | #include <map>
|
---|
| 24 | #include <list>
|
---|
[7c14ec] | 25 | #include <set>
|
---|
[856098] | 26 | #include <stack>
|
---|
[357fba] | 27 |
|
---|
[d74077] | 28 | #include "BoundaryMaps.hpp"
|
---|
| 29 | #include "PointCloud.hpp"
|
---|
| 30 | #include "TesselPoint.hpp"
|
---|
[6b919f8] | 31 | #include "atom_particleinfo.hpp"
|
---|
[952f38] | 32 | #include "Helpers/helpers.hpp"
|
---|
[57f243] | 33 | #include "LinearAlgebra/Vector.hpp"
|
---|
[357fba] | 34 |
|
---|
[d74077] | 35 |
|
---|
[f66195] | 36 | /****************************************** forward declarations *****************************/
|
---|
| 37 |
|
---|
[357fba] | 38 | class BoundaryPointSet;
|
---|
| 39 | class BoundaryLineSet;
|
---|
| 40 | class BoundaryTriangleSet;
|
---|
[d74077] | 41 | class CandidateForTesselation;
|
---|
[f66195] | 42 | class LinkedCell;
|
---|
[357fba] | 43 | class Tesselation;
|
---|
[d4c9ae] | 44 | class Plane;
|
---|
[357fba] | 45 |
|
---|
[f66195] | 46 | /********************************************** definitions *********************************/
|
---|
| 47 |
|
---|
[57066a] | 48 | #define DoTecplotOutput 1
|
---|
[09898c] | 49 | #define DoRaster3DOutput 1
|
---|
[734816] | 50 | #define DoVRMLOutput 0
|
---|
[57066a] | 51 | #define TecplotSuffix ".dat"
|
---|
| 52 | #define Raster3DSuffix ".r3d"
|
---|
| 53 | #define VRMLSUffix ".wrl"
|
---|
| 54 |
|
---|
[fad93c] | 55 | #define ParallelEpsilon 1e-3
|
---|
| 56 |
|
---|
[357fba] | 57 | // ======================================================= some template functions =========================================
|
---|
| 58 |
|
---|
[f66195] | 59 | /********************************************** declarations *******************************/
|
---|
[357fba] | 60 |
|
---|
| 61 | // =========================================================== class TESSELATION ===========================================
|
---|
| 62 |
|
---|
| 63 | /** Contains the envelope to a PointCloud.
|
---|
| 64 | */
|
---|
[5c7bf8] | 65 | class Tesselation : public PointCloud {
|
---|
[357fba] | 66 | public:
|
---|
| 67 |
|
---|
| 68 | Tesselation();
|
---|
[5c7bf8] | 69 | virtual ~Tesselation();
|
---|
[357fba] | 70 |
|
---|
[776b64] | 71 | void AddTesselationPoint(TesselPoint* Candidate, const int n);
|
---|
[f1ef60a] | 72 | void SetTesselationPoint(TesselPoint* Candidate, const int n) const;
|
---|
[d74077] | 73 | void AddTesselationLine(const Vector * OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
|
---|
[474961] | 74 | void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
|
---|
| 75 | void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n);
|
---|
[16d866] | 76 | void AddTesselationTriangle();
|
---|
[776b64] | 77 | void AddTesselationTriangle(const int nr);
|
---|
[6613ec] | 78 | void AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type);
|
---|
[711ac2] | 79 | void AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC);
|
---|
[474961] | 80 | void AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC);
|
---|
[16d866] | 81 | void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
|
---|
| 82 | void RemoveTesselationLine(class BoundaryLineSet *line);
|
---|
| 83 | void RemoveTesselationPoint(class BoundaryPointSet *point);
|
---|
[6613ec] | 84 | bool CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const;
|
---|
[16d866] | 85 |
|
---|
[357fba] | 86 |
|
---|
| 87 | // concave envelope
|
---|
[ce70970] | 88 | bool FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
|
---|
[776b64] | 89 | void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
|
---|
[f07f86d] | 90 | 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;
|
---|
| 91 | bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
|
---|
[6613ec] | 92 | bool FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList);
|
---|
[f1ef60a] | 93 | int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
|
---|
[e138de] | 94 | class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]);
|
---|
[357fba] | 95 |
|
---|
| 96 | // convex envelope
|
---|
[e138de] | 97 | void TesselateOnBoundary(const PointCloud * const cloud);
|
---|
| 98 | void GuessStartingTriangle();
|
---|
| 99 | bool InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC);
|
---|
| 100 | double RemovePointFromTesselatedSurface(class BoundaryPointSet *point);
|
---|
| 101 | class BoundaryLineSet * FlipBaseline(class BoundaryLineSet *Base);
|
---|
| 102 | double PickFarthestofTwoBaselines(class BoundaryLineSet *Base);
|
---|
| 103 | class BoundaryPointSet *IsConvexRectangle(class BoundaryLineSet *Base);
|
---|
[244a84] | 104 | IndexToIndex * FindAllDegeneratedTriangles();
|
---|
| 105 | IndexToIndex * FindAllDegeneratedLines();
|
---|
[7c14ec] | 106 | void RemoveDegeneratedTriangles();
|
---|
[e138de] | 107 | void AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC);
|
---|
[262bae] | 108 | int CorrectAllDegeneratedPolygons();
|
---|
[16d866] | 109 |
|
---|
[244a84] | 110 | TesselPointSet * GetAllConnectedPoints(const TesselPoint* const Point) const;
|
---|
| 111 | TriangleSet * GetAllTriangles(const BoundaryPointSet * const Point) const;
|
---|
| 112 | ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const;
|
---|
| 113 | ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const;
|
---|
[d74077] | 114 | TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const;
|
---|
| 115 | TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector &Reference) const;
|
---|
[244a84] | 116 | class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const;
|
---|
| 117 | TriangleList * FindTriangles(const TesselPoint* const Points[3]) const;
|
---|
[d74077] | 118 | TriangleList * FindClosestTrianglesToVector(const Vector &x, const LinkedCell* LC) const;
|
---|
| 119 | BoundaryTriangleSet * FindClosestTriangleToVector(const Vector &x, const LinkedCell* LC) const;
|
---|
[241485] | 120 | bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
|
---|
[244a84] | 121 | double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const;
|
---|
[8db598] | 122 | double GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const;
|
---|
| 123 | BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const;
|
---|
[776b64] | 124 | bool AddBoundaryPoint(TesselPoint * Walker, const int n);
|
---|
[d74077] | 125 | DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector &x, const LinkedCell* LC) const;
|
---|
| 126 | BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector &x, const LinkedCell* LC) const;
|
---|
[ab1932] | 127 |
|
---|
[0077b5] | 128 | // print for debugging
|
---|
[776b64] | 129 | void PrintAllBoundaryPoints(ofstream *out) const;
|
---|
| 130 | void PrintAllBoundaryLines(ofstream *out) const;
|
---|
| 131 | void PrintAllBoundaryTriangles(ofstream *out) const;
|
---|
[0077b5] | 132 |
|
---|
[57066a] | 133 | // store envelope in file
|
---|
[e138de] | 134 | void Output(const char *filename, const PointCloud * const cloud);
|
---|
[0077b5] | 135 |
|
---|
[357fba] | 136 | PointMap PointsOnBoundary;
|
---|
| 137 | LineMap LinesOnBoundary;
|
---|
[1e168b] | 138 | CandidateMap OpenLines;
|
---|
[357fba] | 139 | TriangleMap TrianglesOnBoundary;
|
---|
| 140 | int PointsOnBoundaryCount;
|
---|
| 141 | int LinesOnBoundaryCount;
|
---|
| 142 | int TrianglesOnBoundaryCount;
|
---|
| 143 |
|
---|
[5c7bf8] | 144 | // PointCloud implementation for PointsOnBoundary
|
---|
[776b64] | 145 | virtual Vector *GetCenter(ofstream *out) const;
|
---|
| 146 | virtual TesselPoint *GetPoint() const;
|
---|
| 147 | virtual void GoToNext() const;
|
---|
| 148 | virtual void GoToFirst() const;
|
---|
| 149 | virtual bool IsEmpty() const;
|
---|
| 150 | virtual bool IsEnd() const;
|
---|
[5c7bf8] | 151 |
|
---|
[357fba] | 152 | class BoundaryPointSet *BPS[2];
|
---|
| 153 | class BoundaryLineSet *BLS[3];
|
---|
| 154 | class BoundaryTriangleSet *BTS;
|
---|
[57066a] | 155 | class BoundaryTriangleSet *LastTriangle;
|
---|
| 156 | int TriangleFilesWritten;
|
---|
[5c7bf8] | 157 |
|
---|
[08ef35] | 158 | private:
|
---|
[f1ef60a] | 159 | mutable class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
|
---|
[08ef35] | 160 |
|
---|
[776b64] | 161 | mutable PointMap::const_iterator InternalPointer;
|
---|
[f1ef60a] | 162 |
|
---|
[f67b6e] | 163 | //bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const;
|
---|
[6613ec] | 164 | void FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter);
|
---|
[357fba] | 165 | };
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | #endif /* TESSELATION_HPP_ */
|
---|