source: src/tesselation.hpp@ 1999d8

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 1999d8 was 1999d8, checked in by Frederik Heber <heber@…>, 16 years ago

BUGFIX: PointCloud implementation in molecule stopped one before last, IsLast() -> IsEnd()

  • Property mode set to 100644
File size: 8.7 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 int Nr;
81};
82
83ostream & operator << (ostream &ost, BoundaryPointSet &a);
84
85// ======================================================== class BoundaryLineSet ==========================================
86
87class BoundaryLineSet {
88 public:
89 BoundaryLineSet();
90 BoundaryLineSet(class BoundaryPointSet *Point[2], int number);
91 ~BoundaryLineSet();
92
93 void AddTriangle(class BoundaryTriangleSet *triangle);
94 bool IsConnectedTo(class BoundaryLineSet *line);
95 bool ContainsBoundaryPoint(class BoundaryPointSet *point);
96 bool CheckConvexityCriterion(ofstream *out);
97 class BoundaryPointSet *GetOtherEndpoint(class BoundaryPointSet *);
98
99 class BoundaryPointSet *endpoints[2];
100 TriangleMap triangles;
101 int TrianglesCount;
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 ~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
145ostream & operator << (ostream &ost, const TesselPoint &a);
146
147// =========================================================== class POINTCLOUD ============================================
148
149/** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.
150 * This basically encapsulates a list structure.
151 */
152class PointCloud {
153public:
154 PointCloud();
155 virtual ~PointCloud();
156
157 virtual Vector *GetCenter(ofstream *out) { return NULL; };
158 virtual TesselPoint *GetPoint() { return NULL; };
159 virtual TesselPoint *GetTerminalPoint() { return NULL; };
160 virtual void GoToNext() {};
161 virtual void GoToPrevious() {};
162 virtual void GoToFirst() {};
163 virtual void GoToLast() {};
164 virtual bool IsEmpty() { return false; };
165 virtual bool IsEnd() { return false; };
166};
167
168// ======================================================== class CandidateForTesselation =========================================
169
170class CandidateForTesselation {
171 public :
172 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
173 ~CandidateForTesselation();
174
175 TesselPoint *point;
176 BoundaryLineSet *BaseLine;
177 Vector OptCenter;
178 Vector OtherOptCenter;
179};
180
181// =========================================================== class TESSELATION ===========================================
182
183/** Contains the envelope to a PointCloud.
184 */
185class Tesselation {
186 public:
187
188 Tesselation();
189 ~Tesselation();
190
191 void AddPoint(TesselPoint *Walker);
192 void AddTrianglePoint(TesselPoint* Candidate, int n);
193 void AddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
194 void AlwaysAddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
195 void AddTriangle();
196 bool IsInside(Vector *pointer);
197 class BoundaryPointSet *GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2);
198
199 // concave envelope
200 void Find_starting_triangle(ofstream *out, const double RADIUS, class LinkedCell *LC);
201 void Find_second_point_for_Tesselation(class TesselPoint* a, class TesselPoint* Candidate, Vector Oben, class TesselPoint*& Opt_Candidate, double Storage[3], double RADIUS, class LinkedCell *LC);
202 void Find_third_point_for_Tesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, class LinkedCell *LC);
203 bool Find_next_suitable_triangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, LinkedCell *LC);
204 int CheckPresenceOfTriangle(ofstream *out, class TesselPoint *Candidates[3]);
205
206 // convex envelope
207 void TesselateOnBoundary(ofstream *out, PointCloud *cloud);
208 void GuessStartingTriangle(ofstream *out);
209 bool InsertStraddlingPoints(ofstream *out, PointCloud *cloud, LinkedCell *LC);
210 bool CorrectConcaveBaselines(ofstream *out);
211
212 list<TesselPoint*> * getCircleOfConnectedPoints(ofstream *out, TesselPoint* Point, Vector* Reference);
213 list<BoundaryTriangleSet*> *FindTriangles(TesselPoint* Points[3]);
214 list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(ofstream *out, Vector *x, LinkedCell* LC);
215 class BoundaryTriangleSet * FindClosestTriangleToPoint(ofstream *out, Vector *x, LinkedCell* LC);
216 bool IsInnerPoint(ofstream *out, Vector Point, LinkedCell* LC);
217 bool IsInnerPoint(ofstream *out, TesselPoint *Point, LinkedCell* LC);
218
219 PointMap PointsOnBoundary;
220 LineMap LinesOnBoundary;
221 TriangleMap TrianglesOnBoundary;
222 int PointsOnBoundaryCount;
223 int LinesOnBoundaryCount;
224 int TrianglesOnBoundaryCount;
225
226 private:
227 class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
228 class BoundaryPointSet *BPS[2];
229 class BoundaryLineSet *BLS[3];
230 class BoundaryTriangleSet *BTS;
231};
232
233bool CheckLineCriteriaforDegeneratedTriangle(class BoundaryPointSet *nodes[3]);
234bool sortCandidates(class CandidateForTesselation* candidate1, class CandidateForTesselation* candidate2);
235TesselPoint* findClosestPoint(const Vector* Point, LinkedCell* LC);
236double getAngle(const Vector &point, const Vector &reference, const Vector &center, Vector OrthogonalVector);
237
238#endif /* TESSELATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.