Changeset e138de for src/boundary.cpp
- Timestamp:
- Nov 4, 2009, 7:56:04 PM (16 years ago)
- Branches:
- 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, Candidate_v1.7.0, 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
- Children:
- 1614174, e5ad5c
- Parents:
- 7326b2
- File:
-
- 1 edited
-
src/boundary.cpp (modified) (66 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r7326b2 re138de 11 11 #include "helpers.hpp" 12 12 #include "linkedcell.hpp" 13 #include "log.hpp" 13 14 #include "memoryallocator.hpp" 14 15 #include "molecule.hpp" … … 30 31 * \return NDIM array of the diameters 31 32 */ 32 double *GetDiametersOfCluster( ofstream *out,const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem)33 double *GetDiametersOfCluster(const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem) 33 34 { 34 35 // get points on boundary of NULL was given as parameter … … 49 50 if (BoundaryPtr == NULL) { 50 51 BoundaryFreeFlag = true; 51 BoundaryPoints = GetBoundaryPoints( out,mol, TesselStruct);52 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 52 53 } else { 53 54 BoundaryPoints = BoundaryPtr; 54 *out<< Verbose(1) << "Using given boundary points set." << endl;55 Log() << Verbose(1) << "Using given boundary points set." << endl; 55 56 } 56 57 // determine biggest "diameter" of cluster for each axis … … 59 60 for (int axis = 0; axis < NDIM; axis++) 60 61 { // regard each projected plane 61 // *out<< Verbose(1) << "Current axis is " << axis << "." << endl;62 //Log() << Verbose(1) << "Current axis is " << axis << "." << endl; 62 63 for (int j = 0; j < 2; j++) 63 64 { // and for both axis on the current plane 64 65 component = (axis + j + 1) % NDIM; 65 66 Othercomponent = (axis + 1 + ((j + 1) & 1)) % NDIM; 66 // *out<< Verbose(1) << "Current component is " << component << ", Othercomponent is " << Othercomponent << "." << endl;67 //Log() << Verbose(1) << "Current component is " << component << ", Othercomponent is " << Othercomponent << "." << endl; 67 68 for (Boundaries::const_iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 68 // *out<< Verbose(2) << "Current runner is " << *(runner->second.second) << "." << endl;69 //Log() << Verbose(2) << "Current runner is " << *(runner->second.second) << "." << endl; 69 70 // seek for the neighbours pair where the Othercomponent sign flips 70 71 Neighbour = runner; … … 81 82 DistanceVector.CopyVector(&runner->second.second->x); 82 83 DistanceVector.SubtractVector(&Neighbour->second.second->x); 83 // *out<< Verbose(3) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;84 //Log() << Verbose(3) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl; 84 85 } while ((runner != Neighbour) && (fabs(OldComponent / fabs( 85 86 OldComponent) - DistanceVector.x[Othercomponent] / fabs( … … 90 91 OtherNeighbour = BoundaryPoints[axis].end(); 91 92 OtherNeighbour--; 92 // *out<< Verbose(2) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl;93 //Log() << Verbose(2) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl; 93 94 // now we have found the pair: Neighbour and OtherNeighbour 94 95 OtherVector.CopyVector(&runner->second.second->x); 95 96 OtherVector.SubtractVector(&OtherNeighbour->second.second->x); 96 // *out<< Verbose(2) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl;97 // *out<< Verbose(2) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;97 //Log() << Verbose(2) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl; 98 //Log() << Verbose(2) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl; 98 99 // do linear interpolation between points (is exact) to extract exact intersection between Neighbour and OtherNeighbour 99 100 w1 = fabs(OtherVector.x[Othercomponent]); … … 102 103 * OtherVector.x[component]) / (w1 + w2)); 103 104 // mark if it has greater diameter 104 // *out<< Verbose(2) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl;105 //Log() << Verbose(2) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl; 105 106 GreatestDiameter[component] = (GreatestDiameter[component] 106 107 > tmp) ? GreatestDiameter[component] : tmp; 107 108 } //else 108 // *out<< Verbose(2) << "Saw no sign flip, probably top or bottom node." << endl;109 //Log() << Verbose(2) << "Saw no sign flip, probably top or bottom node." << endl; 109 110 } 110 111 } 111 112 } 112 *out<< Verbose(0) << "RESULT: The biggest diameters are "113 Log() << Verbose(0) << "RESULT: The biggest diameters are " 113 114 << GreatestDiameter[0] << " and " << GreatestDiameter[1] << " and " 114 115 << GreatestDiameter[2] << " " << (IsAngstroem ? "angstrom" … … 132 133 * \param *&TesselStruct pointer to Tesselation structure 133 134 */ 134 Boundaries *GetBoundaryPoints( ofstream *out,const molecule *mol, Tesselation *&TesselStruct)135 Boundaries *GetBoundaryPoints(const molecule *mol, Tesselation *&TesselStruct) 135 136 { 136 137 atom *Walker = NULL; … … 138 139 LineMap LinesOnBoundary; 139 140 TriangleMap TrianglesOnBoundary; 140 Vector *MolCenter = mol->DetermineCenterOfAll( out);141 Vector *MolCenter = mol->DetermineCenterOfAll(); 141 142 Vector helper; 142 143 BoundariesTestPair BoundaryTestPair; … … 148 149 double angle = 0.; 149 150 150 *out<< Verbose(1) << "Finding all boundary points." << endl;151 Log() << Verbose(1) << "Finding all boundary points." << endl; 151 152 // 3a. Go through every axis 152 153 for (int axis = 0; axis < NDIM; axis++) { … … 158 159 AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.; 159 160 160 *out<< Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;161 Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl; 161 162 162 163 // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours … … 175 176 angle = 0.; // otherwise it's a vector in Axis Direction and unimportant for boundary issues 176 177 177 // *out<< "Checking sign in quadrant : " << ProjectedVector.Projection(&AngleReferenceNormalVector) << "." << endl;178 //Log() << Verbose(0) << "Checking sign in quadrant : " << ProjectedVector.Projection(&AngleReferenceNormalVector) << "." << endl; 178 179 if (ProjectedVector.ScalarProduct(&AngleReferenceNormalVector) > 0) { 179 180 angle = 2. * M_PI - angle; 180 181 } 181 *out<< Verbose(2) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;182 Log() << Verbose(2) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl; 182 183 BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker))); 183 184 if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity 184 *out<< Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl;185 *out<< Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl;186 *out<< Verbose(2) << "New vector: " << *Walker << endl;185 Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl; 186 Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl; 187 Log() << Verbose(2) << "New vector: " << *Walker << endl; 187 188 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 188 189 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 189 190 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 190 191 BoundaryTestPair.first->second.second = Walker; 191 *out<< Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;192 Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl; 192 193 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 193 194 helper.CopyVector(&Walker->x); … … 198 199 if (helper.NormSquared() < oldhelperNorm) { 199 200 BoundaryTestPair.first->second.second = Walker; 200 *out<< Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;201 Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl; 201 202 } else { 202 *out<< Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl;203 Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl; 203 204 } 204 205 } else { 205 *out<< Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;206 Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl; 206 207 } 207 208 } … … 209 210 // printing all inserted for debugging 210 211 // { 211 // *out<< Verbose(2) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;212 // Log() << Verbose(2) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl; 212 213 // int i=0; 213 214 // for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 214 215 // if (runner != BoundaryPoints[axis].begin()) 215 // *out<< ", " << i << ": " << *runner->second.second;216 // Log() << Verbose(0) << ", " << i << ": " << *runner->second.second; 216 217 // else 217 // *out<< i << ": " << *runner->second.second;218 // Log() << Verbose(0) << i << ": " << *runner->second.second; 218 219 // i++; 219 220 // } 220 // *out<< endl;221 // Log() << Verbose(0) << endl; 221 222 // } 222 223 // 3c. throw out points whose distance is less than the mean of left and right neighbours 223 224 bool flag = false; 224 *out<< Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl;225 Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl; 225 226 do { // do as long as we still throw one out per round 226 227 flag = false; … … 248 249 SideA.SubtractVector(MolCenter); 249 250 SideA.ProjectOntoPlane(&AxisVector); 250 // *out<< "SideA: ";251 // Log() << Verbose(0) << "SideA: "; 251 252 // SideA.Output(out); 252 // *out<< endl;253 // Log() << Verbose(0) << endl; 253 254 254 255 SideB.CopyVector(&right->second.second->x); 255 256 SideB.SubtractVector(MolCenter); 256 257 SideB.ProjectOntoPlane(&AxisVector); 257 // *out<< "SideB: ";258 // Log() << Verbose(0) << "SideB: "; 258 259 // SideB.Output(out); 259 // *out<< endl;260 // Log() << Verbose(0) << endl; 260 261 261 262 SideC.CopyVector(&left->second.second->x); 262 263 SideC.SubtractVector(&right->second.second->x); 263 264 SideC.ProjectOntoPlane(&AxisVector); 264 // *out<< "SideC: ";265 // Log() << Verbose(0) << "SideC: "; 265 266 // SideC.Output(out); 266 // *out<< endl;267 // Log() << Verbose(0) << endl; 267 268 268 269 SideH.CopyVector(&runner->second.second->x); 269 270 SideH.SubtractVector(MolCenter); 270 271 SideH.ProjectOntoPlane(&AxisVector); 271 // *out<< "SideH: ";272 // Log() << Verbose(0) << "SideH: "; 272 273 // SideH.Output(out); 273 // *out<< endl;274 // Log() << Verbose(0) << endl; 274 275 275 276 // calculate each length … … 284 285 const double delta = SideC.Angle(&SideH); 285 286 const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.); 286 // *out<< Verbose(2) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl;287 *out<< Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl;287 //Log() << Verbose(2) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl; 288 Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl; 288 289 if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) { 289 290 // throw out point 290 *out<< Verbose(1) << "Throwing out " << *runner->second.second << "." << endl;291 Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl; 291 292 BoundaryPoints[axis].erase(runner); 292 293 flag = true; … … 308 309 * \return *TesselStruct is filled with convex boundary and tesselation is stored under \a *filename. 309 310 */ 310 void FindConvexBorder( ofstream *out,const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)311 void FindConvexBorder(const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename) 311 312 { 312 313 bool BoundaryFreeFlag = false; 313 314 Boundaries *BoundaryPoints = NULL; 314 315 315 cout<< Verbose(1) << "Begin of FindConvexBorder" << endl;316 Log() << Verbose(1) << "Begin of FindConvexBorder" << endl; 316 317 317 318 if (TesselStruct != NULL) // free if allocated … … 322 323 if (BoundaryPoints == NULL) { 323 324 BoundaryFreeFlag = true; 324 BoundaryPoints = GetBoundaryPoints( out,mol, TesselStruct);325 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 325 326 } else { 326 *out<< Verbose(1) << "Using given boundary points set." << endl;327 Log() << Verbose(1) << "Using given boundary points set." << endl; 327 328 } 328 329 … … 330 331 for (int axis=0; axis < NDIM; axis++) 331 332 { 332 *out<< Verbose(2) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;333 Log() << Verbose(2) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl; 333 334 int i=0; 334 335 for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) { 335 336 if (runner != BoundaryPoints[axis].begin()) 336 *out<< ", " << i << ": " << *runner->second.second;337 Log() << Verbose(0) << ", " << i << ": " << *runner->second.second; 337 338 else 338 *out<< i << ": " << *runner->second.second;339 Log() << Verbose(0) << i << ": " << *runner->second.second; 339 340 i++; 340 341 } 341 *out<< endl;342 Log() << Verbose(0) << endl; 342 343 } 343 344 … … 346 347 for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) 347 348 if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0)) 348 *out<< Verbose(3) << "WARNING: Point " << *(runner->second.second) << " is already present!" << endl;349 350 *out<< Verbose(2) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl;349 Log() << Verbose(3) << "WARNING: Point " << *(runner->second.second) << " is already present!" << endl; 350 351 Log() << Verbose(2) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl; 351 352 // now we have the whole set of edge points in the BoundaryList 352 353 353 354 // listing for debugging 354 // *out<< Verbose(1) << "Listing PointsOnBoundary:";355 // Log() << Verbose(1) << "Listing PointsOnBoundary:"; 355 356 // for(PointMap::iterator runner = PointsOnBoundary.begin(); runner != PointsOnBoundary.end(); runner++) { 356 // *out<< " " << *runner->second;357 // Log() << Verbose(0) << " " << *runner->second; 357 358 // } 358 // *out<< endl;359 // Log() << Verbose(0) << endl; 359 360 360 361 // 3a. guess starting triangle 361 TesselStruct->GuessStartingTriangle( out);362 TesselStruct->GuessStartingTriangle(); 362 363 363 364 // 3b. go through all lines, that are not yet part of two triangles (only of one so far) 364 TesselStruct->TesselateOnBoundary( out,mol);365 TesselStruct->TesselateOnBoundary(mol); 365 366 366 367 // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point 367 if (!TesselStruct->InsertStraddlingPoints( out,mol, LCList))368 *out<< Verbose(1) << "Insertion of straddling points failed!" << endl;369 370 *out<< Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;368 if (!TesselStruct->InsertStraddlingPoints(mol, LCList)) 369 Log() << Verbose(1) << "Insertion of straddling points failed!" << endl; 370 371 Log() << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl; 371 372 372 373 // 4. Store triangles in tecplot file … … 377 378 OutputName.append(TecplotSuffix); 378 379 ofstream *tecplot = new ofstream(OutputName.c_str()); 379 WriteTecplotFile( out,tecplot, TesselStruct, mol, 0);380 WriteTecplotFile(tecplot, TesselStruct, mol, 0); 380 381 tecplot->close(); 381 382 delete(tecplot); … … 386 387 OutputName.append(Raster3DSuffix); 387 388 ofstream *rasterplot = new ofstream(OutputName.c_str()); 388 WriteRaster3dFile( out,rasterplot, TesselStruct, mol);389 WriteRaster3dFile(rasterplot, TesselStruct, mol); 389 390 rasterplot->close(); 390 391 delete(rasterplot); … … 399 400 for (LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) { 400 401 line = LineRunner->second; 401 *out<< Verbose(1) << "INFO: Current line is " << *line << "." << endl;402 if (!line->CheckConvexityCriterion( out)) {403 *out<< Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;402 Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl; 403 if (!line->CheckConvexityCriterion()) { 404 Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl; 404 405 405 406 // flip the line 406 if (TesselStruct->PickFarthestofTwoBaselines( out,line) == 0.)407 *out<< Verbose(1) << "ERROR: Correction of concave baselines failed!" << endl;407 if (TesselStruct->PickFarthestofTwoBaselines(line) == 0.) 408 Log() << Verbose(1) << "ERROR: Correction of concave baselines failed!" << endl; 408 409 else { 409 TesselStruct->FlipBaseline( out,line);410 *out<< Verbose(1) << "INFO: Correction of concave baselines worked." << endl;410 TesselStruct->FlipBaseline(line); 411 Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl; 411 412 } 412 413 } … … 416 417 // 3e. we need another correction here, for TesselPoints that are below the surface (i.e. have an odd number of concave triangles surrounding it) 417 418 // if (!TesselStruct->CorrectConcaveTesselPoints(out)) 418 // *out<< Verbose(1) << "Correction of concave tesselpoints failed!" << endl;419 420 *out<< Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;419 // Log() << Verbose(1) << "Correction of concave tesselpoints failed!" << endl; 420 421 Log() << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl; 421 422 422 423 // 4. Store triangles in tecplot file … … 426 427 OutputName.append(TecplotSuffix); 427 428 ofstream *tecplot = new ofstream(OutputName.c_str()); 428 WriteTecplotFile( out,tecplot, TesselStruct, mol, 0);429 WriteTecplotFile(tecplot, TesselStruct, mol, 0); 429 430 tecplot->close(); 430 431 delete(tecplot); … … 434 435 OutputName.append(Raster3DSuffix); 435 436 ofstream *rasterplot = new ofstream(OutputName.c_str()); 436 WriteRaster3dFile( out,rasterplot, TesselStruct, mol);437 WriteRaster3dFile(rasterplot, TesselStruct, mol); 437 438 rasterplot->close(); 438 439 delete(rasterplot); … … 445 446 delete[] (BoundaryPoints); 446 447 447 cout<< Verbose(1) << "End of FindConvexBorder" << endl;448 Log() << Verbose(1) << "End of FindConvexBorder" << endl; 448 449 }; 449 450 … … 455 456 * \return true - all removed, false - something went wrong 456 457 */ 457 bool RemoveAllBoundaryPoints( ofstream *out,class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)458 bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename) 458 459 { 459 460 int i=0; … … 461 462 462 463 if ((TesselStruct == NULL) || (TesselStruct->PointsOnBoundary.empty())) { 463 *out<< Verbose(2) << "ERROR: TesselStruct is empty." << endl;464 Log() << Verbose(2) << "ERROR: TesselStruct is empty." << endl; 464 465 return false; 465 466 } … … 467 468 PointMap::iterator PointRunner; 468 469 while (!TesselStruct->PointsOnBoundary.empty()) { 469 *out<< Verbose(2) << "Remaining points are: ";470 Log() << Verbose(2) << "Remaining points are: "; 470 471 for (PointMap::iterator PointSprinter = TesselStruct->PointsOnBoundary.begin(); PointSprinter != TesselStruct->PointsOnBoundary.end(); PointSprinter++) 471 *out<< *(PointSprinter->second) << "\t";472 *out<< endl;472 Log() << Verbose(0) << *(PointSprinter->second) << "\t"; 473 Log() << Verbose(0) << endl; 473 474 474 475 PointRunner = TesselStruct->PointsOnBoundary.begin(); 475 476 // remove point 476 TesselStruct->RemovePointFromTesselatedSurface( out,PointRunner->second);477 TesselStruct->RemovePointFromTesselatedSurface(PointRunner->second); 477 478 478 479 // store envelope 479 480 sprintf(number, "-%04d", i++); 480 StoreTrianglesinFile( out,mol, (const Tesselation *&)TesselStruct, filename, number);481 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, number); 481 482 } 482 483 … … 508 509 * \return volume difference between the non- and the created convex envelope 509 510 */ 510 double ConvexizeNonconvexEnvelope( ofstream *out,class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)511 double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename) 511 512 { 512 513 double volume = 0; … … 523 524 int run = 0; 524 525 525 *out<< Verbose(0) << "Begin of ConvexizeNonconvexEnvelope" << endl;526 Log() << Verbose(0) << "Begin of ConvexizeNonconvexEnvelope" << endl; 526 527 527 528 // check whether there is something to work on 528 529 if (TesselStruct == NULL) { 529 *out<< Verbose(1) << "ERROR: TesselStruct is empty!" << endl;530 Log() << Verbose(1) << "ERROR: TesselStruct is empty!" << endl; 530 531 return volume; 531 532 } … … 535 536 Concavity = false; 536 537 sprintf(dummy, "-first-%d", run); 537 //CalculateConcavityPerBoundaryPoint( out,TesselStruct);538 StoreTrianglesinFile( out,mol, (const Tesselation *&)TesselStruct, filename, dummy);538 //CalculateConcavityPerBoundaryPoint(TesselStruct); 539 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, dummy); 539 540 540 541 PointRunner = TesselStruct->PointsOnBoundary.begin(); … … 543 544 PointAdvance++; 544 545 point = PointRunner->second; 545 *out<< Verbose(1) << "INFO: Current point is " << *point << "." << endl;546 Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl; 546 547 for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) { 547 548 line = LineRunner->second; 548 *out<< Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;549 if (!line->CheckConvexityCriterion( out)) {549 Log() << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl; 550 if (!line->CheckConvexityCriterion()) { 550 551 // remove the point if needed 551 *out<< Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;552 volume += TesselStruct->RemovePointFromTesselatedSurface( out,point);552 Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl; 553 volume += TesselStruct->RemovePointFromTesselatedSurface(point); 553 554 sprintf(dummy, "-first-%d", ++run); 554 StoreTrianglesinFile( out,mol, (const Tesselation *&)TesselStruct, filename, dummy);555 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, dummy); 555 556 Concavity = true; 556 557 break; … … 561 562 562 563 sprintf(dummy, "-second-%d", run); 563 //CalculateConcavityPerBoundaryPoint( out,TesselStruct);564 StoreTrianglesinFile( out,mol, (const Tesselation *&)TesselStruct, filename, dummy);564 //CalculateConcavityPerBoundaryPoint(TesselStruct); 565 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, dummy); 565 566 566 567 // second step: PickFarthestofTwoBaselines … … 570 571 LineAdvance++; 571 572 line = LineRunner->second; 572 *out<< Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;573 Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl; 573 574 // take highest of both lines 574 if (TesselStruct->IsConvexRectangle( out,line) == NULL) {575 const double tmp = TesselStruct->PickFarthestofTwoBaselines( out,line);575 if (TesselStruct->IsConvexRectangle(line) == NULL) { 576 const double tmp = TesselStruct->PickFarthestofTwoBaselines(line); 576 577 volume += tmp; 577 578 if (tmp != 0.) { 578 TesselStruct->FlipBaseline( out,line);579 TesselStruct->FlipBaseline(line); 579 580 Concavity = true; 580 581 } … … 584 585 run++; 585 586 } while (Concavity); 586 //CalculateConcavityPerBoundaryPoint( out,TesselStruct);587 //StoreTrianglesinFile( out,mol, filename, "-third");587 //CalculateConcavityPerBoundaryPoint(TesselStruct); 588 //StoreTrianglesinFile(mol, filename, "-third"); 588 589 589 590 // third step: IsConvexRectangle … … 593 594 // LineAdvance++; 594 595 // line = LineRunner->second; 595 // *out<< Verbose(1) << "INFO: Current line is " << *line << "." << endl;596 // Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl; 596 597 // //if (LineAdvance != TesselStruct->LinesOnBoundary.end()) 597 // // *out<< Verbose(1) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl;598 // //Log() << Verbose(1) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl; 598 599 // if (!line->CheckConvexityCriterion(out)) { 599 // *out<< Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;600 // Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl; 600 601 // 601 602 // // take highest of both lines 602 // point = TesselStruct->IsConvexRectangle( out,line);603 // point = TesselStruct->IsConvexRectangle(line); 603 604 // if (point != NULL) 604 // volume += TesselStruct->RemovePointFromTesselatedSurface( out,point);605 // volume += TesselStruct->RemovePointFromTesselatedSurface(point); 605 606 // } 606 607 // LineRunner = LineAdvance; 607 608 // } 608 609 609 CalculateConcavityPerBoundaryPoint( out,TesselStruct);610 StoreTrianglesinFile( out,mol, (const Tesselation *&)TesselStruct, filename, "");610 CalculateConcavityPerBoundaryPoint(TesselStruct); 611 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 611 612 612 613 // end 613 *out<< Verbose(1) << "Volume is " << volume << "." << endl;614 *out<< Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl;614 Log() << Verbose(1) << "Volume is " << volume << "." << endl; 615 Log() << Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl; 615 616 return volume; 616 617 }; … … 624 625 * \return determined volume of the cluster in cubed config:GetIsAngstroem() 625 626 */ 626 double VolumeOfConvexEnvelope( ofstream *out,class Tesselation *TesselStruct, class config *configuration)627 double VolumeOfConvexEnvelope(class Tesselation *TesselStruct, class config *configuration) 627 628 { 628 629 bool IsAngstroem = configuration->GetIsAngstroem(); … … 632 633 633 634 // 6a. Every triangle forms a pyramid with the center of gravity as its peak, sum up the volumes 634 *out<< Verbose(1)635 Log() << Verbose(1) 635 636 << "Calculating the volume of the pyramids formed out of triangles and center of gravity." 636 637 << endl; … … 649 650 const double h = x.Norm(); // distance of CoG to triangle 650 651 const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak) 651 *out<< Verbose(2) << "Area of triangle is " << setprecision(10) << G << " "652 Log() << Verbose(2) << "Area of triangle is " << setprecision(10) << G << " " 652 653 << (IsAngstroem ? "angstrom" : "atomiclength") << "^2, height is " 653 654 << h << " and the volume is " << PyramidVolume << " " … … 655 656 volume += PyramidVolume; 656 657 } 657 *out << Verbose(0) << "RESULT: The summed volume is " << setprecision(6)658 Log() << Verbose(0) << "RESULT: The summed volume is " << setprecision(8) 658 659 << volume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." 659 660 << endl; … … 669 670 * \param *extraSuffix intermediate suffix 670 671 */ 671 void StoreTrianglesinFile( ofstream *out,const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix)672 void StoreTrianglesinFile(const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix) 672 673 { 673 674 // 4. Store triangles in tecplot file … … 678 679 OutputName.append(TecplotSuffix); 679 680 ofstream *tecplot = new ofstream(OutputName.c_str()); 680 WriteTecplotFile( out,tecplot, TesselStruct, mol, 0);681 WriteTecplotFile(tecplot, TesselStruct, mol, 0); 681 682 tecplot->close(); 682 683 delete(tecplot); … … 687 688 OutputName.append(Raster3DSuffix); 688 689 ofstream *rasterplot = new ofstream(OutputName.c_str()); 689 WriteRaster3dFile( out,rasterplot, TesselStruct, mol);690 WriteRaster3dFile(rasterplot, TesselStruct, mol); 690 691 rasterplot->close(); 691 692 delete(rasterplot); … … 703 704 * \param celldensity desired average density in final cell 704 705 */ 705 void PrepareClustersinWater( ofstream *out,config *configuration, molecule *mol, double ClusterVolume, double celldensity)706 void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity) 706 707 { 707 708 bool IsAngstroem = true; … … 718 719 719 720 // transform to PAS 720 mol->PrincipalAxisSystem( out,true);721 mol->PrincipalAxisSystem(true); 721 722 722 723 IsAngstroem = configuration->GetIsAngstroem(); 723 GreatestDiameter = GetDiametersOfCluster( out,BoundaryPoints, mol, TesselStruct, IsAngstroem);724 BoundaryPoints = GetBoundaryPoints( out,mol, TesselStruct);724 GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem); 725 BoundaryPoints = GetBoundaryPoints(mol, TesselStruct); 725 726 LinkedCell LCList(mol, 10.); 726 FindConvexBorder( out,mol, TesselStruct, &LCList, NULL);727 FindConvexBorder(mol, TesselStruct, &LCList, NULL); 727 728 728 729 // some preparations beforehand 729 730 if (ClusterVolume == 0) 730 clustervolume = VolumeOfConvexEnvelope( out,TesselStruct, configuration);731 clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration); 731 732 else 732 733 clustervolume = ClusterVolume; … … 741 742 totalmass += Walker->type->mass; 742 743 } 743 *out<< Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl;744 *out<< Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;744 Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl; 745 Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 745 746 746 747 // solve cubic polynomial 747 *out<< Verbose(1) << "Solving equidistant suspension in water problem ..." << endl;748 Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl; 748 749 if (IsAngstroem) 749 750 cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1); 750 751 else 751 752 cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_a0 - (totalmass / clustervolume)) / (celldensity - 1); 752 *out<< Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;753 Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 753 754 754 755 double minimumvolume = TotalNoClusters * (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]); 755 *out<< Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;756 Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 756 757 if (minimumvolume > cellvolume) { 757 cerr<< Verbose(0) << "ERROR: the containing box already has a greater volume than the envisaged cell volume!" << endl;758 cout<< Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl;758 eLog() << Verbose(0) << "ERROR: the containing box already has a greater volume than the envisaged cell volume!" << endl; 759 Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl; 759 760 for (int i = 0; i < NDIM; i++) 760 761 BoxLengths.x[i] = GreatestDiameter[i]; 761 mol->CenterEdge( out,&BoxLengths);762 mol->CenterEdge(&BoxLengths); 762 763 } else { 763 764 BoxLengths.x[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]); … … 768 769 double x2 = 0.; 769 770 if (gsl_poly_solve_cubic(BoxLengths.x[0], BoxLengths.x[1], BoxLengths.x[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return 770 *out<< Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;771 Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl; 771 772 else { 772 *out<< Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl;773 Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl; 773 774 x0 = x2; // sorted in ascending order 774 775 } … … 781 782 782 783 // set new box dimensions 783 *out<< Verbose(0) << "Translating to box with these boundaries." << endl;784 Log() << Verbose(0) << "Translating to box with these boundaries." << endl; 784 785 mol->SetBoxDimension(&BoxLengths); 785 mol->CenterInBox( (ofstream *) &cout);786 mol->CenterInBox(); 786 787 } 787 788 // update Box of atoms by boundary 788 789 mol->SetBoxDimension(&BoxLengths); 789 *out<< Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;790 Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl; 790 791 }; 791 792 … … 803 804 * \return *mol pointer to new molecule with filled atoms 804 805 */ 805 molecule * FillBoxWithMolecule( ofstream *out,MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandomAtomDisplacement, double RandomMolDisplacement, bool DoRandomRotation)806 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandomAtomDisplacement, double RandomMolDisplacement, bool DoRandomRotation) 806 807 { 807 808 molecule *Filling = new molecule(filler->elemente); … … 822 823 class Tesselation *TesselStruct[List->ListOfMolecules.size()]; 823 824 824 *out<< Verbose(0) << "Begin of FillBoxWithMolecule" << endl;825 Log() << Verbose(0) << "Begin of FillBoxWithMolecule" << endl; 825 826 826 827 i=0; 827 828 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 828 *out<< Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;829 Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl; 829 830 LCList[i] = new LinkedCell((*ListRunner), 5.); // get linked cell list 830 831 if (TesselStruct[i] == NULL) { 831 *out<< Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;832 FindNonConvexBorder(( ofstream *)&cout, (*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL);832 Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl; 833 FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL); 833 834 } 834 835 i++; … … 836 837 837 838 // Center filler at origin 838 filler->CenterOrigin( out);839 filler->CenterOrigin(); 839 840 filler->Center.Zero(); 840 841 841 filler->CountAtoms( out);842 filler->CountAtoms(); 842 843 atom * CopyAtoms[filler->AtomCount]; 843 844 … … 845 846 FillerDistance.Init(distance[0], distance[1], distance[2]); 846 847 FillerDistance.InverseMatrixMultiplication(M); 847 *out<< Verbose(1) << "INFO: Grid steps are ";848 Log() << Verbose(1) << "INFO: Grid steps are "; 848 849 for(int i=0;i<NDIM;i++) { 849 850 N[i] = (int) ceil(1./FillerDistance.x[i]); 850 *out<< N[i];851 Log() << Verbose(0) << N[i]; 851 852 if (i != NDIM-1) 852 *out<< ", ";853 Log() << Verbose(0)<< ", "; 853 854 else 854 *out<< "." << endl;855 Log() << Verbose(0) << "." << endl; 855 856 } 856 857 … … 862 863 CurrentPosition.Init((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 863 864 CurrentPosition.MatrixMultiplication(M); 864 *out<< Verbose(2) << "INFO: Current Position is " << CurrentPosition << "." << endl;865 Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "." << endl; 865 866 // Check whether point is in- or outside 866 867 FillIt = true; … … 869 870 // get linked cell list 870 871 if (TesselStruct[i] == NULL) { 871 *out<< Verbose(1) << "ERROR: TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;872 Log() << Verbose(1) << "ERROR: TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl; 872 873 FillIt = false; 873 874 } else { 874 FillIt = FillIt && (!TesselStruct[i]->IsInnerPoint( out,CurrentPosition, LCList[i]));875 FillIt = FillIt && (!TesselStruct[i]->IsInnerPoint(CurrentPosition, LCList[i])); 875 876 i++; 876 877 } … … 879 880 if (FillIt) { 880 881 // fill in Filler 881 *out<< Verbose(2) << "Space at " << CurrentPosition << " is unoccupied by any molecule, filling in." << endl;882 Log() << Verbose(2) << "Space at " << CurrentPosition << " is unoccupied by any molecule, filling in." << endl; 882 883 883 884 // create molecule random translation vector ... 884 885 for (int i=0;i<NDIM;i++) 885 886 FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.); 886 *out<< Verbose(3) << "INFO: Translating this filler by " << FillerTranslations << "." << endl;887 Log() << Verbose(3) << "INFO: Translating this filler by " << FillerTranslations << "." << endl; 887 888 888 889 // go through all atoms … … 924 925 925 926 // FIXME: gives completely different results if CopyAtoms[..] used instead of Walker, why??? 926 *out<< Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl;927 Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl; 927 928 Filling->AddAtom(CopyAtoms[Walker->nr]); 928 929 } … … 932 933 while(Binder->next != filler->last) { 933 934 Binder = Binder->next; 934 *out<< Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;935 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 935 936 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 936 937 } 937 938 } else { 938 939 // leave empty 939 *out<< Verbose(2) << "Space at " << CurrentPosition << " is occupied." << endl;940 Log() << Verbose(2) << "Space at " << CurrentPosition << " is occupied." << endl; 940 941 } 941 942 } 942 *out<< Verbose(0) << "End of FillBoxWithMolecule" << endl;943 Log() << Verbose(0) << "End of FillBoxWithMolecule" << endl; 943 944 944 945 return Filling; … … 954 955 * \param *filename filename prefix for output of vertex data 955 956 */ 956 void FindNonConvexBorder( ofstream *out,const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LCList, const double RADIUS, const char *filename = NULL)957 void FindNonConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LCList, const double RADIUS, const char *filename = NULL) 957 958 { 958 959 bool freeLC = false; … … 962 963 bool TesselationFailFlag = false; 963 964 964 *out<< Verbose(1) << "Entering search for non convex hull. " << endl;965 Log() << Verbose(1) << "Entering search for non convex hull. " << endl; 965 966 if (TesselStruct == NULL) { 966 *out<< Verbose(1) << "Allocating Tesselation struct ..." << endl;967 Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl; 967 968 TesselStruct= new Tesselation; 968 969 } else { 969 970 delete(TesselStruct); 970 *out<< Verbose(1) << "Re-Allocating Tesselation struct ..." << endl;971 Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl; 971 972 TesselStruct = new Tesselation; 972 973 } 973 974 974 *out<< Verbose(0) << "Begin of FindNonConvexBorder\n";975 Log() << Verbose(0) << "Begin of FindNonConvexBorder\n"; 975 976 976 977 // initialise Linked Cell … … 981 982 982 983 // 1. get starting triangle 983 TesselStruct->FindStartingTriangle( out,RADIUS, LCList);984 TesselStruct->FindStartingTriangle(RADIUS, LCList); 984 985 985 986 // 2. expand from there … … 989 990 if (baseline->second->triangles.size() == 1) { 990 991 // 3. find next triangle 991 TesselationFailFlag = TesselStruct->FindNextSuitableTriangle( out,*(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one.992 TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one. 992 993 OneLoopWithoutSuccessFlag = OneLoopWithoutSuccessFlag || TesselationFailFlag; 993 994 if (!TesselationFailFlag) 994 cerr<< "WARNING: FindNextSuitableTriangle failed." << endl;995 eLog() << Verbose(0) << "WARNING: FindNextSuitableTriangle failed." << endl; 995 996 996 997 // write temporary envelope 997 998 if (filename != NULL) { 998 999 if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration 999 TesselStruct->Output( out,filename, mol);1000 TesselStruct->Output(filename, mol); 1000 1001 } 1001 1002 } 1002 1003 baseline = TesselStruct->LinesOnBoundary.end(); 1003 *out<< Verbose(2) << "Baseline set to end." << endl;1004 Log() << Verbose(2) << "Baseline set to end." << endl; 1004 1005 } else { 1005 // cout<< Verbose(1) << "Line " << *baseline->second << " has " << baseline->second->triangles.size() << " triangles adjacent" << endl;1006 //Log() << Verbose(1) << "Line " << *baseline->second << " has " << baseline->second->triangles.size() << " triangles adjacent" << endl; 1006 1007 if (baseline->second->triangles.size() != 2) 1007 *out<< Verbose(1) << "ERROR: TESSELATION FINISHED WITH INVALID TRIANGLE COUNT!" << endl;1008 Log() << Verbose(1) << "ERROR: TESSELATION FINISHED WITH INVALID TRIANGLE COUNT!" << endl; 1008 1009 } 1009 1010 … … 1015 1016 } 1016 1017 // check envelope for consistency 1017 CheckListOfBaselines( out,TesselStruct);1018 CheckListOfBaselines(TesselStruct); 1018 1019 1019 1020 // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles 1020 //->InsertStraddlingPoints( out,mol, LCList);1021 //->InsertStraddlingPoints(mol, LCList); 1021 1022 // mol->GoToFirst(); 1022 1023 // class TesselPoint *Runner = NULL; 1023 1024 // while (!mol->IsEnd()) { 1024 1025 // Runner = mol->GetPoint(); 1025 // *out<< Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;1026 // if (!->IsInnerPoint( out,Runner, LCList)) {1027 // *out<< Verbose(2) << Runner->Name << " is outside of envelope, adding via degenerated triangles." << endl;1028 // ->AddBoundaryPointByDegeneratedTriangle( out,Runner, LCList);1026 // Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl; 1027 // if (!->IsInnerPoint(Runner, LCList)) { 1028 // Log() << Verbose(2) << Runner->Name << " is outside of envelope, adding via degenerated triangles." << endl; 1029 // ->AddBoundaryPointByDegeneratedTriangle(Runner, LCList); 1029 1030 // } else { 1030 // *out<< Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;1031 // Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl; 1031 1032 // } 1032 1033 // mol->GoToNext(); … … 1037 1038 1038 1039 // check envelope for consistency 1039 CheckListOfBaselines( out,TesselStruct);1040 CheckListOfBaselines(TesselStruct); 1040 1041 1041 1042 // write final envelope 1042 CalculateConcavityPerBoundaryPoint( out,TesselStruct);1043 StoreTrianglesinFile( out,mol, (const Tesselation *&)TesselStruct, filename, "");1043 CalculateConcavityPerBoundaryPoint(TesselStruct); 1044 StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, ""); 1044 1045 1045 1046 if (freeLC) 1046 1047 delete(LCList); 1047 *out<< Verbose(0) << "End of FindNonConvexBorder\n";1048 Log() << Verbose(0) << "End of FindNonConvexBorder\n"; 1048 1049 }; 1049 1050 … … 1055 1056 * \return *Vector new center of \a *srcmol for embedding relative to \a this 1056 1057 */ 1057 Vector* FindEmbeddingHole( ofstream *out,MoleculeListClass *mols, molecule *srcmol)1058 Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol) 1058 1059 { 1059 1060 Vector *Center = new Vector;
Note:
See TracChangeset
for help on using the changeset viewer.
