source: src/tesselation.hpp@ f1cccd

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
Last change on this file since f1cccd was f1cccd, checked in by Saskia Metzler <metzler@…>, 16 years ago

Ticket 14: Rename .._.. functions in boundary.cpp

  • Property mode set to 100644
File size: 10.0 KB
Line 
1/*
2 * tesselation.hpp
3 *
4 * The tesselation class is meant to contain the envelope (concave, convex or neither) of a set of Vectors. As we actually mean this stuff for atoms, we have to encapsulate it all a bit.
5 *
6 * Created on: Aug 3, 2009
7 * Author: heber
8 */
9
10#ifndef TESSELATION_HPP_
11#define TESSELATION_HPP_
12
13using namespace std;
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <map>
21#include <list>
22
23
24#include "helpers.hpp"
25#include "linkedcell.hpp"
26#include "tesselationhelpers.hpp"
27#include "vector.hpp"
28
29class BoundaryPointSet;
30class BoundaryLineSet;
31class BoundaryTriangleSet;
32class TesselPoint;
33class PointCloud;
34class Tesselation;
35
36// ======================================================= some template functions =========================================
37
38#define PointMap map < int, class BoundaryPointSet * >
39#define PointPair pair < int, class BoundaryPointSet * >
40#define PointTestPair pair < PointMap::iterator, bool >
41#define CandidateList list <class CandidateForTesselation *>
42
43#define LineMap multimap < int, class BoundaryLineSet * >
44#define LinePair pair < int, class BoundaryLineSet * >
45#define LineTestPair pair < LineMap::iterator, bool >
46
47#define TriangleMap map < int, class BoundaryTriangleSet * >
48#define TrianglePair pair < int, class BoundaryTriangleSet * >
49#define TriangleTestPair pair < TrianglePair::iterator, bool >
50
51#define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
52#define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
53
54
55
56template <typename T> void SetEndpointsOrdered(T endpoints[2], T endpoint1, T endpoint2)
57{
58 if (endpoint1->Nr < endpoint2->Nr) {
59 endpoints[0] = endpoint1;
60 endpoints[1] = endpoint2;
61 } else {
62 endpoints[0] = endpoint2;
63 endpoints[1] = endpoint1;
64 }
65};
66
67// ======================================================== class BoundaryPointSet =========================================
68
69class BoundaryPointSet {
70 public:
71 BoundaryPointSet();
72 BoundaryPointSet(TesselPoint *Walker);
73 ~BoundaryPointSet();
74
75 void AddLine(class BoundaryLineSet *line);
76
77 LineMap lines;
78 int LinesCount;
79 TesselPoint *node;
80 double value;
81 int Nr;
82};
83
84ostream & operator << (ostream &ost, BoundaryPointSet &a);
85
86// ======================================================== class BoundaryLineSet ==========================================
87
88class BoundaryLineSet {
89 public:
90 BoundaryLineSet();
91 BoundaryLineSet(class BoundaryPointSet *Point[2], int number);
92 ~BoundaryLineSet();
93
94 void AddTriangle(class BoundaryTriangleSet *triangle);
95 bool IsConnectedTo(class BoundaryLineSet *line);
96 bool ContainsBoundaryPoint(class BoundaryPointSet *point);
97 bool CheckConvexityCriterion(ofstream *out);
98 class BoundaryPointSet *GetOtherEndpoint(class BoundaryPointSet *);
99
100 class BoundaryPointSet *endpoints[2];
101 TriangleMap triangles;
102 int Nr;
103};
104
105ostream & operator << (ostream &ost, BoundaryLineSet &a);
106
107// ======================================================== class BoundaryTriangleSet =======================================
108
109class BoundaryTriangleSet {
110 public:
111 BoundaryTriangleSet();
112 BoundaryTriangleSet(class BoundaryLineSet *line[3], int number);
113 ~BoundaryTriangleSet();
114
115 void GetNormalVector(Vector &NormalVector);
116 bool GetIntersectionInsideTriangle(ofstream *out, Vector *MolCenter, Vector *x, Vector *Intersection);
117 bool ContainsBoundaryLine(class BoundaryLineSet *line);
118 bool ContainsBoundaryPoint(class BoundaryPointSet *point);
119 class BoundaryPointSet *GetThirdEndpoint(class BoundaryLineSet *line);
120 bool IsPresentTupel(class BoundaryPointSet *Points[3]);
121 void GetCenter(Vector *center);
122
123 class BoundaryPointSet *endpoints[3];
124 class BoundaryLineSet *lines[3];
125 Vector NormalVector;
126 int Nr;
127};
128
129ostream & operator << (ostream &ost, BoundaryTriangleSet &a);
130
131// =========================================================== class TESSELPOINT ===========================================
132
133/** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.
134 */
135class TesselPoint {
136public:
137 TesselPoint();
138 virtual ~TesselPoint();
139
140 Vector *node; // pointer to position of the dot in space
141 int nr; // index to easierly identify
142 char *Name; // some name to reference to on output
143
144 virtual ostream & operator << (ostream &ost);
145};
146
147ostream & operator << (ostream &ost, const TesselPoint &a);
148
149// =========================================================== class POINTCLOUD ============================================
150
151/** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.
152 * This basically encapsulates a list structure.
153 */
154class PointCloud {
155public:
156 PointCloud();
157 virtual ~PointCloud();
158
159 virtual Vector *GetCenter(ofstream *out) { return NULL; };
160 virtual TesselPoint *GetPoint() { return NULL; };
161 virtual TesselPoint *GetTerminalPoint() { return NULL; };
162 virtual void GoToNext() {};
163 virtual void GoToPrevious() {};
164 virtual void GoToFirst() {};
165 virtual void GoToLast() {};
166 virtual bool IsEmpty() { return false; };
167 virtual bool IsEnd() { return false; };
168};
169
170// ======================================================== class CandidateForTesselation =========================================
171
172class CandidateForTesselation {
173 public :
174 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
175 ~CandidateForTesselation();
176
177 TesselPoint *point;
178 BoundaryLineSet *BaseLine;
179 Vector OptCenter;
180 Vector OtherOptCenter;
181};
182
183// =========================================================== class TESSELATION ===========================================
184
185/** Contains the envelope to a PointCloud.
186 */
187class Tesselation : public PointCloud {
188 public:
189
190 Tesselation();
191 virtual ~Tesselation();
192
193 void AddTesselationPoint(TesselPoint* Candidate, int n);
194 void AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
195 void AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
196 void AddTesselationTriangle();
197 void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
198 void RemoveTesselationLine(class BoundaryLineSet *line);
199 void RemoveTesselationPoint(class BoundaryPointSet *point);
200
201 bool IsInside(Vector *pointer);
202 class BoundaryPointSet *GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2);
203
204 // concave envelope
205 void FindStartingTriangle(ofstream *out, const double RADIUS, class LinkedCell *LC);
206 void FindSecondPointForTesselation(class TesselPoint* a, class TesselPoint* Candidate, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, class LinkedCell *LC);
207 void FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, class LinkedCell *LC);
208 bool FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, LinkedCell *LC);
209 int CheckPresenceOfTriangle(ofstream *out, class TesselPoint *Candidates[3]);
210
211 // convex envelope
212 void TesselateOnBoundary(ofstream *out, PointCloud *cloud);
213 void GuessStartingTriangle(ofstream *out);
214 bool InsertStraddlingPoints(ofstream *out, PointCloud *cloud, LinkedCell *LC);
215 double RemovePointFromTesselatedSurface(ofstream *out, class BoundaryPointSet *point);
216 bool FlipBaseline(ofstream *out, class BoundaryLineSet *Base);
217 bool PickFarthestofTwoBaselines(ofstream *out, class BoundaryLineSet *Base);
218 class BoundaryPointSet *IsConvexRectangle(ofstream *out, class BoundaryLineSet *Base);
219
220
221 list<TesselPoint*> * GetCircleOfConnectedPoints(ofstream *out, TesselPoint* Point);
222 list<TesselPoint*> * GetNeighboursOnCircleOfConnectedPoints(ofstream *out, list<TesselPoint*> *connectedPoints, TesselPoint* Point, Vector* Reference);
223 list<BoundaryTriangleSet*> *FindTriangles(TesselPoint* Points[3]);
224 list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(ofstream *out, Vector *x, LinkedCell* LC);
225 class BoundaryTriangleSet * FindClosestTriangleToPoint(ofstream *out, Vector *x, LinkedCell* LC);
226 bool IsInnerPoint(ofstream *out, Vector Point, LinkedCell* LC);
227 bool IsInnerPoint(ofstream *out, TesselPoint *Point, LinkedCell* LC);
228 bool AddBoundaryPoint(TesselPoint *Walker, int n);
229
230 PointMap PointsOnBoundary;
231 LineMap LinesOnBoundary;
232 TriangleMap TrianglesOnBoundary;
233 int PointsOnBoundaryCount;
234 int LinesOnBoundaryCount;
235 int TrianglesOnBoundaryCount;
236
237 // PointCloud implementation for PointsOnBoundary
238 virtual Vector *GetCenter(ofstream *out);
239 virtual TesselPoint *GetPoint();
240 virtual TesselPoint *GetTerminalPoint();
241 virtual void GoToNext();
242 virtual void GoToPrevious();
243 virtual void GoToFirst();
244 virtual void GoToLast();
245 virtual bool IsEmpty();
246 virtual bool IsEnd();
247
248 class BoundaryPointSet *BPS[2];
249 class BoundaryLineSet *BLS[3];
250 class BoundaryTriangleSet *BTS;
251
252 private:
253 class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
254
255 PointMap::iterator InternalPointer;
256};
257
258bool CheckLineCriteriaForDegeneratedTriangle(class BoundaryPointSet *nodes[3]);
259bool SortCandidates(class CandidateForTesselation* candidate1, class CandidateForTesselation* candidate2);
260TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, LinkedCell* LC);
261TesselPoint* FindSecondClosestPoint(const Vector*, LinkedCell*);
262double GetAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector);
263Vector * GetClosestPointBetweenLine(ofstream *out, class BoundaryLineSet *Base, class BoundaryLineSet *OtherBase);
264
265#endif /* TESSELATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.