source: src/tesselation.hpp@ 0c5eeb

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 0c5eeb was a7b761b, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Merge branch 'MoleculeStartEndSwitch' into StructureRefactoring

Conflicts:

molecuilder/src/Helpers/Assert.cpp
molecuilder/src/Helpers/Assert.hpp
molecuilder/src/Legacy/oldmenu.cpp
molecuilder/src/Makefile.am
molecuilder/src/Patterns/Cacheable.hpp
molecuilder/src/Patterns/Observer.cpp
molecuilder/src/Patterns/Observer.hpp
molecuilder/src/analysis_correlation.cpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/helpers.hpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule.hpp
molecuilder/src/molecule_dynamics.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/ObserverTest.cpp
molecuilder/src/unittests/ObserverTest.hpp

  • Property mode set to 100644
File size: 15.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/*********************************************** includes ***********************************/
16
17// include config.h
18#ifdef HAVE_CONFIG_H
19#include <config.h>
20#endif
21
22#include <map>
23#include <list>
24#include <set>
25#include <stack>
26
27#include "atom_particleinfo.hpp"
28#include "helpers.hpp"
29#include "vector.hpp"
30
31/****************************************** forward declarations *****************************/
32
33class BoundaryPointSet;
34class BoundaryLineSet;
35class BoundaryTriangleSet;
36class LinkedCell;
37class TesselPoint;
38class PointCloud;
39class Tesselation;
40class Plane;
41
42/********************************************** definitions *********************************/
43
44#define DoTecplotOutput 1
45#define DoRaster3DOutput 1
46#define DoVRMLOutput 0
47#define TecplotSuffix ".dat"
48#define Raster3DSuffix ".r3d"
49#define VRMLSUffix ".wrl"
50
51#define ParallelEpsilon 1e-3
52
53// ======================================================= some template functions =========================================
54
55#define IndexToIndex map <int, int>
56
57#define PointMap map < int, class BoundaryPointSet * >
58#define PointSet set < class BoundaryPointSet * >
59#define PointList list < class BoundaryPointSet * >
60#define PointPair pair < int, class BoundaryPointSet * >
61#define PointTestPair pair < PointMap::iterator, bool >
62
63#define CandidateList list <class CandidateForTesselation *>
64#define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>
65
66#define LineMap multimap < int, class BoundaryLineSet * >
67#define LineSet set < class BoundaryLineSet * >
68#define LineList list < class BoundaryLineSet * >
69#define LinePair pair < int, class BoundaryLineSet * >
70#define LineTestPair pair < LineMap::iterator, bool >
71
72#define TriangleMap map < int, class BoundaryTriangleSet * >
73#define TriangleSet set < class BoundaryTriangleSet * >
74#define TriangleList list < class BoundaryTriangleSet * >
75#define TrianglePair pair < int, class BoundaryTriangleSet * >
76#define TriangleTestPair pair < TrianglePair::iterator, bool >
77
78#define PolygonMap map < int, class BoundaryPolygonSet * >
79#define PolygonSet set < class BoundaryPolygonSet * >
80#define PolygonList list < class BoundaryPolygonSet * >
81
82#define DistanceToPointMap multimap <double, class BoundaryPointSet * >
83#define DistanceToPointPair pair <double, class BoundaryPointSet * >
84
85#define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
86#define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
87
88#define TesselPointList list <TesselPoint *>
89#define TesselPointSet set <TesselPoint *>
90
91#define ListOfTesselPointList list<list <TesselPoint *> *>
92
93enum centers {Opt, OtherOpt};
94
95/********************************************** declarations *******************************/
96
97template <typename T> void SetEndpointsOrdered(T endpoints[2], T endpoint1, T endpoint2)
98{
99 if (endpoint1->Nr < endpoint2->Nr) {
100 endpoints[0] = endpoint1;
101 endpoints[1] = endpoint2;
102 } else {
103 endpoints[0] = endpoint2;
104 endpoints[1] = endpoint1;
105 }
106};
107
108// ======================================================== class BoundaryPointSet =========================================
109
110class BoundaryPointSet {
111 public:
112 BoundaryPointSet();
113 BoundaryPointSet(TesselPoint * const Walker);
114 ~BoundaryPointSet();
115
116 void AddLine(BoundaryLineSet * const line);
117
118 LineMap lines;
119 int LinesCount;
120 TesselPoint *node;
121 double value;
122 int Nr;
123};
124
125ostream & operator << (ostream &ost, const BoundaryPointSet &a);
126
127// ======================================================== class BoundaryLineSet ==========================================
128
129class BoundaryLineSet {
130 public:
131 BoundaryLineSet();
132 BoundaryLineSet(BoundaryPointSet * const Point[2], const int number);
133 BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number);
134 ~BoundaryLineSet();
135
136 void AddTriangle(BoundaryTriangleSet * const triangle);
137 bool IsConnectedTo(const BoundaryLineSet * const line) const;
138 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
139 bool CheckConvexityCriterion() const;
140 class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;
141
142 class BoundaryPointSet *endpoints[2];
143 TriangleMap triangles;
144 int Nr;
145 bool skipped;
146};
147
148ostream & operator << (ostream &ost, const BoundaryLineSet &a);
149
150// ======================================================== class BoundaryTriangleSet =======================================
151
152class BoundaryTriangleSet {
153 public:
154 BoundaryTriangleSet();
155 BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);
156 ~BoundaryTriangleSet();
157
158 void GetNormalVector(const Vector &NormalVector);
159 void GetCenter(Vector * const center) const;
160 bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const;
161 double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const;
162 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
163 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
164 bool ContainsBoundaryPoint(const TesselPoint * const point) const;
165 class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;
166 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
167 bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
168
169 Plane getPlane() const;
170 Vector getEndpoint(int) const;
171 std::string getEndpointName(int) const;
172
173 class BoundaryPointSet *endpoints[3];
174 class BoundaryLineSet *lines[3];
175 Vector NormalVector;
176 Vector SphereCenter;
177 int Nr;
178
179 private:
180
181};
182
183ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);
184
185
186// ======================================================== class BoundaryTriangleSet =======================================
187
188/** Set of BoundaryPointSet.
189 * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has
190 * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation
191 * class (i.e. no allocation, no deletion).
192 * \note we assume that the set of endpoints reside (more or less) on a plane.
193 */
194class BoundaryPolygonSet {
195 public:
196 BoundaryPolygonSet();
197 ~BoundaryPolygonSet();
198
199 Vector * GetNormalVector(const Vector &NormalVector) const;
200 void GetCenter(Vector *center) const;
201 bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
202 bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
203 bool ContainsBoundaryPoint(const TesselPoint * const point) const;
204 bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;
205 bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;
206 bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;
207 bool ContainsPresentTupel(const PointSet &endpoints) const;
208 TriangleSet * GetAllContainedTrianglesFromEndpoints() const;
209 bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);
210
211 PointSet endpoints;
212 int Nr;
213};
214
215ostream & operator << (ostream &ost, const BoundaryPolygonSet &a);
216
217// =========================================================== class TESSELPOINT ===========================================
218
219/** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.
220 */
221class TesselPoint : virtual public ParticleInfo {
222public:
223 TesselPoint();
224 virtual ~TesselPoint();
225
226 Vector *node; // pointer to position of the dot in space
227
228 virtual ostream & operator << (ostream &ost);
229};
230
231ostream & operator << (ostream &ost, const TesselPoint &a);
232
233// =========================================================== class POINTCLOUD ============================================
234
235/** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.
236 * This basically encapsulates a list structure.
237 */
238class PointCloud {
239public:
240 PointCloud();
241 virtual ~PointCloud();
242
243 virtual const char * const GetName() const { return "unknown"; };
244 virtual Vector *GetCenter() const { return NULL; };
245 virtual TesselPoint *GetPoint() const { return NULL; };
246 virtual int GetMaxId() const { return 0; };
247 virtual void GoToNext() const {};
248 virtual void GoToFirst() const {};
249 virtual bool IsEmpty() const { return true; };
250 virtual bool IsEnd() const { return true; };
251};
252
253// ======================================================== class CandidateForTesselation =========================================
254
255class CandidateForTesselation {
256 public :
257 CandidateForTesselation(BoundaryLineSet* currentBaseLine);
258 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
259 ~CandidateForTesselation();
260
261 bool CheckValidity(const double RADIUS, const LinkedCell *LC) const;
262
263 TesselPointList pointlist;
264 const BoundaryLineSet * BaseLine;
265 const BoundaryPointSet * ThirdPoint;
266 const BoundaryTriangleSet *T;
267 Vector OldCenter;
268 Vector OptCenter;
269 Vector OtherOptCenter;
270 double ShortestAngle;
271 double OtherShortestAngle;
272};
273
274ostream & operator <<(ostream &ost, const CandidateForTesselation &a);
275
276// =========================================================== class TESSELATION ===========================================
277
278/** Contains the envelope to a PointCloud.
279 */
280class Tesselation : public PointCloud {
281 public:
282
283 Tesselation();
284 virtual ~Tesselation();
285
286 void AddTesselationPoint(TesselPoint* Candidate, const int n);
287 void SetTesselationPoint(TesselPoint* Candidate, const int n) const;
288 void AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
289 void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
290 void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n);
291 void AddTesselationTriangle();
292 void AddTesselationTriangle(const int nr);
293 void AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type);
294 void AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC);
295 void AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC);
296 void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
297 void RemoveTesselationLine(class BoundaryLineSet *line);
298 void RemoveTesselationPoint(class BoundaryPointSet *point);
299 bool CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const;
300
301
302 // concave envelope
303 bool FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
304 void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
305 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;
306 bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
307 bool FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList);
308 int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
309 class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]);
310
311 // convex envelope
312 void TesselateOnBoundary(const PointCloud * const cloud);
313 void GuessStartingTriangle();
314 bool InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC);
315 double RemovePointFromTesselatedSurface(class BoundaryPointSet *point);
316 class BoundaryLineSet * FlipBaseline(class BoundaryLineSet *Base);
317 double PickFarthestofTwoBaselines(class BoundaryLineSet *Base);
318 class BoundaryPointSet *IsConvexRectangle(class BoundaryLineSet *Base);
319 IndexToIndex * FindAllDegeneratedTriangles();
320 IndexToIndex * FindAllDegeneratedLines();
321 void RemoveDegeneratedTriangles();
322 void AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC);
323 int CorrectAllDegeneratedPolygons();
324
325 TesselPointSet * GetAllConnectedPoints(const TesselPoint* const Point) const;
326 TriangleSet * GetAllTriangles(const BoundaryPointSet * const Point) const;
327 ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const;
328 ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const;
329 TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const;
330 TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const;
331 class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const;
332 TriangleList * FindTriangles(const TesselPoint* const Points[3]) const;
333 TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const;
334 BoundaryTriangleSet * FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const;
335 bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
336 double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const;
337 double GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const;
338 BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const;
339 bool AddBoundaryPoint(TesselPoint * Walker, const int n);
340 DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;
341 BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const;
342
343 // print for debugging
344 void PrintAllBoundaryPoints(ofstream *out) const;
345 void PrintAllBoundaryLines(ofstream *out) const;
346 void PrintAllBoundaryTriangles(ofstream *out) const;
347
348 // store envelope in file
349 void Output(const char *filename, const PointCloud * const cloud);
350
351 PointMap PointsOnBoundary;
352 LineMap LinesOnBoundary;
353 CandidateMap OpenLines;
354 TriangleMap TrianglesOnBoundary;
355 int PointsOnBoundaryCount;
356 int LinesOnBoundaryCount;
357 int TrianglesOnBoundaryCount;
358
359 // PointCloud implementation for PointsOnBoundary
360 virtual Vector *GetCenter(ofstream *out) const;
361 virtual TesselPoint *GetPoint() const;
362 virtual void GoToNext() const;
363 virtual void GoToFirst() const;
364 virtual bool IsEmpty() const;
365 virtual bool IsEnd() const;
366
367 class BoundaryPointSet *BPS[2];
368 class BoundaryLineSet *BLS[3];
369 class BoundaryTriangleSet *BTS;
370 class BoundaryTriangleSet *LastTriangle;
371 int TriangleFilesWritten;
372
373 private:
374 mutable class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
375
376 mutable PointMap::const_iterator InternalPointer;
377
378 //bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const;
379 void FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter);
380};
381
382
383#endif /* TESSELATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.