source: src/tesselation.hpp@ edb93c

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

Huge refactoring of Tesselation routines, but not finished yet.

  • new file tesselation.cpp with all of classes tesselation, Boundary..Set and CandidatesForTesselationOB
  • new file tesselationhelper.cpp with all auxiliary functions.
  • boundary.cpp just contains super functions, combininb molecule and Tesselation pointers
  • new pointer molecule::TesselStruct
  • PointMap, LineMap, TriangleMap DistanceMap have been moved from molecules.hpp to tesselation.hpp
  • new abstract class PointCloud and TesselPoint
  • atom inherits TesselPoint
  • molecule inherits PointCloud (i.e. a set of TesselPoints) and implements all virtual functions for the chained list
  • TriangleFilesWritten is thrown out, intermediate steps are written in find_nonconvex_border and not in find_next_triangle()
  • LinkedCell class uses TesselPoint as its nodes, i.e. as long as any class inherits TesselPoint, it may make use of LinkedCell as well and a PointCloud is used to initialize
  • class atom and bond definitions have been moved to own header files

NOTE: This is not bugfree yet. Tesselation of heptan produces way too many triangles, but runs without faults or leaks.

  • Property mode set to 100644
File size: 7.9 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
98 class BoundaryPointSet *endpoints[2];
99 TriangleMap triangles;
100 int TrianglesCount;
101 int Nr;
102};
103
104ostream & operator << (ostream &ost, BoundaryLineSet &a);
105
106// ======================================================== class BoundaryTriangleSet =======================================
107
108class BoundaryTriangleSet {
109 public:
110 BoundaryTriangleSet();
111 BoundaryTriangleSet(class BoundaryLineSet *line[3], int number);
112 ~BoundaryTriangleSet();
113
114 void GetNormalVector(Vector &NormalVector);
115 bool GetIntersectionInsideTriangle(ofstream *out, Vector *MolCenter, Vector *x, Vector *Intersection);
116 bool ContainsBoundaryLine(class BoundaryLineSet *line);
117 bool ContainsBoundaryPoint(class BoundaryPointSet *point);
118 bool IsPresentTupel(class BoundaryPointSet *Points[3]);
119
120 class BoundaryPointSet *endpoints[3];
121 class BoundaryLineSet *lines[3];
122 Vector NormalVector;
123 int Nr;
124};
125
126ostream & operator << (ostream &ost, BoundaryTriangleSet &a);
127
128// =========================================================== class TESSELPOINT ===========================================
129
130/** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.
131 */
132class TesselPoint {
133public:
134 TesselPoint();
135 ~TesselPoint();
136
137 Vector *node; // pointer to position of the dot in space
138 int nr; // index to easierly identify
139 char *Name; // some name to reference to on output
140};
141
142ostream & operator << (ostream &ost, const TesselPoint &a);
143
144// =========================================================== class POINTCLOUD ============================================
145
146/** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.
147 * This basically encapsulates a list structure.
148 */
149class PointCloud {
150public:
151 PointCloud();
152 ~PointCloud();
153
154 virtual Vector *GetCenter(ofstream *out) { return NULL; };
155 virtual TesselPoint *GetPoint() { return NULL; };
156 virtual TesselPoint *GetTerminalPoint() { return NULL; };
157 virtual void GoToNext() {};
158 virtual void GoToPrevious() {};
159 virtual void GoToFirst() {};
160 virtual void GoToLast() {};
161 virtual bool IsEmpty() { return false; };
162 virtual bool IsLast() { return false; };
163};
164
165// ======================================================== class CandidateForTesselation =========================================
166
167class CandidateForTesselation {
168 public :
169 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
170 ~CandidateForTesselation();
171
172 TesselPoint *point;
173 BoundaryLineSet *BaseLine;
174 Vector OptCenter;
175 Vector OtherOptCenter;
176};
177
178// =========================================================== class TESSELATION ===========================================
179
180/** Contains the envelope to a PointCloud.
181 */
182class Tesselation {
183 public:
184
185 Tesselation();
186 ~Tesselation();
187
188 void AddPoint(TesselPoint *Walker);
189 void AddTrianglePoint(TesselPoint* Candidate, int n);
190 void AddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
191 void AlwaysAddTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
192 void AddTriangle();
193 bool IsInside(Vector *pointer);
194 class BoundaryPointSet *GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2);
195
196 // concave envelope
197 void Find_starting_triangle(ofstream *out, const double RADIUS, class LinkedCell *LC);
198 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);
199 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);
200 bool Find_next_suitable_triangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, LinkedCell *LC);
201 int CheckPresenceOfTriangle(ofstream *out, class TesselPoint *Candidates[3]);
202
203 // convex envelope
204 class BoundaryTriangleSet * FindClosestTriangleToPoint(ofstream *out, Vector *x);
205 void TesselateOnBoundary(ofstream *out, PointCloud *cloud);
206 void GuessStartingTriangle(ofstream *out);
207 bool InsertStraddlingPoints(ofstream *out, PointCloud *cloud);
208 bool CorrectConcaveBaselines(ofstream *out);
209
210 PointMap PointsOnBoundary;
211 LineMap LinesOnBoundary;
212 TriangleMap TrianglesOnBoundary;
213 int PointsOnBoundaryCount;
214 int LinesOnBoundaryCount;
215 int TrianglesOnBoundaryCount;
216
217 private:
218 class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
219 class BoundaryPointSet *BPS[2];
220 class BoundaryLineSet *BLS[3];
221 class BoundaryTriangleSet *BTS;
222};
223
224bool CheckLineCriteriaforDegeneratedTriangle(class BoundaryPointSet *nodes[3]);
225bool sortCandidates(class CandidateForTesselation* candidate1, class CandidateForTesselation* candidate2);
226
227
228#endif /* TESSELATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.