source: src/tesselation.hpp@ c26f44

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

Fixes to the (Non)ConvexTesselation, working with 1_2_dimethoxyethylene

minor changes:

major changes:

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