source: src/tesselation.hpp@ e4a379

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

Various fixes and attempt to get convex hull working.

Moved tesselation writing to tesselation.cpp

  • WriteVrmlFile(), WriteRaster3dFile(), WriteTecplotFile() moved to tesselation.cpp
  • these also don't use molecule anymore, but the PointCloud structure (hence, bonds are no more visible)
  • new function TesselStruct::Output() which performs the writing
  • new function InsertSphereInRaster3D(), which places a sphere at the position of the last triangle
  • Property mode set to 100644
File size: 10.5 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 class BoundaryPointSet *GetThirdEndpoint(class BoundaryLineSet *line);
129 bool IsPresentTupel(class BoundaryPointSet *Points[3]);
130 bool IsPresentTupel(class BoundaryTriangleSet *T);
131
132 class BoundaryPointSet *endpoints[3];
133 class BoundaryLineSet *lines[3];
134 Vector NormalVector;
135 int Nr;
136};
137
138ostream & operator << (ostream &ost, BoundaryTriangleSet &a);
139
140// =========================================================== class TESSELPOINT ===========================================
141
142/** Is a single point of the set of Vectors, also a super-class to be inherited and and its functions to be implemented.
143 */
144class TesselPoint {
145public:
146 TesselPoint();
147 virtual ~TesselPoint();
148
149 Vector *node; // pointer to position of the dot in space
150 int nr; // index to easierly identify
151 char *Name; // some name to reference to on output
152
153 virtual ostream & operator << (ostream &ost);
154};
155
156ostream & operator << (ostream &ost, const TesselPoint &a);
157
158// =========================================================== class POINTCLOUD ============================================
159
160/** Super-class for all point clouds structures, also molecules. They have to inherit this structure and implement the virtual function to access the Vectors.
161 * This basically encapsulates a list structure.
162 */
163class PointCloud {
164public:
165 PointCloud();
166 virtual ~PointCloud();
167
168 virtual Vector *GetCenter(ofstream *out) { return NULL; };
169 virtual TesselPoint *GetPoint() { return NULL; };
170 virtual TesselPoint *GetTerminalPoint() { return NULL; };
171 virtual void GoToNext() {};
172 virtual void GoToPrevious() {};
173 virtual void GoToFirst() {};
174 virtual void GoToLast() {};
175 virtual bool IsEmpty() { return false; };
176 virtual bool IsEnd() { return false; };
177};
178
179// ======================================================== class CandidateForTesselation =========================================
180
181class CandidateForTesselation {
182 public :
183 CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
184 ~CandidateForTesselation();
185
186 TesselPoint *point;
187 BoundaryLineSet *BaseLine;
188 Vector OptCenter;
189 Vector OtherOptCenter;
190};
191
192// =========================================================== class TESSELATION ===========================================
193
194/** Contains the envelope to a PointCloud.
195 */
196class Tesselation : public PointCloud {
197 public:
198
199 Tesselation();
200 virtual ~Tesselation();
201
202 void AddTesselationPoint(TesselPoint* Candidate, int n);
203 void AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
204 void AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, int n);
205 void AddTesselationTriangle();
206 void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
207 void RemoveTesselationLine(class BoundaryLineSet *line);
208 void RemoveTesselationPoint(class BoundaryPointSet *point);
209
210 class BoundaryPointSet *GetCommonEndpoint(class BoundaryLineSet * line1, class BoundaryLineSet * line2);
211
212 // concave envelope
213 void FindStartingTriangle(ofstream *out, const double RADIUS, class LinkedCell *LC);
214 void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, class LinkedCell *LC);
215 void FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, class LinkedCell *LC);
216 bool FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, LinkedCell *LC);
217 int CheckPresenceOfTriangle(ofstream *out, class TesselPoint *Candidates[3]);
218 class BoundaryTriangleSet * GetPresentTriangle(ofstream *out, TesselPoint *Candidates[3]);
219
220 // convex envelope
221 void TesselateOnBoundary(ofstream *out, PointCloud *cloud);
222 void GuessStartingTriangle(ofstream *out);
223 bool InsertStraddlingPoints(ofstream *out, PointCloud *cloud, LinkedCell *LC);
224 double RemovePointFromTesselatedSurface(ofstream *out, class BoundaryPointSet *point);
225 class BoundaryLineSet * FlipBaseline(ofstream *out, class BoundaryLineSet *Base);
226 double PickFarthestofTwoBaselines(ofstream *out, class BoundaryLineSet *Base);
227 class BoundaryPointSet *IsConvexRectangle(ofstream *out, class BoundaryLineSet *Base);
228 map<int, int> * FindAllDegeneratedTriangles();
229 map<int, int> * FindAllDegeneratedLines();
230 void RemoveDegeneratedTriangles();
231 void AddBoundaryPointByDegeneratedTriangle(ofstream *out, class TesselPoint *point, LinkedCell *LC);
232
233 set<TesselPoint*> * GetAllConnectedPoints(ofstream *out, TesselPoint* Point);
234 set<BoundaryTriangleSet*> *GetAllTriangles(ofstream *out, class BoundaryPointSet *Point);
235 list<list<TesselPoint*> *> * GetPathsOfConnectedPoints(ofstream *out, TesselPoint* Point);
236 list<list<TesselPoint*> *> * GetClosedPathsOfConnectedPoints(ofstream *out, TesselPoint* Point);
237 list<TesselPoint*> * GetCircleOfConnectedPoints(ofstream *out, TesselPoint* Point, Vector *Reference = NULL);
238 list<BoundaryTriangleSet*> *FindTriangles(TesselPoint* Points[3]);
239 list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(ofstream *out, Vector *x, LinkedCell* LC);
240 class BoundaryTriangleSet * FindClosestTriangleToPoint(ofstream *out, Vector *x, LinkedCell* LC);
241 bool IsInnerPoint(ofstream *out, Vector Point, LinkedCell* LC);
242 bool IsInnerPoint(ofstream *out, TesselPoint *Point, LinkedCell* LC);
243 bool AddBoundaryPoint(TesselPoint *Walker, int n);
244
245 // print for debugging
246 void PrintAllBoundaryPoints(ofstream *out);
247 void PrintAllBoundaryLines(ofstream *out);
248 void PrintAllBoundaryTriangles(ofstream *out);
249
250 // store envelope in file
251 void Output(ofstream *out, const char *filename, PointCloud *cloud);
252
253 PointMap PointsOnBoundary;
254 LineMap LinesOnBoundary;
255 TriangleMap TrianglesOnBoundary;
256 int PointsOnBoundaryCount;
257 int LinesOnBoundaryCount;
258 int TrianglesOnBoundaryCount;
259
260 // PointCloud implementation for PointsOnBoundary
261 virtual Vector *GetCenter(ofstream *out);
262 virtual TesselPoint *GetPoint();
263 virtual TesselPoint *GetTerminalPoint();
264 virtual void GoToNext();
265 virtual void GoToPrevious();
266 virtual void GoToFirst();
267 virtual void GoToLast();
268 virtual bool IsEmpty();
269 virtual bool IsEnd();
270
271 class BoundaryPointSet *BPS[2];
272 class BoundaryLineSet *BLS[3];
273 class BoundaryTriangleSet *BTS;
274 class BoundaryTriangleSet *LastTriangle;
275 int TriangleFilesWritten;
276
277 private:
278 class BoundaryPointSet *TPS[3]; //this is a Storage for pointers to triangle points, this and BPS[2] needed due to AddLine restrictions
279
280 PointMap::iterator InternalPointer;
281};
282
283
284#endif /* TESSELATION_HPP_ */
Note: See TracBrowser for help on using the repository browser.