source: src/tesselationhelpers.cpp@ d74077

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

Member variable Vector and element of class atom are now private.

  • Property mode set to 100644
File size: 39.5 KB
Line 
1/*
2 * TesselationHelpers.cpp
3 *
4 * Created on: Aug 3, 2009
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include <fstream>
11
12#include "BoundaryLineSet.hpp"
13#include "BoundaryPointSet.hpp"
14#include "BoundaryPolygonSet.hpp"
15#include "BoundaryTriangleSet.hpp"
16#include "CandidateForTesselation.hpp"
17#include "info.hpp"
18#include "linkedcell.hpp"
19#include "linearsystemofequations.hpp"
20#include "log.hpp"
21#include "tesselation.hpp"
22#include "tesselationhelpers.hpp"
23#include "vector.hpp"
24#include "Line.hpp"
25#include "vector_ops.hpp"
26#include "verbose.hpp"
27#include "Plane.hpp"
28#include "Matrix.hpp"
29
30void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
31{
32 Info FunctionInfo(__func__);
33 Matrix mat;
34 double m11, m12, m13, m14;
35
36 for(int i=0;i<3;i++) {
37 mat.set(i, 0, a[i]);
38 mat.set(i, 1, b[i]);
39 mat.set(i, 2, c[i]);
40 }
41 m11 = mat.determinant();
42
43 for(int i=0;i<3;i++) {
44 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
45 mat.set(i, 1, b[i]);
46 mat.set(i, 2, c[i]);
47 }
48 m12 = mat.determinant();
49
50 for(int i=0;i<3;i++) {
51 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
52 mat.set(i, 1, a[i]);
53 mat.set(i, 2, c[i]);
54 }
55 m13 = mat.determinant();
56
57 for(int i=0;i<3;i++) {
58 mat.set(i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
59 mat.set(i, 1, a[i]);
60 mat.set(i, 2, b[i]);
61 }
62 m14 = mat.determinant();
63
64 if (fabs(m11) < MYEPSILON)
65 DoeLog(1) && (eLog()<< Verbose(1) << "three points are colinear." << endl);
66
67 center->at(0) = 0.5 * m12/ m11;
68 center->at(1) = -0.5 * m13/ m11;
69 center->at(2) = 0.5 * m14/ m11;
70
71 if (fabs(a.distance(*center) - RADIUS) > MYEPSILON)
72 DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.distance(*center) - RADIUS) << " from a than RADIUS." << endl);
73};
74
75
76
77/**
78 * Function returns center of sphere with RADIUS, which rests on points a, b, c
79 * @param Center this vector will be used for return
80 * @param a vector first point of triangle
81 * @param b vector second point of triangle
82 * @param c vector third point of triangle
83 * @param *Umkreismittelpunkt new center point of circumference
84 * @param Direction vector indicates up/down
85 * @param AlternativeDirection Vector, needed in case the triangles have 90 deg angle
86 * @param Halfplaneindicator double indicates whether Direction is up or down
87 * @param AlternativeIndicator double indicates in case of orthogonal triangles which direction of AlternativeDirection is suitable
88 * @param alpha double angle at a
89 * @param beta double, angle at b
90 * @param gamma, double, angle at c
91 * @param Radius, double
92 * @param Umkreisradius double radius of circumscribing circle
93 */
94void GetCenterOfSphere(Vector* const & Center, const Vector &a, const Vector &b, const Vector &c, Vector * const NewUmkreismittelpunkt, const Vector* const Direction, const Vector* const AlternativeDirection,
95 const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius)
96{
97 Info FunctionInfo(__func__);
98 Vector TempNormal, helper;
99 double Restradius;
100 Vector OtherCenter;
101 Center->Zero();
102 helper = sin(2.*alpha) * a;
103 (*Center) += helper;
104 helper = sin(2.*beta) * b;
105 (*Center) += helper;
106 helper = sin(2.*gamma) * c;
107 (*Center) += helper;
108 //*Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ;
109 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
110 (*NewUmkreismittelpunkt) = (*Center);
111 DoLog(1) && (Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n");
112 // Here we calculated center of circumscribing circle, using barycentric coordinates
113 DoLog(1) && (Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n");
114
115 TempNormal = a - b;
116 helper = a - c;
117 TempNormal.VectorProduct(helper);
118 if (fabs(HalfplaneIndicator) < MYEPSILON)
119 {
120 if ((TempNormal.ScalarProduct(*AlternativeDirection) <0 && AlternativeIndicator >0) || (TempNormal.ScalarProduct(*AlternativeDirection) >0 && AlternativeIndicator <0))
121 {
122 TempNormal *= -1;
123 }
124 }
125 else
126 {
127 if (((TempNormal.ScalarProduct(*Direction)<0) && (HalfplaneIndicator >0)) || ((TempNormal.ScalarProduct(*Direction)>0) && (HalfplaneIndicator<0)))
128 {
129 TempNormal *= -1;
130 }
131 }
132
133 TempNormal.Normalize();
134 Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
135 DoLog(1) && (Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n");
136 TempNormal.Scale(Restradius);
137 DoLog(1) && (Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n");
138 (*Center) += TempNormal;
139 DoLog(1) && (Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n");
140 GetSphere(&OtherCenter, a, b, c, RADIUS);
141 DoLog(1) && (Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n");
142};
143
144
145/** Constructs the center of the circumcircle defined by three points \a *a, \a *b and \a *c.
146 * \param *Center new center on return
147 * \param *a first point
148 * \param *b second point
149 * \param *c third point
150 */
151void GetCenterofCircumcircle(Vector &Center, const Vector &a, const Vector &b, const Vector &c)
152{
153 Info FunctionInfo(__func__);
154 Vector helper;
155 Vector SideA = b - c;
156 Vector SideB = c - a;
157 Vector SideC = a - b;
158
159 helper[0] = SideA.NormSquared()*(SideB.NormSquared()+SideC.NormSquared() - SideA.NormSquared());
160 helper[1] = SideB.NormSquared()*(SideC.NormSquared()+SideA.NormSquared() - SideB.NormSquared());
161 helper[2] = SideC.NormSquared()*(SideA.NormSquared()+SideB.NormSquared() - SideC.NormSquared());
162
163 Center.Zero();
164 Center += helper[0] * a;
165 Center += helper[1] * b;
166 Center += helper[2] * c;
167 Center.Scale(1./(helper[0]+helper[1]+helper[2]));
168 Log() << Verbose(1) << "INFO: Center (2nd algo) is at " << Center << "." << endl;
169};
170
171/** Returns the parameter "path length" for a given \a NewSphereCenter relative to \a OldSphereCenter on a circle on the plane \a CirclePlaneNormal with center \a CircleCenter and radius \a CircleRadius.
172 * Test whether the \a NewSphereCenter is really on the given plane and in distance \a CircleRadius from \a CircleCenter.
173 * It calculates the angle, making it unique on [0,2.*M_PI) by comparing to SearchDirection.
174 * Also the new center is invalid if it the same as the old one and does not lie right above (\a NormalVector) the base line (\a CircleCenter).
175 * \param CircleCenter Center of the parameter circle
176 * \param CirclePlaneNormal normal vector to plane of the parameter circle
177 * \param CircleRadius radius of the parameter circle
178 * \param NewSphereCenter new center of a circumcircle
179 * \param OldSphereCenter old center of a circumcircle, defining the zero "path length" on the parameter circle
180 * \param NormalVector normal vector
181 * \param SearchDirection search direction to make angle unique on return.
182 * \return Angle between \a NewSphereCenter and \a OldSphereCenter relative to \a CircleCenter, 2.*M_PI if one test fails
183 */
184double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection)
185{
186 Info FunctionInfo(__func__);
187 Vector helper;
188 double radius, alpha;
189
190 Vector RelativeOldSphereCenter = OldSphereCenter - CircleCenter;
191 Vector RelativeNewSphereCenter = NewSphereCenter - CircleCenter;
192 helper = RelativeNewSphereCenter;
193 // test whether new center is on the parameter circle's plane
194 if (fabs(helper.ScalarProduct(CirclePlaneNormal)) > HULLEPSILON) {
195 DoeLog(1) && (eLog()<< Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(CirclePlaneNormal)) << "!" << endl);
196 helper.ProjectOntoPlane(CirclePlaneNormal);
197 }
198 radius = helper.NormSquared();
199 // test whether the new center vector has length of CircleRadius
200 if (fabs(radius - CircleRadius) > HULLEPSILON)
201 DoeLog(1) && (eLog()<< Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl);
202 alpha = helper.Angle(RelativeOldSphereCenter);
203 // make the angle unique by checking the halfplanes/search direction
204 if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON) // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
205 alpha = 2.*M_PI - alpha;
206 DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl);
207 radius = helper.distance(RelativeOldSphereCenter);
208 helper.ProjectOntoPlane(NormalVector);
209 // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles
210 if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) {
211 DoLog(1) && (Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl);
212 return alpha;
213 } else {
214 DoLog(1) && (Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl);
215 return 2.*M_PI;
216 }
217};
218
219struct Intersection {
220 Vector x1;
221 Vector x2;
222 Vector x3;
223 Vector x4;
224};
225
226/** Gets the angle between a point and a reference relative to the provided center.
227 * We have two shanks point and reference between which the angle is calculated
228 * and by scalar product with OrthogonalVector we decide the interval.
229 * @param point to calculate the angle for
230 * @param reference to which to calculate the angle
231 * @param OrthogonalVector points in direction of [pi,2pi] interval
232 *
233 * @return angle between point and reference
234 */
235double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector)
236{
237 Info FunctionInfo(__func__);
238 if (reference.IsZero())
239 return M_PI;
240
241 // calculate both angles and correct with in-plane vector
242 if (point.IsZero())
243 return M_PI;
244 double phi = point.Angle(reference);
245 if (OrthogonalVector.ScalarProduct(point) > 0) {
246 phi = 2.*M_PI - phi;
247 }
248
249 DoLog(1) && (Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl);
250
251 return phi;
252}
253
254
255/** Calculates the volume of a general tetraeder.
256 * \param *a first vector
257 * \param *b second vector
258 * \param *c third vector
259 * \param *d fourth vector
260 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$
261 */
262double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d)
263{
264 Info FunctionInfo(__func__);
265 Vector Point, TetraederVector[3];
266 double volume;
267
268 TetraederVector[0] = a;
269 TetraederVector[1] = b;
270 TetraederVector[2] = c;
271 for (int j=0;j<3;j++)
272 TetraederVector[j].SubtractVector(d);
273 Point = TetraederVector[0];
274 Point.VectorProduct(TetraederVector[1]);
275 volume = 1./6. * fabs(Point.ScalarProduct(TetraederVector[2]));
276 return volume;
277};
278
279/** Calculates the area of a general triangle.
280 * We use the Heron's formula of area, [Bronstein, S. 138]
281 * \param &A first vector
282 * \param &B second vector
283 * \param &C third vector
284 * \return \f$ \frac{1}{6} \cdot ((a-d) \times (a-c) \cdot (a-b)) \f$
285 */
286double CalculateAreaofGeneralTriangle(const Vector &A, const Vector &B, const Vector &C)
287{
288 Info FunctionInfo(__func__);
289
290 const double sidea = B.distance(C);
291 const double sideb = A.distance(C);
292 const double sidec = A.distance(B);
293 const double s = (sidea+sideb+sidec)/2.;
294
295 const double area = sqrt(s*(s-sidea)*(s-sideb)*(s-sidec));
296 return area;
297};
298
299
300/** Checks for a new special triangle whether one of its edges is already present with one one triangle connected.
301 * This enforces that special triangles (i.e. degenerated ones) should at last close the open-edge frontier and not
302 * make it bigger (i.e. closing one (the baseline) and opening two new ones).
303 * \param TPS[3] nodes of the triangle
304 * \return true - there is such a line (i.e. creation of degenerated triangle is valid), false - no such line (don't create)
305 */
306bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3])
307{
308 Info FunctionInfo(__func__);
309 bool result = false;
310 int counter = 0;
311
312 // check all three points
313 for (int i=0;i<3;i++)
314 for (int j=i+1; j<3; j++) {
315 if (nodes[i] == NULL) {
316 DoLog(1) && (Log() << Verbose(1) << "Node nr. " << i << " is not yet present." << endl);
317 result = true;
318 } else if (nodes[i]->lines.find(nodes[j]->node->nr) != nodes[i]->lines.end()) { // there already is a line
319 LineMap::const_iterator FindLine;
320 pair<LineMap::const_iterator,LineMap::const_iterator> FindPair;
321 FindPair = nodes[i]->lines.equal_range(nodes[j]->node->nr);
322 for (FindLine = FindPair.first; FindLine != FindPair.second; ++FindLine) {
323 // If there is a line with less than two attached triangles, we don't need a new line.
324 if (FindLine->second->triangles.size() < 2) {
325 counter++;
326 break; // increase counter only once per edge
327 }
328 }
329 } else { // no line
330 DoLog(1) && (Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl);
331 result = true;
332 }
333 }
334 if ((!result) && (counter > 1)) {
335 DoLog(1) && (Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl);
336 result = true;
337 }
338 return result;
339};
340
341
342///** Sort function for the candidate list.
343// */
344//bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2)
345//{
346// Info FunctionInfo(__func__);
347// Vector BaseLineVector, OrthogonalVector, helper;
348// if (candidate1->BaseLine != candidate2->BaseLine) { // sanity check
349// DoeLog(1) && (eLog()<< Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl);
350// //return false;
351// exit(1);
352// }
353// // create baseline vector
354// BaseLineVector.CopyVector(candidate1->BaseLine->endpoints[1]->node->node);
355// BaseLineVector.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
356// BaseLineVector.Normalize();
357//
358// // create normal in-plane vector to cope with acos() non-uniqueness on [0,2pi] (note that is pointing in the "right" direction already, hence ">0" test!)
359// helper.CopyVector(candidate1->BaseLine->endpoints[0]->node->node);
360// helper.SubtractVector(candidate1->point->node);
361// OrthogonalVector.CopyVector(&helper);
362// helper.VectorProduct(&BaseLineVector);
363// OrthogonalVector.SubtractVector(&helper);
364// OrthogonalVector.Normalize();
365//
366// // calculate both angles and correct with in-plane vector
367// helper.CopyVector(candidate1->point->node);
368// helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
369// double phi = BaseLineVector.Angle(&helper);
370// if (OrthogonalVector.ScalarProduct(&helper) > 0) {
371// phi = 2.*M_PI - phi;
372// }
373// helper.CopyVector(candidate2->point->node);
374// helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
375// double psi = BaseLineVector.Angle(&helper);
376// if (OrthogonalVector.ScalarProduct(&helper) > 0) {
377// psi = 2.*M_PI - psi;
378// }
379//
380// Log() << Verbose(1) << *candidate1->point << " has angle " << phi << endl;
381// Log() << Verbose(1) << *candidate2->point << " has angle " << psi << endl;
382//
383// // return comparison
384// return phi < psi;
385//};
386
387/**
388 * Finds the point which is second closest to the provided one.
389 *
390 * @param Point to which to find the second closest other point
391 * @param linked cell structure
392 *
393 * @return point which is second closest to the provided one
394 */
395TesselPoint* FindSecondClosestTesselPoint(const Vector& Point, const LinkedCell* const LC)
396{
397 Info FunctionInfo(__func__);
398 TesselPoint* closestPoint = NULL;
399 TesselPoint* secondClosestPoint = NULL;
400 double distance = 1e16;
401 double secondDistance = 1e16;
402 Vector helper;
403 int N[NDIM], Nlower[NDIM], Nupper[NDIM];
404
405 LC->SetIndexToVector(Point); // ignore status as we calculate bounds below sensibly
406 for(int i=0;i<NDIM;i++) // store indices of this cell
407 N[i] = LC->n[i];
408 DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
409
410 LC->GetNeighbourBounds(Nlower, Nupper);
411 //Log() << Verbose(1) << endl;
412 for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
413 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
414 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
415 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
416 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
417 if (List != NULL) {
418 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
419 helper = (Point) - ((*Runner)->getPosition());
420 double currentNorm = helper. Norm();
421 if (currentNorm < distance) {
422 // remember second point
423 secondDistance = distance;
424 secondClosestPoint = closestPoint;
425 // mark down new closest point
426 distance = currentNorm;
427 closestPoint = (*Runner);
428 //Log() << Verbose(2) << "INFO: New Second Nearest Neighbour is " << *secondClosestPoint << "." << endl;
429 }
430 }
431 } else {
432 DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
433 }
434 }
435
436 return secondClosestPoint;
437};
438
439/**
440 * Finds the point which is closest to the provided one.
441 *
442 * @param Point to which to find the closest other point
443 * @param SecondPoint the second closest other point on return, NULL if none found
444 * @param linked cell structure
445 *
446 * @return point which is closest to the provided one, NULL if none found
447 */
448TesselPoint* FindClosestTesselPoint(const Vector& Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
449{
450 Info FunctionInfo(__func__);
451 TesselPoint* closestPoint = NULL;
452 SecondPoint = NULL;
453 double distance = 1e16;
454 double secondDistance = 1e16;
455 Vector helper;
456 int N[NDIM], Nlower[NDIM], Nupper[NDIM];
457
458 LC->SetIndexToVector(Point); // ignore status as we calculate bounds below sensibly
459 for(int i=0;i<NDIM;i++) // store indices of this cell
460 N[i] = LC->n[i];
461 DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
462
463 LC->GetNeighbourBounds(Nlower, Nupper);
464 //Log() << Verbose(1) << endl;
465 for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
466 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
467 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
468 const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
469 //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
470 if (List != NULL) {
471 for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
472 helper = (Point) - ((*Runner)->getPosition());
473 double currentNorm = helper.NormSquared();
474 if (currentNorm < distance) {
475 secondDistance = distance;
476 SecondPoint = closestPoint;
477 distance = currentNorm;
478 closestPoint = (*Runner);
479 //Log() << Verbose(1) << "INFO: New Nearest Neighbour is " << *closestPoint << "." << endl;
480 } else if (currentNorm < secondDistance) {
481 secondDistance = currentNorm;
482 SecondPoint = (*Runner);
483 //Log() << Verbose(1) << "INFO: New Second Nearest Neighbour is " << *SecondPoint << "." << endl;
484 }
485 }
486 } else {
487 DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
488 }
489 }
490 // output
491 if (closestPoint != NULL) {
492 DoLog(1) && (Log() << Verbose(1) << "Closest point is " << *closestPoint);
493 if (SecondPoint != NULL)
494 DoLog(0) && (Log() << Verbose(0) << " and second closest is " << *SecondPoint);
495 DoLog(0) && (Log() << Verbose(0) << "." << endl);
496 }
497 return closestPoint;
498};
499
500/** Returns the closest point on \a *Base with respect to \a *OtherBase.
501 * \param *out output stream for debugging
502 * \param *Base reference line
503 * \param *OtherBase other base line
504 * \return Vector on reference line that has closest distance
505 */
506Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase)
507{
508 Info FunctionInfo(__func__);
509 // construct the plane of the two baselines (i.e. take both their directional vectors)
510 Vector Baseline = (Base->endpoints[1]->node->getPosition()) - (Base->endpoints[0]->node->getPosition());
511 Vector OtherBaseline = (OtherBase->endpoints[1]->node->getPosition()) - (OtherBase->endpoints[0]->node->getPosition());
512 Vector Normal = Baseline;
513 Normal.VectorProduct(OtherBaseline);
514 Normal.Normalize();
515 DoLog(1) && (Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl);
516
517 // project one offset point of OtherBase onto this plane (and add plane offset vector)
518 Vector NewOffset = (OtherBase->endpoints[0]->node->getPosition()) - (Base->endpoints[0]->node->getPosition());
519 NewOffset.ProjectOntoPlane(Normal);
520 NewOffset += (Base->endpoints[0]->node->getPosition());
521 Vector NewDirection = NewOffset + OtherBaseline;
522
523 // calculate the intersection between this projected baseline and Base
524 Vector *Intersection = new Vector;
525 Line line1 = makeLineThrough((Base->endpoints[0]->node->getPosition()),(Base->endpoints[1]->node->getPosition()));
526 Line line2 = makeLineThrough(NewOffset, NewDirection);
527 *Intersection = line1.getIntersection(line2);
528 Normal = (*Intersection) - (Base->endpoints[0]->node->getPosition());
529 DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(Baseline)/Baseline.NormSquared()) << "." << endl);
530
531 return Intersection;
532};
533
534/** Returns the distance to the plane defined by \a *triangle
535 * \param *out output stream for debugging
536 * \param *x Vector to calculate distance to
537 * \param *triangle triangle defining plane
538 * \return distance between \a *x and plane defined by \a *triangle, -1 - if something went wrong
539 */
540double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle)
541{
542 Info FunctionInfo(__func__);
543 double distance = 0.;
544 if (x == NULL) {
545 return -1;
546 }
547 distance = x->DistanceToSpace(triangle->getPlane());
548 return distance;
549};
550
551/** Creates the objects in a VRML file.
552 * \param *out output stream for debugging
553 * \param *vrmlfile output stream for tecplot data
554 * \param *Tess Tesselation structure with constructed triangles
555 * \param *mol molecule structure with atom positions
556 */
557void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud)
558{
559 Info FunctionInfo(__func__);
560 TesselPoint *Walker = NULL;
561 int i;
562 Vector *center = cloud->GetCenter();
563 if (vrmlfile != NULL) {
564 //Log() << Verbose(1) << "Writing Raster3D file ... ";
565 *vrmlfile << "#VRML V2.0 utf8" << endl;
566 *vrmlfile << "#Created by molecuilder" << endl;
567 *vrmlfile << "#All atoms as spheres" << endl;
568 cloud->GoToFirst();
569 while (!cloud->IsEnd()) {
570 Walker = cloud->GetPoint();
571 *vrmlfile << "Sphere {" << endl << " "; // 2 is sphere type
572 for (i=0;i<NDIM;i++)
573 *vrmlfile << Walker->at(i)-center->at(i) << " ";
574 *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
575 cloud->GoToNext();
576 }
577
578 *vrmlfile << "# All tesselation triangles" << endl;
579 for (TriangleMap::const_iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
580 *vrmlfile << "1" << endl << " "; // 1 is triangle type
581 for (i=0;i<3;i++) { // print each node
582 for (int j=0;j<NDIM;j++) // and for each node all NDIM coordinates
583 *vrmlfile << TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j) << " ";
584 *vrmlfile << "\t";
585 }
586 *vrmlfile << "1. 0. 0." << endl; // red as colour
587 *vrmlfile << "18" << endl << " 0.5 0.5 0.5" << endl; // 18 is transparency type for previous object
588 }
589 } else {
590 DoeLog(1) && (eLog()<< Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl);
591 }
592 delete(center);
593};
594
595/** Writes additionally the current sphere (i.e. the last triangle to file).
596 * \param *out output stream for debugging
597 * \param *rasterfile output stream for tecplot data
598 * \param *Tess Tesselation structure with constructed triangles
599 * \param *mol molecule structure with atom positions
600 */
601void IncludeSphereinRaster3D(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
602{
603 Info FunctionInfo(__func__);
604 Vector helper;
605
606 if (Tess->LastTriangle != NULL) {
607 // include the current position of the virtual sphere in the temporary raster3d file
608 Vector *center = cloud->GetCenter();
609 // make the circumsphere's center absolute again
610 Vector helper = (1./3.) * ((Tess->LastTriangle->endpoints[0]->node->getPosition()) +
611 (Tess->LastTriangle->endpoints[1]->node->getPosition()) +
612 (Tess->LastTriangle->endpoints[2]->node->getPosition()));
613 helper -= (*center);
614 // and add to file plus translucency object
615 *rasterfile << "# current virtual sphere\n";
616 *rasterfile << "8\n 25.0 0.6 -1.0 -1.0 -1.0 0.2 0 0 0 0\n";
617 *rasterfile << "2\n " << helper[0] << " " << helper[1] << " " << helper[2] << "\t" << 5. << "\t1 0 0\n";
618 *rasterfile << "9\n terminating special property\n";
619 delete(center);
620 }
621};
622
623/** Creates the objects in a raster3d file (renderable with a header.r3d).
624 * \param *out output stream for debugging
625 * \param *rasterfile output stream for tecplot data
626 * \param *Tess Tesselation structure with constructed triangles
627 * \param *mol molecule structure with atom positions
628 */
629void WriteRaster3dFile(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
630{
631 Info FunctionInfo(__func__);
632 TesselPoint *Walker = NULL;
633 int i;
634 Vector *center = cloud->GetCenter();
635 if (rasterfile != NULL) {
636 //Log() << Verbose(1) << "Writing Raster3D file ... ";
637 *rasterfile << "# Raster3D object description, created by MoleCuilder" << endl;
638 *rasterfile << "@header.r3d" << endl;
639 *rasterfile << "# All atoms as spheres" << endl;
640 cloud->GoToFirst();
641 while (!cloud->IsEnd()) {
642 Walker = cloud->GetPoint();
643 *rasterfile << "2" << endl << " "; // 2 is sphere type
644 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
645 const double tmp = Walker->at(j)-center->at(j);
646 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
647 }
648 *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
649 cloud->GoToNext();
650 }
651
652 *rasterfile << "# All tesselation triangles" << endl;
653 *rasterfile << "8\n 25. -1. 1. 1. 1. 0.0 0 0 0 2\n SOLID 1.0 0.0 0.0\n BACKFACE 0.3 0.3 1.0 0 0\n";
654 for (TriangleMap::const_iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
655 *rasterfile << "1" << endl << " "; // 1 is triangle type
656 for (i=0;i<3;i++) { // print each node
657 for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
658 const double tmp = TriangleRunner->second->endpoints[i]->node->at(j)-center->at(j);
659 *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
660 }
661 *rasterfile << "\t";
662 }
663 *rasterfile << "1. 0. 0." << endl; // red as colour
664 //*rasterfile << "18" << endl << " 0.5 0.5 0.5" << endl; // 18 is transparency type for previous object
665 }
666 *rasterfile << "9\n# terminating special property\n";
667 } else {
668 DoeLog(1) && (eLog()<< Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl);
669 }
670 IncludeSphereinRaster3D(rasterfile, Tess, cloud);
671 delete(center);
672};
673
674/** This function creates the tecplot file, displaying the tesselation of the hull.
675 * \param *out output stream for debugging
676 * \param *tecplot output stream for tecplot data
677 * \param N arbitrary number to differentiate various zones in the tecplot format
678 */
679void WriteTecplotFile(ofstream * const tecplot, const Tesselation * const TesselStruct, const PointCloud * const cloud, const int N)
680{
681 Info FunctionInfo(__func__);
682 if ((tecplot != NULL) && (TesselStruct != NULL)) {
683 // write header
684 *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
685 *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\" \"U\"" << endl;
686 *tecplot << "ZONE T=\"";
687 if (N < 0) {
688 *tecplot << cloud->GetName();
689 } else {
690 *tecplot << N << "-";
691 if (TesselStruct->LastTriangle != NULL) {
692 for (int i=0;i<3;i++)
693 *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->getName();
694 } else {
695 *tecplot << "none";
696 }
697 }
698 *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
699 const int MaxId=cloud->GetMaxId();
700 int *LookupList = new int[MaxId];
701 for (int i=0; i< MaxId ; i++){
702 LookupList[i] = -1;
703 }
704
705 // print atom coordinates
706 int Counter = 1;
707 TesselPoint *Walker = NULL;
708 for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); ++target) {
709 Walker = target->second->node;
710 LookupList[Walker->nr] = Counter++;
711 for (int i=0;i<NDIM;i++) {
712 const double tmp = Walker->at(i);
713 *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
714 }
715 *tecplot << target->second->value << endl;
716 }
717 *tecplot << endl;
718 // print connectivity
719 DoLog(1) && (Log() << Verbose(1) << "The following triangles were created:" << endl);
720 for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) {
721 DoLog(1) && (Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->getName() << "<->" << runner->second->endpoints[1]->node->getName() << "<->" << runner->second->endpoints[2]->node->getName() << endl);
722 *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
723 }
724 delete[] (LookupList);
725 }
726};
727
728/** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation.
729 * Sets BoundaryPointSet::value equal to the number of connected lines that are not convex.
730 * \param *out output stream for debugging
731 * \param *TesselStruct pointer to Tesselation structure
732 */
733void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct)
734{
735 Info FunctionInfo(__func__);
736 class BoundaryPointSet *point = NULL;
737 class BoundaryLineSet *line = NULL;
738 class BoundaryTriangleSet *triangle = NULL;
739 double ConcavityPerLine = 0.;
740 double ConcavityPerTriangle = 0.;
741 double area = 0.;
742 double totalarea = 0.;
743
744 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
745 point = PointRunner->second;
746 DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
747
748 // calculate mean concavity over all connected line
749 ConcavityPerLine = 0.;
750 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
751 line = LineRunner->second;
752 //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
753 ConcavityPerLine -= line->CalculateConvexity();
754 }
755 ConcavityPerLine /= point->lines.size();
756
757 // weigh with total area of the surrounding triangles
758 totalarea = 0.;
759 TriangleSet *triangles = TesselStruct->GetAllTriangles(PointRunner->second);
760 for (TriangleSet::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) {
761 totalarea += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition());
762 }
763 ConcavityPerLine *= totalarea;
764
765 // calculate mean concavity over all attached triangles
766 ConcavityPerTriangle = 0.;
767 for (TriangleSet::const_iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); ++TriangleRunner) {
768 line = (*TriangleRunner)->GetThirdLine(PointRunner->second);
769 triangle = line->GetOtherTriangle(*TriangleRunner);
770 area = CalculateAreaofGeneralTriangle(triangle->endpoints[0]->node->getPosition() , triangle->endpoints[1]->node->getPosition() , triangle->endpoints[2]->node->getPosition());
771 area += CalculateAreaofGeneralTriangle((*TriangleRunner)->endpoints[0]->node->getPosition() , (*TriangleRunner)->endpoints[1]->node->getPosition() , (*TriangleRunner)->endpoints[2]->node->getPosition());
772 area *= -line->CalculateConvexity();
773 if (area > 0)
774 ConcavityPerTriangle += area;
775// else
776// ConcavityPerTriangle -= area;
777 }
778 ConcavityPerTriangle /= triangles->size()/totalarea;
779 delete(triangles);
780
781 // add up
782 point->value = ConcavityPerLine + ConcavityPerTriangle;
783 }
784};
785
786
787
788/** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation.
789 * Sets BoundaryPointSet::value equal to the nearest distance to convex envelope.
790 * \param *out output stream for debugging
791 * \param *TesselStruct pointer to Tesselation structure
792 * \param *Convex pointer to convex Tesselation structure as reference
793 */
794void CalculateConstrictionPerBoundaryPoint(const Tesselation * const TesselStruct, const Tesselation * const Convex)
795{
796 Info FunctionInfo(__func__);
797 double distance = 0.;
798
799 for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
800 DoeLog(1) && (eLog() << Verbose(1) << "INFO: Current point is " << * PointRunner->second << "." << endl);
801
802 distance = 0.;
803 for (TriangleMap::const_iterator TriangleRunner = Convex->TrianglesOnBoundary.begin(); TriangleRunner != Convex->TrianglesOnBoundary.end(); TriangleRunner++) {
804 const double CurrentDistance = Convex->GetDistanceSquaredToTriangle(PointRunner->second->node->getPosition() , TriangleRunner->second);
805 if (CurrentDistance < distance)
806 distance = CurrentDistance;
807 }
808
809 PointRunner->second->value = distance;
810 }
811};
812
813/** Checks whether each BoundaryLineSet in the Tesselation has two triangles.
814 * \param *out output stream for debugging
815 * \param *TesselStruct
816 * \return true - all have exactly two triangles, false - some not, list is printed to screen
817 */
818bool CheckListOfBaselines(const Tesselation * const TesselStruct)
819{
820 Info FunctionInfo(__func__);
821 LineMap::const_iterator testline;
822 bool result = false;
823 int counter = 0;
824
825 DoLog(1) && (Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl);
826 for (testline = TesselStruct->LinesOnBoundary.begin(); testline != TesselStruct->LinesOnBoundary.end(); testline++) {
827 if (testline->second->triangles.size() != 2) {
828 DoLog(2) && (Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl);
829 counter++;
830 }
831 }
832 if (counter == 0) {
833 DoLog(1) && (Log() << Verbose(1) << "None." << endl);
834 result = true;
835 }
836 return result;
837}
838
839/** Counts the number of triangle pairs that contain the given polygon.
840 * \param *P polygon with endpoints to look for
841 * \param *T set of triangles to create pairs from containing \a *P
842 */
843int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T)
844{
845 Info FunctionInfo(__func__);
846 // check number of endpoints in *P
847 if (P->endpoints.size() != 4) {
848 DoeLog(1) && (eLog()<< Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl);
849 return 0;
850 }
851
852 // check number of triangles in *T
853 if (T->size() < 2) {
854 DoeLog(1) && (eLog()<< Verbose(1) << "Not enough triangles to have pairs!" << endl);
855 return 0;
856 }
857
858 DoLog(0) && (Log() << Verbose(0) << "Polygon is " << *P << endl);
859 // create each pair, get the endpoints and check whether *P is contained.
860 int counter = 0;
861 PointSet Trianglenodes;
862 class BoundaryPolygonSet PairTrianglenodes;
863 for(TriangleSet::iterator Walker = T->begin(); Walker != T->end(); Walker++) {
864 for (int i=0;i<3;i++)
865 Trianglenodes.insert((*Walker)->endpoints[i]);
866
867 for(TriangleSet::iterator PairWalker = Walker; PairWalker != T->end(); PairWalker++) {
868 if (Walker != PairWalker) { // skip first
869 PairTrianglenodes.endpoints = Trianglenodes;
870 for (int i=0;i<3;i++)
871 PairTrianglenodes.endpoints.insert((*PairWalker)->endpoints[i]);
872 const int size = PairTrianglenodes.endpoints.size();
873 if (size == 4) {
874 DoLog(0) && (Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl);
875 // now check
876 if (PairTrianglenodes.ContainsPresentTupel(P)) {
877 counter++;
878 DoLog(0) && (Log() << Verbose(0) << " ACCEPT: Matches with " << *P << endl);
879 } else {
880 DoLog(0) && (Log() << Verbose(0) << " REJECT: No match with " << *P << endl);
881 }
882 } else {
883 DoLog(0) && (Log() << Verbose(0) << " REJECT: Less than four endpoints." << endl);
884 }
885 }
886 }
887 Trianglenodes.clear();
888 }
889 return counter;
890};
891
892/** Checks whether two give polygons have two or more points in common.
893 * \param *P1 first polygon
894 * \param *P2 second polygon
895 * \return true - are connected, false = are note
896 */
897bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2)
898{
899 Info FunctionInfo(__func__);
900 int counter = 0;
901 for(PointSet::const_iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) {
902 if (P2->ContainsBoundaryPoint((*Runner))) {
903 counter++;
904 DoLog(1) && (Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl);
905 return true;
906 }
907 }
908 return false;
909};
910
911/** Combines second into the first and deletes the second.
912 * \param *P1 first polygon, contains all nodes on return
913 * \param *&P2 second polygon, is deleted.
914 */
915void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2)
916{
917 Info FunctionInfo(__func__);
918 pair <PointSet::iterator, bool> Tester;
919 for(PointSet::iterator Runner = P2->endpoints.begin(); Runner != P2->endpoints.end(); Runner++) {
920 Tester = P1->endpoints.insert((*Runner));
921 if (Tester.second)
922 DoLog(0) && (Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl);
923 }
924 P2->endpoints.clear();
925 delete(P2);
926};
927
Note: See TracBrowser for help on using the repository browser.