Changeset e138de for src/tesselation.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, 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
Legend:
- Unmodified
- Added
- Removed
-
src/tesselation.cpp
r7326b2 re138de 10 10 #include "helpers.hpp" 11 11 #include "linkedcell.hpp" 12 #include "log.hpp" 12 13 #include "tesselation.hpp" 13 14 #include "tesselationhelpers.hpp" … … 45 46 BoundaryPointSet::~BoundaryPointSet() 46 47 { 47 // cout<< Verbose(5) << "Erasing point nr. " << Nr << "." << endl;48 //Log() << Verbose(5) << "Erasing point nr. " << Nr << "." << endl; 48 49 if (!lines.empty()) 49 cerr<< "WARNING: Memory Leak! I " << *this << " am still connected to some lines." << endl;50 eLog() << Verbose(0) << "WARNING: Memory Leak! I " << *this << " am still connected to some lines." << endl; 50 51 node = NULL; 51 52 }; … … 56 57 void BoundaryPointSet::AddLine(class BoundaryLineSet *line) 57 58 { 58 cout<< Verbose(6) << "Adding " << *this << " to line " << *line << "."59 Log() << Verbose(6) << "Adding " << *this << " to line " << *line << "." 59 60 << endl; 60 61 if (line->endpoints[0] == this) … … 106 107 Point[1]->AddLine(this); // 107 108 // clear triangles list 108 cout<< Verbose(5) << "New Line with endpoints " << *this << "." << endl;109 Log() << Verbose(5) << "New Line with endpoints " << *this << "." << endl; 109 110 }; 110 111 … … 133 134 for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++) 134 135 if ((*Runner).second == this) { 135 // cout<< Verbose(5) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;136 //Log() << Verbose(5) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl; 136 137 endpoints[i]->lines.erase(Runner); 137 138 break; … … 139 140 } else { // there's just a single line left 140 141 if (endpoints[i]->lines.erase(Nr)) { 141 // cout<< Verbose(5) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;142 //Log() << Verbose(5) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl; 142 143 } 143 144 } 144 145 if (endpoints[i]->lines.empty()) { 145 // cout<< Verbose(5) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;146 //Log() << Verbose(5) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl; 146 147 if (endpoints[i] != NULL) { 147 148 delete(endpoints[i]); … … 152 153 } 153 154 if (!triangles.empty()) 154 cerr<< "WARNING: Memory Leak! I " << *this << " am still connected to some triangles." << endl;155 eLog() << Verbose(0) << "WARNING: Memory Leak! I " << *this << " am still connected to some triangles." << endl; 155 156 }; 156 157 … … 160 161 void BoundaryLineSet::AddTriangle(class BoundaryTriangleSet *triangle) 161 162 { 162 cout<< Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." << endl;163 Log() << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." << endl; 163 164 triangles.insert(TrianglePair(triangle->Nr, triangle)); 164 165 }; … … 182 183 * \return true - triangles are convex, false - concave or less than two triangles connected 183 184 */ 184 bool BoundaryLineSet::CheckConvexityCriterion( ofstream *out)185 bool BoundaryLineSet::CheckConvexityCriterion() 185 186 { 186 187 Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck; 187 188 // get the two triangles 188 189 if (triangles.size() != 2) { 189 *out<< Verbose(1) << "ERROR: Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl;190 Log() << Verbose(1) << "ERROR: Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl; 190 191 return true; 191 192 } 192 193 // check normal vectors 193 194 // have a normal vector on the base line pointing outwards 194 // *out<< Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;195 //Log() << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl; 195 196 BaseLineCenter.CopyVector(endpoints[0]->node->node); 196 197 BaseLineCenter.AddVector(endpoints[1]->node->node); … … 198 199 BaseLine.CopyVector(endpoints[0]->node->node); 199 200 BaseLine.SubtractVector(endpoints[1]->node->node); 200 // *out<< Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;201 //Log() << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl; 201 202 202 203 BaseLineNormal.Zero(); … … 206 207 class BoundaryPointSet *node = NULL; 207 208 for(TriangleMap::iterator runner = triangles.begin(); runner != triangles.end(); runner++) { 208 // *out<< Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;209 //Log() << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl; 209 210 NormalCheck.AddVector(&runner->second->NormalVector); 210 211 NormalCheck.Scale(sign); … … 213 214 BaseLineNormal.CopyVector(&runner->second->NormalVector); // yes, copy second on top of first 214 215 else { 215 *out<< Verbose(1) << "CRITICAL: Triangle " << *runner->second << " has zero normal vector!" << endl;216 Log() << Verbose(1) << "CRITICAL: Triangle " << *runner->second << " has zero normal vector!" << endl; 216 217 exit(255); 217 218 } 218 219 node = runner->second->GetThirdEndpoint(this); 219 220 if (node != NULL) { 220 // *out<< Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;221 //Log() << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl; 221 222 helper[i].CopyVector(node->node->node); 222 223 helper[i].SubtractVector(&BaseLineCenter); 223 224 helper[i].MakeNormalVector(&BaseLine); // we want to compare the triangle's heights' angles! 224 // *out<< Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;225 //Log() << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl; 225 226 i++; 226 227 } else { 227 // *out<< Verbose(2) << "ERROR: I cannot find third node in triangle, something's wrong." << endl;228 //Log() << Verbose(2) << "ERROR: I cannot find third node in triangle, something's wrong." << endl; 228 229 return true; 229 230 } 230 231 } 231 // *out<< Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;232 //Log() << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl; 232 233 if (NormalCheck.NormSquared() < MYEPSILON) { 233 *out<< Verbose(3) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl;234 Log() << Verbose(3) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl; 234 235 return true; 235 236 } … … 237 238 double angle = GetAngle(helper[0], helper[1], BaseLineNormal); 238 239 if ((angle - M_PI) > -MYEPSILON) { 239 *out<< Verbose(3) << "ACCEPT: Angle is greater than pi: convex." << endl;240 Log() << Verbose(3) << "ACCEPT: Angle is greater than pi: convex." << endl; 240 241 return true; 241 242 } else { 242 *out<< Verbose(3) << "REJECT: Angle is less than pi: concave." << endl;243 Log() << Verbose(3) << "REJECT: Angle is less than pi: concave." << endl; 243 244 return false; 244 245 } … … 304 305 Nr = number; 305 306 // set lines 306 cout<< Verbose(5) << "New triangle " << Nr << ":" << endl;307 Log() << Verbose(5) << "New triangle " << Nr << ":" << endl; 307 308 for (int i = 0; i < 3; i++) 308 309 { … … 322 323 // set endpoints 323 324 int Counter = 0; 324 cout<< Verbose(6) << " with end points ";325 Log() << Verbose(6) << " with end points "; 325 326 for (map<int, class BoundaryPointSet *>::iterator runner = OrderMap.begin(); runner 326 327 != OrderMap.end(); runner++) 327 328 { 328 329 endpoints[Counter] = runner->second; 329 cout<< " " << *endpoints[Counter];330 Log() << Verbose(0) << " " << *endpoints[Counter]; 330 331 Counter++; 331 332 } 332 333 if (Counter < 3) 333 334 { 334 cerr<< "ERROR! We have a triangle with only two distinct endpoints!"335 eLog() << Verbose(0) << "ERROR! We have a triangle with only two distinct endpoints!" 335 336 << endl; 336 337 //exit(1); 337 338 } 338 cout<< "." << endl;339 Log() << Verbose(0) << "." << endl; 339 340 }; 340 341 … … 348 349 if (lines[i] != NULL) { 349 350 if (lines[i]->triangles.erase(Nr)) { 350 // cout<< Verbose(5) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl;351 //Log() << Verbose(5) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl; 351 352 } 352 353 if (lines[i]->triangles.empty()) { 353 // cout<< Verbose(5) << *lines[i] << " is no more attached to any triangle, erasing." << endl;354 //Log() << Verbose(5) << *lines[i] << " is no more attached to any triangle, erasing." << endl; 354 355 delete (lines[i]); 355 356 lines[i] = NULL; … … 357 358 } 358 359 } 359 // cout<< Verbose(5) << "Erasing triangle Nr." << Nr << " itself." << endl;360 //Log() << Verbose(5) << "Erasing triangle Nr." << Nr << " itself." << endl; 360 361 }; 361 362 … … 386 387 * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle. 387 388 */ 388 bool BoundaryTriangleSet::GetIntersectionInsideTriangle( ofstream *out,Vector *MolCenter, Vector *x, Vector *Intersection)389 bool BoundaryTriangleSet::GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection) 389 390 { 390 391 Vector CrossPoint; 391 392 Vector helper; 392 393 393 if (!Intersection->GetIntersectionWithPlane( out,&NormalVector, endpoints[0]->node->node, MolCenter, x)) {394 *out<< Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl;394 if (!Intersection->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, MolCenter, x)) { 395 Log() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl; 395 396 return false; 396 397 } … … 399 400 int i=0; 400 401 do { 401 if (CrossPoint.GetIntersectionOfTwoLinesOnPlane( out,endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) {402 if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) { 402 403 helper.CopyVector(endpoints[(i+1)%3]->node->node); 403 404 helper.SubtractVector(endpoints[i%3]->node->node); … … 408 409 } while (CrossPoint.NormSquared() < MYEPSILON); 409 410 if (i==3) { 410 *out<< Verbose(1) << "ERROR: Could not find any cross points, something's utterly wrong here!" << endl;411 Log() << Verbose(1) << "ERROR: Could not find any cross points, something's utterly wrong here!" << endl; 411 412 exit(255); 412 413 } … … 627 628 Tesselation::~Tesselation() 628 629 { 629 cout<< Verbose(1) << "Free'ing TesselStruct ... " << endl;630 Log() << Verbose(1) << "Free'ing TesselStruct ... " << endl; 630 631 for (TriangleMap::iterator runner = TrianglesOnBoundary.begin(); runner != TrianglesOnBoundary.end(); runner++) { 631 632 if (runner->second != NULL) { … … 633 634 runner->second = NULL; 634 635 } else 635 cerr<< "ERROR: The triangle " << runner->first << " has already been free'd." << endl;636 } 637 cout<< "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl;636 eLog() << Verbose(1) << "ERROR: The triangle " << runner->first << " has already been free'd." << endl; 637 } 638 Log() << Verbose(1) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl; 638 639 } 639 640 ; … … 730 731 */ 731 732 void 732 Tesselation::GuessStartingTriangle( ofstream *out)733 Tesselation::GuessStartingTriangle() 733 734 { 734 735 // 4b. create a starting triangle … … 762 763 } 763 764 // // listing distances 764 // *out<< Verbose(1) << "Listing DistanceMMap:";765 // Log() << Verbose(1) << "Listing DistanceMMap:"; 765 766 // for(DistanceMultiMap::iterator runner = DistanceMMap.begin(); runner != DistanceMMap.end(); runner++) { 766 // *out<< " " << runner->first << "(" << *runner->second.first->second << ", " << *runner->second.second->second << ")";767 // Log() << Verbose(0) << " " << runner->first << "(" << *runner->second.first->second << ", " << *runner->second.second->second << ")"; 767 768 // } 768 // *out<< endl;769 // Log() << Verbose(0) << endl; 769 770 // 4b2. pick three baselines forming a triangle 770 771 // 1. we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate … … 778 779 baseline->second.first->second->node->node, 779 780 baseline->second.second->second->node->node); 780 *out<< Verbose(2) << "Plane vector of candidate triangle is ";781 PlaneVector.Output( out);782 *out<< endl;781 Log() << Verbose(2) << "Plane vector of candidate triangle is "; 782 PlaneVector.Output(); 783 Log() << Verbose(0) << endl; 783 784 // 4. loop over all points 784 785 double sign = 0.; … … 796 797 if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok 797 798 continue; 798 *out<< Verbose(3) << "Projection of " << checker->second->node->Name799 Log() << Verbose(3) << "Projection of " << checker->second->node->Name 799 800 << " yields distance of " << distance << "." << endl; 800 801 tmp = distance / fabs(distance); … … 803 804 { 804 805 // 4c. If so, break 4. loop and continue with next candidate in 1. loop 805 *out<< Verbose(2) << "Current candidates: "806 Log() << Verbose(2) << "Current candidates: " 806 807 << A->second->node->Name << "," 807 808 << baseline->second.first->second->node->Name << "," … … 813 814 else 814 815 { // note the sign for later 815 *out<< Verbose(2) << "Current candidates: "816 Log() << Verbose(2) << "Current candidates: " 816 817 << A->second->node->Name << "," 817 818 << baseline->second.first->second->node->Name << "," … … 850 851 if (checker == PointsOnBoundary.end()) 851 852 { 852 *out<< "Looks like we have a candidate!" << endl;853 Log() << Verbose(0) << "Looks like we have a candidate!" << endl; 853 854 break; 854 855 } … … 876 877 } 877 878 878 *out<< Verbose(1) << "Starting triangle is " << *BTS << "." << endl;879 Log() << Verbose(1) << "Starting triangle is " << *BTS << "." << endl; 879 880 } 880 881 else 881 882 { 882 *out<< Verbose(1) << "No starting triangle found." << endl;883 Log() << Verbose(1) << "No starting triangle found." << endl; 883 884 exit(255); 884 885 } … … 899 900 * \param *cloud cluster of points 900 901 */ 901 void Tesselation::TesselateOnBoundary( ofstream *out,const PointCloud * const cloud)902 void Tesselation::TesselateOnBoundary(const PointCloud * const cloud) 902 903 { 903 904 bool flag; … … 908 909 LineMap::iterator LineChecker[2]; 909 910 910 Center = cloud->GetCenter( out);911 Center = cloud->GetCenter(); 911 912 // create a first tesselation with the given BoundaryPoints 912 913 do { … … 919 920 // get peak point with respect to this base line's only triangle 920 921 BTS = baseline->second->triangles.begin()->second; // there is only one triangle so far 921 *out<< Verbose(2) << "Current baseline is between " << *(baseline->second) << "." << endl;922 Log() << Verbose(2) << "Current baseline is between " << *(baseline->second) << "." << endl; 922 923 for (int i = 0; i < 3; i++) 923 924 if ((BTS->endpoints[i] != baseline->second->endpoints[0]) && (BTS->endpoints[i] != baseline->second->endpoints[1])) 924 925 peak = BTS->endpoints[i]; 925 *out<< Verbose(3) << " and has peak " << *peak << "." << endl;926 Log() << Verbose(3) << " and has peak " << *peak << "." << endl; 926 927 927 928 // prepare some auxiliary vectors … … 938 939 CenterVector.AddVector(BTS->endpoints[i]->node->node); 939 940 CenterVector.Scale(1. / 3.); 940 *out<< Verbose(4) << "CenterVector of base triangle is " << CenterVector << endl;941 Log() << Verbose(4) << "CenterVector of base triangle is " << CenterVector << endl; 941 942 942 943 // normal vector of triangle … … 945 946 BTS->GetNormalVector(NormalVector); 946 947 NormalVector.CopyVector(&BTS->NormalVector); 947 *out<< Verbose(4) << "NormalVector of base triangle is " << NormalVector << endl;948 Log() << Verbose(4) << "NormalVector of base triangle is " << NormalVector << endl; 948 949 949 950 // vector in propagation direction (out of triangle) … … 952 953 TempVector.CopyVector(&CenterVector); 953 954 TempVector.SubtractVector(baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center! 954 // *out<< Verbose(2) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl;955 //Log() << Verbose(2) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl; 955 956 if (PropagationVector.ScalarProduct(&TempVector) > 0) // make sure normal propagation vector points outward from baseline 956 957 PropagationVector.Scale(-1.); 957 *out<< Verbose(4) << "PropagationVector of base triangle is " << PropagationVector << endl;958 Log() << Verbose(4) << "PropagationVector of base triangle is " << PropagationVector << endl; 958 959 winner = PointsOnBoundary.end(); 959 960 … … 961 962 for (PointMap::iterator target = PointsOnBoundary.begin(); target != PointsOnBoundary.end(); target++) { 962 963 if ((target->second != baseline->second->endpoints[0]) && (target->second != baseline->second->endpoints[1])) { // don't take the same endpoints 963 *out<< Verbose(3) << "Target point is " << *(target->second) << ":" << endl;964 Log() << Verbose(3) << "Target point is " << *(target->second) << ":" << endl; 964 965 965 966 // first check direction, so that triangles don't intersect … … 968 969 VirtualNormalVector.ProjectOntoPlane(&NormalVector); 969 970 TempAngle = VirtualNormalVector.Angle(&PropagationVector); 970 *out<< Verbose(4) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;971 Log() << Verbose(4) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl; 971 972 if (TempAngle > (M_PI/2.)) { // no bends bigger than Pi/2 (90 degrees) 972 *out<< Verbose(4) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl;973 Log() << Verbose(4) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl; 973 974 continue; 974 975 } else 975 *out<< Verbose(4) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl;976 Log() << Verbose(4) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl; 976 977 977 978 // check first and second endpoint (if any connecting line goes to target has at least not more than 1 triangle) … … 979 980 LineChecker[1] = baseline->second->endpoints[1]->lines.find(target->first); 980 981 if (((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[0]->second->triangles.size() == 2))) { 981 *out<< Verbose(4) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl;982 Log() << Verbose(4) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl; 982 983 continue; 983 984 } 984 985 if (((LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (LineChecker[1]->second->triangles.size() == 2))) { 985 *out<< Verbose(4) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl;986 Log() << Verbose(4) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl; 986 987 continue; 987 988 } … … 989 990 // check whether the envisaged triangle does not already exist (if both lines exist and have same endpoint) 990 991 if ((((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (GetCommonEndpoint(LineChecker[0]->second, LineChecker[1]->second) == peak)))) { 991 *out<< Verbose(4) << "Current target is peak!" << endl;992 Log() << Verbose(4) << "Current target is peak!" << endl; 992 993 continue; 993 994 } … … 1000 1001 helper.ProjectOntoPlane(&TempVector); 1001 1002 if (fabs(helper.NormSquared()) < MYEPSILON) { 1002 *out<< Verbose(4) << "Chosen set of vectors is linear dependent." << endl;1003 Log() << Verbose(4) << "Chosen set of vectors is linear dependent." << endl; 1003 1004 continue; 1004 1005 } … … 1017 1018 // calculate angle 1018 1019 TempAngle = NormalVector.Angle(&VirtualNormalVector); 1019 *out<< Verbose(4) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl;1020 Log() << Verbose(4) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl; 1020 1021 if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner 1021 1022 SmallestAngle = TempAngle; 1022 1023 winner = target; 1023 *out<< Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;1024 Log() << Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl; 1024 1025 } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle) 1025 1026 // hence, check the angles to some normal direction from our base line but in this common plane of both targets... … … 1039 1040 SmallestAngle = TempAngle; 1040 1041 winner = target; 1041 *out<< Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl;1042 Log() << Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl; 1042 1043 } else 1043 *out<< Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl;1044 Log() << Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl; 1044 1045 } else 1045 *out<< Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;1046 Log() << Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl; 1046 1047 } 1047 1048 } // end of loop over all boundary points … … 1049 1050 // 5b. The point of the above whose triangle has the greatest angle with the triangle the current line belongs to (it only belongs to one, remember!): New triangle 1050 1051 if (winner != PointsOnBoundary.end()) { 1051 *out<< Verbose(2) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl;1052 Log() << Verbose(2) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl; 1052 1053 // create the lins of not yet present 1053 1054 BLS[0] = baseline->second; … … 1079 1080 TrianglesOnBoundaryCount++; 1080 1081 } else { 1081 *out<< Verbose(1) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl;1082 Log() << Verbose(1) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl; 1082 1083 } 1083 1084 1084 1085 // 5d. If the set of lines is not yet empty, go to 5. and continue 1085 1086 } else 1086 *out<< Verbose(2) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl;1087 Log() << Verbose(2) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl; 1087 1088 } while (flag); 1088 1089 … … 1097 1098 * \return true - all straddling points insert, false - something went wrong 1098 1099 */ 1099 bool Tesselation::InsertStraddlingPoints( ofstream *out,const PointCloud *cloud, const LinkedCell *LC)1100 bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC) 1100 1101 { 1101 1102 Vector Intersection, Normal; 1102 1103 TesselPoint *Walker = NULL; 1103 Vector *Center = cloud->GetCenter( out);1104 Vector *Center = cloud->GetCenter(); 1104 1105 list<BoundaryTriangleSet*> *triangles = NULL; 1105 1106 bool AddFlag = false; 1106 1107 LinkedCell *BoundaryPoints = NULL; 1107 1108 1108 *out<< Verbose(1) << "Begin of InsertStraddlingPoints" << endl;1109 Log() << Verbose(1) << "Begin of InsertStraddlingPoints" << endl; 1109 1110 1110 1111 cloud->GoToFirst(); … … 1117 1118 } 1118 1119 Walker = cloud->GetPoint(); 1119 *out<< Verbose(2) << "Current point is " << *Walker << "." << endl;1120 Log() << Verbose(2) << "Current point is " << *Walker << "." << endl; 1120 1121 // get the next triangle 1121 triangles = FindClosestTrianglesToPoint( out,Walker->node, BoundaryPoints);1122 triangles = FindClosestTrianglesToPoint(Walker->node, BoundaryPoints); 1122 1123 BTS = triangles->front(); 1123 1124 if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) { 1124 *out<< Verbose(2) << "No triangles found, probably a tesselation point itself." << endl;1125 Log() << Verbose(2) << "No triangles found, probably a tesselation point itself." << endl; 1125 1126 cloud->GoToNext(); 1126 1127 continue; 1127 1128 } else { 1128 1129 } 1129 *out<< Verbose(2) << "Closest triangle is " << *BTS << "." << endl;1130 Log() << Verbose(2) << "Closest triangle is " << *BTS << "." << endl; 1130 1131 // get the intersection point 1131 if (BTS->GetIntersectionInsideTriangle( out,Center, Walker->node, &Intersection)) {1132 *out<< Verbose(2) << "We have an intersection at " << Intersection << "." << endl;1132 if (BTS->GetIntersectionInsideTriangle(Center, Walker->node, &Intersection)) { 1133 Log() << Verbose(2) << "We have an intersection at " << Intersection << "." << endl; 1133 1134 // we have the intersection, check whether in- or outside of boundary 1134 1135 if ((Center->DistanceSquared(Walker->node) - Center->DistanceSquared(&Intersection)) < -MYEPSILON) { 1135 1136 // inside, next! 1136 *out<< Verbose(2) << *Walker << " is inside wrt triangle " << *BTS << "." << endl;1137 Log() << Verbose(2) << *Walker << " is inside wrt triangle " << *BTS << "." << endl; 1137 1138 } else { 1138 1139 // outside! 1139 *out<< Verbose(2) << *Walker << " is outside wrt triangle " << *BTS << "." << endl;1140 Log() << Verbose(2) << *Walker << " is outside wrt triangle " << *BTS << "." << endl; 1140 1141 class BoundaryLineSet *OldLines[3], *NewLines[3]; 1141 1142 class BoundaryPointSet *OldPoints[3], *NewPoint; … … 1147 1148 Normal.CopyVector(&BTS->NormalVector); 1148 1149 // add Walker to boundary points 1149 *out<< Verbose(2) << "Adding " << *Walker << " to BoundaryPoints." << endl;1150 Log() << Verbose(2) << "Adding " << *Walker << " to BoundaryPoints." << endl; 1150 1151 AddFlag = true; 1151 1152 if (AddBoundaryPoint(Walker,0)) … … 1154 1155 continue; 1155 1156 // remove triangle 1156 *out<< Verbose(2) << "Erasing triangle " << *BTS << "." << endl;1157 Log() << Verbose(2) << "Erasing triangle " << *BTS << "." << endl; 1157 1158 TrianglesOnBoundary.erase(BTS->Nr); 1158 1159 delete(BTS); … … 1162 1163 BPS[1] = OldPoints[i]; 1163 1164 NewLines[i] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); 1164 *out<< Verbose(3) << "Creating new line " << *NewLines[i] << "." << endl;1165 Log() << Verbose(3) << "Creating new line " << *NewLines[i] << "." << endl; 1165 1166 LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, NewLines[i])); // no need for check for unique insertion as BPS[0] is definitely a new one 1166 1167 LinesOnBoundaryCount++; … … 1173 1174 if (NewLines[j]->IsConnectedTo(BLS[0])) { 1174 1175 if (n>2) { 1175 *out<< Verbose(1) << "ERROR: " << BLS[0] << " connects to all of the new lines?!" << endl;1176 Log() << Verbose(1) << "ERROR: " << BLS[0] << " connects to all of the new lines?!" << endl; 1176 1177 return false; 1177 1178 } else … … 1184 1185 BTS->GetNormalVector(Normal); 1185 1186 Normal.Scale(-1.); 1186 *out<< Verbose(2) << "Created new triangle " << *BTS << "." << endl;1187 Log() << Verbose(2) << "Created new triangle " << *BTS << "." << endl; 1187 1188 TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS)); 1188 1189 TrianglesOnBoundaryCount++; … … 1190 1191 } 1191 1192 } else { // something is wrong with FindClosestTriangleToPoint! 1192 *out<< Verbose(1) << "ERROR: The closest triangle did not produce an intersection!" << endl;1193 Log() << Verbose(1) << "ERROR: The closest triangle did not produce an intersection!" << endl; 1193 1194 return false; 1194 1195 } … … 1198 1199 // exit 1199 1200 delete(Center); 1200 *out<< Verbose(1) << "End of InsertStraddlingPoints" << endl;1201 Log() << Verbose(1) << "End of InsertStraddlingPoints" << endl; 1201 1202 return true; 1202 1203 }; … … 1237 1238 } else { 1238 1239 delete TPS[n]; 1239 cout<< Verbose(4) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl;1240 Log() << Verbose(4) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl; 1240 1241 TPS[n] = (InsertUnique.first)->second; 1241 1242 } … … 1257 1258 pair<LineMap::iterator,LineMap::iterator> FindPair; 1258 1259 FindPair = a->lines.equal_range(b->node->nr); 1259 cout<< Verbose(5) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl;1260 Log() << Verbose(5) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl; 1260 1261 1261 1262 for (FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) { … … 1263 1264 if (FindLine->second->triangles.size() < 2) { 1264 1265 insertNewLine = false; 1265 cout<< Verbose(4) << "Using existing line " << *FindLine->second << endl;1266 Log() << Verbose(4) << "Using existing line " << *FindLine->second << endl; 1266 1267 1267 1268 BPS[0] = FindLine->second->endpoints[0]; … … 1290 1291 void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) 1291 1292 { 1292 cout<< Verbose(4) << "Adding line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;1293 Log() << Verbose(4) << "Adding line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl; 1293 1294 BPS[0] = a; 1294 1295 BPS[1] = b; … … 1305 1306 void Tesselation::AddTesselationTriangle() 1306 1307 { 1307 cout<< Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;1308 Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl; 1308 1309 1309 1310 // add triangle to global map … … 1323 1324 void Tesselation::AddTesselationTriangle(const int nr) 1324 1325 { 1325 cout<< Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;1326 Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl; 1326 1327 1327 1328 // add triangle to global map … … 1345 1346 for (int i = 0; i < 3; i++) { 1346 1347 if (triangle->lines[i] != NULL) { 1347 cout<< Verbose(5) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl;1348 Log() << Verbose(5) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl; 1348 1349 triangle->lines[i]->triangles.erase(triangle->Nr); 1349 1350 if (triangle->lines[i]->triangles.empty()) { 1350 cout<< Verbose(5) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl;1351 Log() << Verbose(5) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl; 1351 1352 RemoveTesselationLine(triangle->lines[i]); 1352 1353 } else { 1353 cout<< Verbose(5) << *triangle->lines[i] << " is still attached to another triangle: ";1354 Log() << Verbose(5) << *triangle->lines[i] << " is still attached to another triangle: "; 1354 1355 for(TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++) 1355 cout<< "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t";1356 cout<< endl;1356 Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t"; 1357 Log() << Verbose(0) << endl; 1357 1358 // for (int j=0;j<2;j++) { 1358 // cout<< Verbose(5) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": ";1359 // Log() << Verbose(5) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": "; 1359 1360 // for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++) 1360 // cout<< "[" << *(LineRunner->second) << "] \t";1361 // cout<< endl;1361 // Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t"; 1362 // Log() << Verbose(0) << endl; 1362 1363 // } 1363 1364 } 1364 1365 triangle->lines[i] = NULL; // free'd or not: disconnect 1365 1366 } else 1366 cerr<< "ERROR: This line " << i << " has already been free'd." << endl;1367 eLog() << Verbose(0) << "ERROR: This line " << i << " has already been free'd." << endl; 1367 1368 } 1368 1369 1369 1370 if (TrianglesOnBoundary.erase(triangle->Nr)) 1370 cout<< Verbose(5) << "Removing triangle Nr. " << triangle->Nr << "." << endl;1371 Log() << Verbose(5) << "Removing triangle Nr. " << triangle->Nr << "." << endl; 1371 1372 delete(triangle); 1372 1373 }; … … 1398 1399 for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++) 1399 1400 if ((*Runner).second == line) { 1400 cout<< Verbose(5) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;1401 Log() << Verbose(5) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl; 1401 1402 line->endpoints[i]->lines.erase(Runner); 1402 1403 break; … … 1404 1405 } else { // there's just a single line left 1405 1406 if (line->endpoints[i]->lines.erase(line->Nr)) 1406 cout<< Verbose(5) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;1407 Log() << Verbose(5) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl; 1407 1408 } 1408 1409 if (line->endpoints[i]->lines.empty()) { 1409 cout<< Verbose(5) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl;1410 Log() << Verbose(5) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl; 1410 1411 RemoveTesselationPoint(line->endpoints[i]); 1411 1412 } else { 1412 cout<< Verbose(5) << *line->endpoints[i] << " has still lines it's attached to: ";1413 Log() << Verbose(5) << *line->endpoints[i] << " has still lines it's attached to: "; 1413 1414 for(LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++) 1414 cout<< "[" << *(LineRunner->second) << "] \t";1415 cout<< endl;1415 Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t"; 1416 Log() << Verbose(0) << endl; 1416 1417 } 1417 1418 line->endpoints[i] = NULL; // free'd or not: disconnect 1418 1419 } else 1419 cerr<< "ERROR: Endpoint " << i << " has already been free'd." << endl;1420 eLog() << Verbose(0) << "ERROR: Endpoint " << i << " has already been free'd." << endl; 1420 1421 } 1421 1422 if (!line->triangles.empty()) 1422 cerr<< "WARNING: Memory Leak! I " << *line << " am still connected to some triangles." << endl;1423 eLog() << Verbose(0) << "WARNING: Memory Leak! I " << *line << " am still connected to some triangles." << endl; 1423 1424 1424 1425 if (LinesOnBoundary.erase(line->Nr)) 1425 cout<< Verbose(5) << "Removing line Nr. " << line->Nr << "." << endl;1426 Log() << Verbose(5) << "Removing line Nr. " << line->Nr << "." << endl; 1426 1427 delete(line); 1427 1428 }; … … 1437 1438 return; 1438 1439 if (PointsOnBoundary.erase(point->Nr)) 1439 cout<< Verbose(5) << "Removing point Nr. " << point->Nr << "." << endl;1440 Log() << Verbose(5) << "Removing point Nr. " << point->Nr << "." << endl; 1440 1441 delete(point); 1441 1442 }; … … 1450 1451 * triangles exist which is the maximum for three points 1451 1452 */ 1452 int Tesselation::CheckPresenceOfTriangle( ofstream *out,TesselPoint *Candidates[3]) {1453 int Tesselation::CheckPresenceOfTriangle(TesselPoint *Candidates[3]) { 1453 1454 int adjacentTriangleCount = 0; 1454 1455 class BoundaryPointSet *Points[3]; 1455 1456 1456 *out<< Verbose(2) << "Begin of CheckPresenceOfTriangle" << endl;1457 Log() << Verbose(2) << "Begin of CheckPresenceOfTriangle" << endl; 1457 1458 // builds a triangle point set (Points) of the end points 1458 1459 for (int i = 0; i < 3; i++) { … … 1473 1474 for (; (FindLine != Points[i]->lines.end()) && (FindLine->first == Points[j]->node->nr); FindLine++) { 1474 1475 TriangleMap *triangles = &FindLine->second->triangles; 1475 *out<< Verbose(3) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl;1476 Log() << Verbose(3) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl; 1476 1477 for (TriangleMap::iterator FindTriangle = triangles->begin(); FindTriangle != triangles->end(); FindTriangle++) { 1477 1478 if (FindTriangle->second->IsPresentTupel(Points)) { … … 1479 1480 } 1480 1481 } 1481 *out<< Verbose(3) << "end." << endl;1482 Log() << Verbose(3) << "end." << endl; 1482 1483 } 1483 1484 // Only one of the triangle lines must be considered for the triangle count. 1484 // *out<< Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;1485 //Log() << Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl; 1485 1486 //return adjacentTriangleCount; 1486 1487 } … … 1489 1490 } 1490 1491 1491 *out<< Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;1492 *out<< Verbose(2) << "End of CheckPresenceOfTriangle" << endl;1492 Log() << Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl; 1493 Log() << Verbose(2) << "End of CheckPresenceOfTriangle" << endl; 1493 1494 return adjacentTriangleCount; 1494 1495 }; … … 1502 1503 * \return NULL - none found or pointer to triangle 1503 1504 */ 1504 class BoundaryTriangleSet * Tesselation::GetPresentTriangle( ofstream *out,TesselPoint *Candidates[3])1505 class BoundaryTriangleSet * Tesselation::GetPresentTriangle(TesselPoint *Candidates[3]) 1505 1506 { 1506 1507 class BoundaryTriangleSet *triangle = NULL; … … 1533 1534 } 1534 1535 // Only one of the triangle lines must be considered for the triangle count. 1535 // *out<< Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;1536 //Log() << Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl; 1536 1537 //return adjacentTriangleCount; 1537 1538 } … … 1552 1553 * \param *LC LinkedCell structure with neighbouring TesselPoint's 1553 1554 */ 1554 void Tesselation::FindStartingTriangle( ofstream *out,const double RADIUS, const LinkedCell *LC)1555 { 1556 cout<< Verbose(1) << "Begin of FindStartingTriangle\n";1555 void Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC) 1556 { 1557 Log() << Verbose(1) << "Begin of FindStartingTriangle\n"; 1557 1558 int i = 0; 1558 1559 TesselPoint* FirstPoint = NULL; … … 1578 1579 for (LC->n[(i+2)%NDIM]=0;LC->n[(i+2)%NDIM]<LC->N[(i+2)%NDIM];LC->n[(i+2)%NDIM]++) { 1579 1580 const LinkedNodes *List = LC->GetCurrentCell(); 1580 // cout<< Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;1581 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 1581 1582 if (List != NULL) { 1582 1583 for (LinkedNodes::const_iterator Runner = List->begin();Runner != List->end();Runner++) { 1583 1584 if ((*Runner)->node->x[i] > maxCoordinate[i]) { 1584 cout<< Verbose(2) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl;1585 Log() << Verbose(2) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl; 1585 1586 maxCoordinate[i] = (*Runner)->node->x[i]; 1586 1587 MaxPoint[i] = (*Runner); … … 1588 1589 } 1589 1590 } else { 1590 cerr<< "ERROR: The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;1591 eLog() << Verbose(0) << "ERROR: The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl; 1591 1592 } 1592 1593 } 1593 1594 } 1594 1595 1595 cout<< Verbose(2) << "Found maximum coordinates: ";1596 Log() << Verbose(2) << "Found maximum coordinates: "; 1596 1597 for (int i=0;i<NDIM;i++) 1597 cout<< i << ": " << *MaxPoint[i] << "\t";1598 cout<< endl;1598 Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t"; 1599 Log() << Verbose(0) << endl; 1599 1600 1600 1601 BTS = NULL; … … 1604 1605 Oben.x[k] = 1.; 1605 1606 FirstPoint = MaxPoint[k]; 1606 cout<< Verbose(1) << "Coordinates of start node at " << *FirstPoint->node << "." << endl;1607 Log() << Verbose(1) << "Coordinates of start node at " << *FirstPoint->node << "." << endl; 1607 1608 1608 1609 double ShortestAngle; … … 1635 1636 1636 1637 // adding point 1 and point 2 and add the line between them 1637 cout<< Verbose(1) << "Coordinates of start node at " << *FirstPoint->node << "." << endl;1638 Log() << Verbose(1) << "Coordinates of start node at " << *FirstPoint->node << "." << endl; 1638 1639 AddTesselationPoint(FirstPoint, 0); 1639 cout<< Verbose(1) << "Found second point is at " << *SecondPoint->node << ".\n";1640 Log() << Verbose(1) << "Found second point is at " << *SecondPoint->node << ".\n"; 1640 1641 AddTesselationPoint(SecondPoint, 1); 1641 1642 AddTesselationLine(TPS[0], TPS[1], 0); 1642 1643 1643 // cout<< Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n";1644 //Log() << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n"; 1644 1645 FindThirdPointForTesselation(Oben, SearchDirection, helper, BLS[0], NULL, *&OptCandidates, &ShortestAngle, RADIUS, LC); 1645 cout<< Verbose(1) << "List of third Points is ";1646 Log() << Verbose(1) << "List of third Points is "; 1646 1647 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1647 cout<< " " << *(*it)->point;1648 } 1649 cout<< endl;1648 Log() << Verbose(0) << " " << *(*it)->point; 1649 } 1650 Log() << Verbose(0) << endl; 1650 1651 1651 1652 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { … … 1660 1661 // ... and calculate its normal vector (with correct orientation) 1661 1662 (*it)->OptCenter.Scale(-1.); 1662 cout<< Verbose(2) << "Anti-Oben is currently " << (*it)->OptCenter << "." << endl;1663 Log() << Verbose(2) << "Anti-Oben is currently " << (*it)->OptCenter << "." << endl; 1663 1664 BTS->GetNormalVector((*it)->OptCenter); // vector to compare with should point inwards 1664 cout<< Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and "1665 Log() << Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and " 1665 1666 << *(*it)->point << " with normal vector " << BTS->NormalVector << ".\n"; 1666 1667 … … 1674 1675 AddTesselationLine(TPS[0], TPS[1], 0); 1675 1676 } 1676 cout<< Verbose(2) << "Projection is " << BTS->NormalVector.ScalarProduct(&Oben) << "." << endl;1677 Log() << Verbose(2) << "Projection is " << BTS->NormalVector.ScalarProduct(&Oben) << "." << endl; 1677 1678 } 1678 1679 if (BTS != NULL) // we have created one starting triangle … … 1696 1697 } 1697 1698 delete(OptCandidates); 1698 cout<< Verbose(1) << "End of FindStartingTriangle\n";1699 Log() << Verbose(1) << "End of FindStartingTriangle\n"; 1699 1700 }; 1700 1701 … … 1708 1709 * @param *LC LinkedCell structure with neighbouring points 1709 1710 */ 1710 bool Tesselation::FindNextSuitableTriangle( ofstream *out,BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)1711 { 1712 cout<< Verbose(0) << "Begin of FindNextSuitableTriangle\n";1711 bool Tesselation::FindNextSuitableTriangle(BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC) 1712 { 1713 Log() << Verbose(0) << "Begin of FindNextSuitableTriangle\n"; 1713 1714 bool result = true; 1714 1715 CandidateList *OptCandidates = new CandidateList(); … … 1724 1725 double radius, CircleRadius; 1725 1726 1726 cout<< Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl;1727 Log() << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl; 1727 1728 for (int i=0;i<3;i++) 1728 1729 if ((T.endpoints[i]->node != Line.endpoints[0]->node) && (T.endpoints[i]->node != Line.endpoints[1]->node)) … … 1743 1744 CircleRadius = RADIUS*RADIUS - radius/4.; 1744 1745 CirclePlaneNormal.Normalize(); 1745 // cout<< Verbose(2) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;1746 //Log() << Verbose(2) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 1746 1747 1747 1748 // construct old center … … 1752 1753 OldSphereCenter.AddVector(&helper); 1753 1754 OldSphereCenter.SubtractVector(&CircleCenter); 1754 // cout<< Verbose(2) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;1755 //Log() << Verbose(2) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl; 1755 1756 1756 1757 // construct SearchDirection … … 1762 1763 SearchDirection.ProjectOntoPlane(&OldSphereCenter); 1763 1764 SearchDirection.Normalize(); 1764 cout<< Verbose(2) << "INFO: SearchDirection is " << SearchDirection << "." << endl;1765 Log() << Verbose(2) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 1765 1766 if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { 1766 1767 // rotated the wrong way! 1767 cerr<< "ERROR: SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;1768 eLog() << Verbose(0) << "ERROR: SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl; 1768 1769 } 1769 1770 … … 1772 1773 1773 1774 } else { 1774 cout<< Verbose(1) << "Circumcircle for base line " << Line << " and base triangle " << T << " is too big!" << endl;1775 Log() << Verbose(1) << "Circumcircle for base line " << Line << " and base triangle " << T << " is too big!" << endl; 1775 1776 } 1776 1777 1777 1778 if (OptCandidates->begin() == OptCandidates->end()) { 1778 cerr<< "WARNING: Could not find a suitable candidate." << endl;1779 eLog() << Verbose(0) << "WARNING: Could not find a suitable candidate." << endl; 1779 1780 return false; 1780 1781 } 1781 cout<< Verbose(1) << "Third Points are ";1782 Log() << Verbose(1) << "Third Points are "; 1782 1783 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1783 cout<< " " << *(*it)->point;1784 } 1785 cout<< endl;1784 Log() << Verbose(0) << " " << *(*it)->point; 1785 } 1786 Log() << Verbose(0) << endl; 1786 1787 1787 1788 BoundaryLineSet *BaseRay = &Line; 1788 1789 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1789 cout<< Verbose(1) << " Third point candidate is " << *(*it)->point1790 Log() << Verbose(1) << " Third point candidate is " << *(*it)->point 1790 1791 << " with circumsphere's center at " << (*it)->OptCenter << "." << endl; 1791 cout<< Verbose(1) << " Baseline is " << *BaseRay << endl;1792 Log() << Verbose(1) << " Baseline is " << *BaseRay << endl; 1792 1793 1793 1794 // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2) … … 1796 1797 PointCandidates[1] = BaseRay->endpoints[0]->node; 1797 1798 PointCandidates[2] = BaseRay->endpoints[1]->node; 1798 int existentTrianglesCount = CheckPresenceOfTriangle( out,PointCandidates);1799 int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates); 1799 1800 1800 1801 BTS = NULL; … … 1816 1817 (*it)->OptCenter.Scale(-1.); 1817 1818 1818 cout<< "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector1819 Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector 1819 1820 << " for this triangle ... " << endl; 1820 // cout<< Verbose(1) << "We have "<< TrianglesOnBoundaryCount << " for line " << *BaseRay << "." << endl;1821 //Log() << Verbose(1) << "We have "<< TrianglesOnBoundaryCount << " for line " << *BaseRay << "." << endl; 1821 1822 } else { 1822 cout<< Verbose(1) << "WARNING: This triangle consisting of ";1823 cout<< *(*it)->point << ", ";1824 cout<< *BaseRay->endpoints[0]->node << " and ";1825 cout<< *BaseRay->endpoints[1]->node << " ";1826 cout<< "exists and is not added, as it does not seem helpful!" << endl;1823 Log() << Verbose(1) << "WARNING: This triangle consisting of "; 1824 Log() << Verbose(0) << *(*it)->point << ", "; 1825 Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and "; 1826 Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " "; 1827 Log() << Verbose(0) << "exists and is not added, as it does not seem helpful!" << endl; 1827 1828 result = false; 1828 1829 } … … 1846 1847 (*it)->OtherOptCenter.Scale(-1.); 1847 1848 1848 cout<< "--> WARNING: Special new triangle with " << *BTS << " and normal vector " << BTS->NormalVector1849 Log() << Verbose(0) << "--> WARNING: Special new triangle with " << *BTS << " and normal vector " << BTS->NormalVector 1849 1850 << " for this triangle ... " << endl; 1850 cout<< Verbose(1) << "We have "<< BaseRay->triangles.size() << " for line " << BaseRay << "." << endl;1851 Log() << Verbose(1) << "We have "<< BaseRay->triangles.size() << " for line " << BaseRay << "." << endl; 1851 1852 } else { 1852 cout<< Verbose(1) << "WARNING: This triangle consisting of ";1853 cout<< *(*it)->point << ", ";1854 cout<< *BaseRay->endpoints[0]->node << " and ";1855 cout<< *BaseRay->endpoints[1]->node << " ";1856 cout<< "exists and is not added, as it does not seem helpful!" << endl;1853 Log() << Verbose(1) << "WARNING: This triangle consisting of "; 1854 Log() << Verbose(0) << *(*it)->point << ", "; 1855 Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and "; 1856 Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " "; 1857 Log() << Verbose(0) << "exists and is not added, as it does not seem helpful!" << endl; 1857 1858 result = false; 1858 1859 } 1859 1860 } else { 1860 cout<< Verbose(1) << "This triangle consisting of ";1861 cout<< *(*it)->point << ", ";1862 cout<< *BaseRay->endpoints[0]->node << " and ";1863 cout<< *BaseRay->endpoints[1]->node << " ";1864 cout<< "is invalid!" << endl;1861 Log() << Verbose(1) << "This triangle consisting of "; 1862 Log() << Verbose(0) << *(*it)->point << ", "; 1863 Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and "; 1864 Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " "; 1865 Log() << Verbose(0) << "is invalid!" << endl; 1865 1866 result = false; 1866 1867 } … … 1869 1870 BaseRay = BLS[0]; 1870 1871 if ((BTS != NULL) && (BTS->NormalVector.NormSquared() < MYEPSILON)) { 1871 *out<< Verbose(1) << "CRITICAL: Triangle " << *BTS << " has zero normal vector!" << endl;1872 Log() << Verbose(1) << "CRITICAL: Triangle " << *BTS << " has zero normal vector!" << endl; 1872 1873 exit(255); 1873 1874 } … … 1882 1883 } 1883 1884 delete(OptCandidates); 1884 cout<< Verbose(0) << "End of FindNextSuitableTriangle\n";1885 Log() << Verbose(0) << "End of FindNextSuitableTriangle\n"; 1885 1886 return result; 1886 1887 }; … … 1893 1894 * \return NULL - convex, otherwise endpoint that makes it concave 1894 1895 */ 1895 class BoundaryPointSet *Tesselation::IsConvexRectangle( ofstream *out,class BoundaryLineSet *Base)1896 class BoundaryPointSet *Tesselation::IsConvexRectangle(class BoundaryLineSet *Base) 1896 1897 { 1897 1898 class BoundaryPointSet *Spot = NULL; … … 1906 1907 OtherBase = new class BoundaryLineSet(BPS,-1); 1907 1908 1908 *out<< Verbose(3) << "INFO: Current base line is " << *Base << "." << endl;1909 *out<< Verbose(3) << "INFO: Other base line is " << *OtherBase << "." << endl;1909 Log() << Verbose(3) << "INFO: Current base line is " << *Base << "." << endl; 1910 Log() << Verbose(3) << "INFO: Other base line is " << *OtherBase << "." << endl; 1910 1911 1911 1912 // get the closest point on each line to the other line 1912 ClosestPoint = GetClosestPointBetweenLine( out,Base, OtherBase);1913 ClosestPoint = GetClosestPointBetweenLine(Base, OtherBase); 1913 1914 1914 1915 // delete the temporary other base line … … 1927 1928 delete(ClosestPoint); 1928 1929 if ((distance[0] * distance[1]) > 0) { // have same sign? 1929 *out<< Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl;1930 Log() << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl; 1930 1931 if (distance[0] < distance[1]) { 1931 1932 Spot = Base->endpoints[0]; … … 1935 1936 return Spot; 1936 1937 } else { // different sign, i.e. we are in between 1937 *out<< Verbose(3) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl;1938 Log() << Verbose(3) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl; 1938 1939 return NULL; 1939 1940 } … … 1944 1945 { 1945 1946 // print all lines 1946 *out<< Verbose(1) << "Printing all boundary points for debugging:" << endl;1947 Log() << Verbose(1) << "Printing all boundary points for debugging:" << endl; 1947 1948 for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++) 1948 *out<< Verbose(2) << *(PointRunner->second) << endl;1949 Log() << Verbose(2) << *(PointRunner->second) << endl; 1949 1950 }; 1950 1951 … … 1952 1953 { 1953 1954 // print all lines 1954 *out<< Verbose(1) << "Printing all boundary lines for debugging:" << endl;1955 Log() << Verbose(1) << "Printing all boundary lines for debugging:" << endl; 1955 1956 for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++) 1956 *out<< Verbose(2) << *(LineRunner->second) << endl;1957 Log() << Verbose(2) << *(LineRunner->second) << endl; 1957 1958 }; 1958 1959 … … 1960 1961 { 1961 1962 // print all triangles 1962 *out<< Verbose(1) << "Printing all boundary triangles for debugging:" << endl;1963 Log() << Verbose(1) << "Printing all boundary triangles for debugging:" << endl; 1963 1964 for (TriangleMap::const_iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++) 1964 *out<< Verbose(2) << *(TriangleRunner->second) << endl;1965 Log() << Verbose(2) << *(TriangleRunner->second) << endl; 1965 1966 }; 1966 1967 … … 1970 1971 * \return volume change due to flipping (0 - then no flipped occured) 1971 1972 */ 1972 double Tesselation::PickFarthestofTwoBaselines( ofstream *out,class BoundaryLineSet *Base)1973 double Tesselation::PickFarthestofTwoBaselines(class BoundaryLineSet *Base) 1973 1974 { 1974 1975 class BoundaryLineSet *OtherBase; … … 1983 1984 OtherBase = new class BoundaryLineSet(BPS,-1); 1984 1985 1985 *out<< Verbose(3) << "INFO: Current base line is " << *Base << "." << endl;1986 *out<< Verbose(3) << "INFO: Other base line is " << *OtherBase << "." << endl;1986 Log() << Verbose(3) << "INFO: Current base line is " << *Base << "." << endl; 1987 Log() << Verbose(3) << "INFO: Other base line is " << *OtherBase << "." << endl; 1987 1988 1988 1989 // get the closest point on each line to the other line 1989 ClosestPoint[0] = GetClosestPointBetweenLine( out,Base, OtherBase);1990 ClosestPoint[1] = GetClosestPointBetweenLine( out,OtherBase, Base);1990 ClosestPoint[0] = GetClosestPointBetweenLine(Base, OtherBase); 1991 ClosestPoint[1] = GetClosestPointBetweenLine(OtherBase, Base); 1991 1992 1992 1993 // get the distance vector from Base line to OtherBase line … … 2004 2005 2005 2006 if (Distance.NormSquared() < MYEPSILON) { // check for intersection 2006 *out<< Verbose(3) << "REJECT: Both lines have an intersection: Nothing to do." << endl;2007 Log() << Verbose(3) << "REJECT: Both lines have an intersection: Nothing to do." << endl; 2007 2008 return false; 2008 2009 } else { // check for sign against BaseLineNormal … … 2010 2011 BaseLineNormal.Zero(); 2011 2012 if (Base->triangles.size() < 2) { 2012 *out<< Verbose(2) << "ERROR: Less than two triangles are attached to this baseline!" << endl;2013 Log() << Verbose(2) << "ERROR: Less than two triangles are attached to this baseline!" << endl; 2013 2014 return 0.; 2014 2015 } 2015 2016 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 2016 *out<< Verbose(4) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;2017 Log() << Verbose(4) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl; 2017 2018 BaseLineNormal.AddVector(&(runner->second->NormalVector)); 2018 2019 } … … 2020 2021 2021 2022 if (Distance.ScalarProduct(&BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip 2022 *out<< Verbose(2) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl;2023 Log() << Verbose(2) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl; 2023 2024 // calculate volume summand as a general tetraeder 2024 2025 return volume; 2025 2026 } else { // Base higher than OtherBase -> do nothing 2026 *out<< Verbose(2) << "REJECT: Base line is higher: Nothing to do." << endl;2027 Log() << Verbose(2) << "REJECT: Base line is higher: Nothing to do." << endl; 2027 2028 return 0.; 2028 2029 } … … 2037 2038 * \return pointer to allocated new baseline - flipping successful, NULL - something went awry 2038 2039 */ 2039 class BoundaryLineSet * Tesselation::FlipBaseline( ofstream *out,class BoundaryLineSet *Base)2040 class BoundaryLineSet * Tesselation::FlipBaseline(class BoundaryLineSet *Base) 2040 2041 { 2041 2042 class BoundaryLineSet *OldLines[4], *NewLine; … … 2045 2046 int i,m; 2046 2047 2047 *out<< Verbose(1) << "Begin of FlipBaseline" << endl;2048 Log() << Verbose(1) << "Begin of FlipBaseline" << endl; 2048 2049 2049 2050 // calculate NormalVector for later use 2050 2051 BaseLineNormal.Zero(); 2051 2052 if (Base->triangles.size() < 2) { 2052 *out<< Verbose(2) << "ERROR: Less than two triangles are attached to this baseline!" << endl;2053 Log() << Verbose(2) << "ERROR: Less than two triangles are attached to this baseline!" << endl; 2053 2054 return NULL; 2054 2055 } 2055 2056 for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 2056 *out<< Verbose(4) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;2057 Log() << Verbose(4) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl; 2057 2058 BaseLineNormal.AddVector(&(runner->second->NormalVector)); 2058 2059 } … … 2067 2068 i=0; 2068 2069 m=0; 2069 *out<< Verbose(3) << "The four old lines are: ";2070 Log() << Verbose(3) << "The four old lines are: "; 2070 2071 for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) 2071 2072 for (int j=0;j<3;j++) // all of their endpoints and baselines 2072 2073 if (runner->second->lines[j] != Base) { // pick not the central baseline 2073 2074 OldLines[i++] = runner->second->lines[j]; 2074 *out<< *runner->second->lines[j] << "\t";2075 Log() << Verbose(0) << *runner->second->lines[j] << "\t"; 2075 2076 } 2076 *out<< endl;2077 *out<< Verbose(3) << "The two old points are: ";2077 Log() << Verbose(0) << endl; 2078 Log() << Verbose(3) << "The two old points are: "; 2078 2079 for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) 2079 2080 for (int j=0;j<3;j++) // all of their endpoints and baselines 2080 2081 if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) { // and neither of its endpoints 2081 2082 OldPoints[m++] = runner->second->endpoints[j]; 2082 *out<< *runner->second->endpoints[j] << "\t";2083 Log() << Verbose(0) << *runner->second->endpoints[j] << "\t"; 2083 2084 } 2084 *out<< endl;2085 Log() << Verbose(0) << endl; 2085 2086 2086 2087 // check whether everything is in place to create new lines and triangles 2087 2088 if (i<4) { 2088 *out<< Verbose(1) << "ERROR: We have not gathered enough baselines!" << endl;2089 Log() << Verbose(1) << "ERROR: We have not gathered enough baselines!" << endl; 2089 2090 return NULL; 2090 2091 } 2091 2092 for (int j=0;j<4;j++) 2092 2093 if (OldLines[j] == NULL) { 2093 *out<< Verbose(1) << "ERROR: We have not gathered enough baselines!" << endl;2094 Log() << Verbose(1) << "ERROR: We have not gathered enough baselines!" << endl; 2094 2095 return NULL; 2095 2096 } 2096 2097 for (int j=0;j<2;j++) 2097 2098 if (OldPoints[j] == NULL) { 2098 *out<< Verbose(1) << "ERROR: We have not gathered enough endpoints!" << endl;2099 Log() << Verbose(1) << "ERROR: We have not gathered enough endpoints!" << endl; 2099 2100 return NULL; 2100 2101 } 2101 2102 2102 2103 // remove triangles and baseline removes itself 2103 *out<< Verbose(3) << "INFO: Deleting baseline " << *Base << " from global list." << endl;2104 Log() << Verbose(3) << "INFO: Deleting baseline " << *Base << " from global list." << endl; 2104 2105 OldBaseLineNr = Base->Nr; 2105 2106 m=0; 2106 2107 for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) { 2107 *out<< Verbose(3) << "INFO: Deleting triangle " << *(runner->second) << "." << endl;2108 Log() << Verbose(3) << "INFO: Deleting triangle " << *(runner->second) << "." << endl; 2108 2109 OldTriangleNrs[m++] = runner->second->Nr; 2109 2110 RemoveTesselationTriangle(runner->second); … … 2115 2116 NewLine = new class BoundaryLineSet(BPS, OldBaseLineNr); 2116 2117 LinesOnBoundary.insert(LinePair(OldBaseLineNr, NewLine)); // no need for check for unique insertion as NewLine is definitely a new one 2117 *out<< Verbose(3) << "INFO: Created new baseline " << *NewLine << "." << endl;2118 Log() << Verbose(3) << "INFO: Created new baseline " << *NewLine << "." << endl; 2118 2119 2119 2120 // construct new triangles with flipped baseline … … 2130 2131 BTS->GetNormalVector(BaseLineNormal); 2131 2132 AddTesselationTriangle(OldTriangleNrs[0]); 2132 *out<< Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl;2133 Log() << Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl; 2133 2134 2134 2135 BLS[0] = (i==2 ? OldLines[3] : OldLines[2]); … … 2138 2139 BTS->GetNormalVector(BaseLineNormal); 2139 2140 AddTesselationTriangle(OldTriangleNrs[1]); 2140 *out<< Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl;2141 Log() << Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl; 2141 2142 } else { 2142 *out<< Verbose(1) << "The four old lines do not connect, something's utterly wrong here!" << endl;2143 Log() << Verbose(1) << "The four old lines do not connect, something's utterly wrong here!" << endl; 2143 2144 return NULL; 2144 2145 } 2145 2146 2146 *out<< Verbose(1) << "End of FlipBaseline" << endl;2147 Log() << Verbose(1) << "End of FlipBaseline" << endl; 2147 2148 return NewLine; 2148 2149 }; … … 2159 2160 void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC) 2160 2161 { 2161 cout<< Verbose(2) << "Begin of FindSecondPointForTesselation" << endl;2162 Log() << Verbose(2) << "Begin of FindSecondPointForTesselation" << endl; 2162 2163 Vector AngleCheck; 2163 2164 class TesselPoint* Candidate = NULL; … … 2172 2173 N[i] = LC->n[i]; 2173 2174 } else { 2174 cerr<< "ERROR: Point " << *a << " is not found in cell " << LC->index << "." << endl;2175 eLog() << Verbose(0) << "ERROR: Point " << *a << " is not found in cell " << LC->index << "." << endl; 2175 2176 return; 2176 2177 } 2177 2178 // then go through the current and all neighbouring cells and check the contained points for possible candidates 2178 cout<< Verbose(3) << "LC Intervals from [";2179 Log() << Verbose(3) << "LC Intervals from ["; 2179 2180 for (int i=0;i<NDIM;i++) { 2180 cout<< " " << N[i] << "<->" << LC->N[i];2181 } 2182 cout<< "] :";2181 Log() << Verbose(0) << " " << N[i] << "<->" << LC->N[i]; 2182 } 2183 Log() << Verbose(0) << "] :"; 2183 2184 for (int i=0;i<NDIM;i++) { 2184 2185 Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0; 2185 2186 Nupper[i] = ((N[i]+1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1; 2186 cout<< " [" << Nlower[i] << "," << Nupper[i] << "] ";2187 } 2188 cout<< endl;2187 Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "; 2188 } 2189 Log() << Verbose(0) << endl; 2189 2190 2190 2191 … … 2193 2194 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2194 2195 const LinkedNodes *List = LC->GetCurrentCell(); 2195 // cout<< Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;2196 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2196 2197 if (List != NULL) { 2197 2198 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { … … 2224 2225 angle = AngleCheck.Angle(&Oben); 2225 2226 if (angle < Storage[0]) { 2226 // cout<< Verbose(3) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);2227 cout<< Verbose(3) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";2227 //Log() << Verbose(3) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 2228 Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n"; 2228 2229 OptCandidate = Candidate; 2229 2230 Storage[0] = angle; 2230 // cout<< Verbose(3) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]);2231 //Log() << Verbose(3) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]); 2231 2232 } else { 2232 // cout<< Verbose(3) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *OptCandidate << endl;2233 //Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *OptCandidate << endl; 2233 2234 } 2234 2235 } else { 2235 // cout<< Verbose(3) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl;2236 //Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl; 2236 2237 } 2237 2238 } else { 2238 // cout<< Verbose(3) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl;2239 //Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl; 2239 2240 } 2240 2241 } 2241 2242 } else { 2242 cout<< Verbose(3) << "Linked cell list is empty." << endl;2243 Log() << Verbose(3) << "Linked cell list is empty." << endl; 2243 2244 } 2244 2245 } 2245 cout<< Verbose(2) << "End of FindSecondPointForTesselation" << endl;2246 Log() << Verbose(2) << "End of FindSecondPointForTesselation" << endl; 2246 2247 }; 2247 2248 … … 2295 2296 CandidateForTesselation *optCandidate = NULL; 2296 2297 2297 cout<< Verbose(1) << "Begin of FindThirdPointForTesselation" << endl;2298 2299 cout<< Verbose(2) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl;2298 Log() << Verbose(1) << "Begin of FindThirdPointForTesselation" << endl; 2299 2300 Log() << Verbose(2) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl; 2300 2301 2301 2302 // construct center of circle … … 2313 2314 CircleRadius = RADIUS*RADIUS - radius/4.; 2314 2315 CirclePlaneNormal.Normalize(); 2315 // cout<< Verbose(2) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;2316 //Log() << Verbose(2) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl; 2316 2317 2317 2318 // test whether old center is on the band's plane 2318 2319 if (fabs(OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) { 2319 cerr<< "ERROR: Something's very wrong here: OldSphereCenter is not on the band's plane as desired by " << fabs(OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;2320 eLog() << Verbose(0) << "ERROR: Something's very wrong here: OldSphereCenter is not on the band's plane as desired by " << fabs(OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl; 2320 2321 OldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal); 2321 2322 } 2322 2323 radius = OldSphereCenter.ScalarProduct(&OldSphereCenter); 2323 2324 if (fabs(radius - CircleRadius) < HULLEPSILON) { 2324 // cout<< Verbose(2) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;2325 //Log() << Verbose(2) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl; 2325 2326 2326 2327 // check SearchDirection 2327 // cout<< Verbose(2) << "INFO: SearchDirection is " << SearchDirection << "." << endl;2328 //Log() << Verbose(2) << "INFO: SearchDirection is " << SearchDirection << "." << endl; 2328 2329 if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way! 2329 cerr<< "ERROR: SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl;2330 eLog() << Verbose(0) << "ERROR: SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl; 2330 2331 } 2331 2332 … … 2334 2335 for(int i=0;i<NDIM;i++) // store indices of this cell 2335 2336 N[i] = LC->n[i]; 2336 // cout<< Verbose(2) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;2337 //Log() << Verbose(2) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl; 2337 2338 } else { 2338 cerr<< "ERROR: Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl;2339 eLog() << Verbose(0) << "ERROR: Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl; 2339 2340 return; 2340 2341 } 2341 2342 // then go through the current and all neighbouring cells and check the contained points for possible candidates 2342 // cout<< Verbose(2) << "LC Intervals:";2343 //Log() << Verbose(2) << "LC Intervals:"; 2343 2344 for (int i=0;i<NDIM;i++) { 2344 2345 Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0; 2345 2346 Nupper[i] = ((N[i]+1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1; 2346 // cout<< " [" << Nlower[i] << "," << Nupper[i] << "] ";2347 //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] "; 2347 2348 } 2348 // cout<< endl;2349 //Log() << Verbose(0) << endl; 2349 2350 for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++) 2350 2351 for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++) 2351 2352 for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) { 2352 2353 const LinkedNodes *List = LC->GetCurrentCell(); 2353 // cout<< Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;2354 //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl; 2354 2355 if (List != NULL) { 2355 2356 for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) { … … 2357 2358 2358 2359 // check for three unique points 2359 // cout<< Verbose(2) << "INFO: Current Candidate is " << *Candidate << " at " << Candidate->node << "." << endl;2360 //Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " at " << Candidate->node << "." << endl; 2360 2361 if ((Candidate != BaseLine->endpoints[0]->node) && (Candidate != BaseLine->endpoints[1]->node) ){ 2361 2362 … … 2368 2369 ) { 2369 2370 helper.CopyVector(&NewNormalVector); 2370 // cout<< Verbose(2) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl;2371 //Log() << Verbose(2) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl; 2371 2372 radius = BaseLine->endpoints[0]->node->node->DistanceSquared(&NewSphereCenter); 2372 2373 if (radius < RADIUS*RADIUS) { 2373 2374 helper.Scale(sqrt(RADIUS*RADIUS - radius)); 2374 // cout<< Verbose(2) << "INFO: Distance of NewCircleCenter to NewSphereCenter is " << helper.Norm() << " with sphere radius " << RADIUS << "." << endl;2375 //Log() << Verbose(2) << "INFO: Distance of NewCircleCenter to NewSphereCenter is " << helper.Norm() << " with sphere radius " << RADIUS << "." << endl; 2375 2376 NewSphereCenter.AddVector(&helper); 2376 2377 NewSphereCenter.SubtractVector(&CircleCenter); 2377 // cout<< Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl;2378 //Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl; 2378 2379 2379 2380 // OtherNewSphereCenter is created by the same vector just in the other direction … … 2381 2382 OtherNewSphereCenter.AddVector(&helper); 2382 2383 OtherNewSphereCenter.SubtractVector(&CircleCenter); 2383 // cout<< Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl;2384 //Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl; 2384 2385 2385 2386 alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection); … … 2400 2401 if ((*ShortestAngle - HULLEPSILON) < alpha) { 2401 2402 candidates->push_back(optCandidate); 2402 cout<< Verbose(2) << "ACCEPT: We have found an equally good candidate: " << *(optCandidate->point) << " with "2403 Log() << Verbose(2) << "ACCEPT: We have found an equally good candidate: " << *(optCandidate->point) << " with " 2403 2404 << alpha << " and circumsphere's center at " << optCandidate->OptCenter << "." << endl; 2404 2405 } else { … … 2411 2412 candidates->clear(); 2412 2413 candidates->push_back(optCandidate); 2413 cout<< Verbose(2) << "ACCEPT: We have found a better candidate: " << *(optCandidate->point) << " with "2414 Log() << Verbose(2) << "ACCEPT: We have found a better candidate: " << *(optCandidate->point) << " with " 2414 2415 << alpha << " and circumsphere's center at " << optCandidate->OptCenter << "." << endl; 2415 2416 } 2416 2417 *ShortestAngle = alpha; 2417 // cout<< Verbose(2) << "INFO: There are " << candidates->size() << " candidates in the list now." << endl;2418 //Log() << Verbose(2) << "INFO: There are " << candidates->size() << " candidates in the list now." << endl; 2418 2419 } else { 2419 2420 if ((optCandidate != NULL) && (optCandidate->point != NULL)) { 2420 // cout<< Verbose(2) << "REJECT: Old candidate " << *(optCandidate->point) << " with " << *ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl;2421 //Log() << Verbose(2) << "REJECT: Old candidate " << *(optCandidate->point) << " with " << *ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2421 2422 } else { 2422 // cout<< Verbose(2) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl;2423 //Log() << Verbose(2) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2423 2424 } 2424 2425 } 2425 2426 2426 2427 } else { 2427 // cout<< Verbose(2) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl;2428 //Log() << Verbose(2) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl; 2428 2429 } 2429 2430 } else { 2430 // cout<< Verbose(2) << "REJECT: Three points from " << *BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl;2431 //Log() << Verbose(2) << "REJECT: Three points from " << *BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl; 2431 2432 } 2432 2433 } else { 2433 2434 if (ThirdNode != NULL) { 2434 // cout<< Verbose(2) << "REJECT: Base triangle " << *BaseLine << " and " << *ThirdNode << " contains Candidate " << *Candidate << "." << endl;2435 //Log() << Verbose(2) << "REJECT: Base triangle " << *BaseLine << " and " << *ThirdNode << " contains Candidate " << *Candidate << "." << endl; 2435 2436 } else { 2436 // cout<< Verbose(2) << "REJECT: Base triangle " << *BaseLine << " contains Candidate " << *Candidate << "." << endl;2437 //Log() << Verbose(2) << "REJECT: Base triangle " << *BaseLine << " contains Candidate " << *Candidate << "." << endl; 2437 2438 } 2438 2439 } … … 2441 2442 } 2442 2443 } else { 2443 cerr<< Verbose(2) << "ERROR: The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;2444 eLog() << Verbose(2) << "ERROR: The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl; 2444 2445 } 2445 2446 } else { 2446 2447 if (ThirdNode != NULL) 2447 cout<< Verbose(2) << "Circumcircle for base line " << *BaseLine << " and third node " << *ThirdNode << " is too big!" << endl;2448 Log() << Verbose(2) << "Circumcircle for base line " << *BaseLine << " and third node " << *ThirdNode << " is too big!" << endl; 2448 2449 else 2449 cout<< Verbose(2) << "Circumcircle for base line " << *BaseLine << " is too big!" << endl;2450 } 2451 2452 // cout<< Verbose(2) << "INFO: Sorting candidate list ..." << endl;2450 Log() << Verbose(2) << "Circumcircle for base line " << *BaseLine << " is too big!" << endl; 2451 } 2452 2453 //Log() << Verbose(2) << "INFO: Sorting candidate list ..." << endl; 2453 2454 if (candidates->size() > 1) { 2454 2455 candidates->unique(); … … 2456 2457 } 2457 2458 2458 cout<< Verbose(1) << "End of FindThirdPointForTesselation" << endl;2459 Log() << Verbose(1) << "End of FindThirdPointForTesselation" << endl; 2459 2460 }; 2460 2461 … … 2479 2480 { // if insertion fails, we have common endpoint 2480 2481 node = OrderTest.first->second; 2481 cout<< Verbose(5) << "Common endpoint of lines " << *line12482 Log() << Verbose(5) << "Common endpoint of lines " << *line1 2482 2483 << " and " << *line2 << " is: " << *node << "." << endl; 2483 2484 j = 2; … … 2494 2495 * \return list of BoundaryTriangleSet of nearest triangles or NULL in degenerate case. 2495 2496 */ 2496 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint( ofstream *out,const Vector *x, const LinkedCell* LC) const2497 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(const Vector *x, const LinkedCell* LC) const 2497 2498 { 2498 2499 TesselPoint *trianglePoints[3]; … … 2501 2502 2502 2503 if (LinesOnBoundary.empty()) { 2503 *out<< Verbose(0) << "Error: There is no tesselation structure to compare the point with, please create one first.";2504 Log() << Verbose(0) << "Error: There is no tesselation structure to compare the point with, please create one first."; 2504 2505 return NULL; 2505 2506 } 2506 *out<< Verbose(1) << "Finding closest Tesselpoint to " << *x << " ... " << endl;2507 Log() << Verbose(1) << "Finding closest Tesselpoint to " << *x << " ... " << endl; 2507 2508 trianglePoints[0] = FindClosestPoint(x, SecondPoint, LC); 2508 2509 2509 2510 // check whether closest point is "too close" :), then it's inside 2510 2511 if (trianglePoints[0] == NULL) { 2511 *out<< Verbose(2) << "Is the only point, no one else is closeby." << endl;2512 Log() << Verbose(2) << "Is the only point, no one else is closeby." << endl; 2512 2513 return NULL; 2513 2514 } 2514 2515 if (trianglePoints[0]->node->DistanceSquared(x) < MYEPSILON) { 2515 *out<< Verbose(3) << "Point is right on a tesselation point, no nearest triangle." << endl;2516 Log() << Verbose(3) << "Point is right on a tesselation point, no nearest triangle." << endl; 2516 2517 PointMap::const_iterator PointRunner = PointsOnBoundary.find(trianglePoints[0]->nr); 2517 2518 triangles = new list<BoundaryTriangleSet*>; … … 2532 2533 triangles->unique(); 2533 2534 } else { 2534 *out<< Verbose(1) << "ERROR: I cannot find a boundary point to the tessel point " << *trianglePoints[0] << "." << endl;2535 Log() << Verbose(1) << "ERROR: I cannot find a boundary point to the tessel point " << *trianglePoints[0] << "." << endl; 2535 2536 return NULL; 2536 2537 } 2537 2538 } 2538 2539 } else { 2539 list<TesselPoint*> *connectedClosestPoints = GetCircleOfConnectedPoints( out,trianglePoints[0], x);2540 list<TesselPoint*> *connectedClosestPoints = GetCircleOfConnectedPoints(trianglePoints[0], x); 2540 2541 if (connectedClosestPoints != NULL) { 2541 2542 trianglePoints[1] = connectedClosestPoints->front(); … … 2543 2544 for (int i=0;i<3;i++) { 2544 2545 if (trianglePoints[i] == NULL) { 2545 *out<< Verbose(1) << "ERROR: IsInnerPoint encounters serious error, point " << i << " not found." << endl;2546 Log() << Verbose(1) << "ERROR: IsInnerPoint encounters serious error, point " << i << " not found." << endl; 2546 2547 } 2547 // *out<< Verbose(2) << "List of triangle points:" << endl;2548 // *out<< Verbose(3) << *trianglePoints[i] << endl;2548 //Log() << Verbose(2) << "List of triangle points:" << endl; 2549 //Log() << Verbose(3) << *trianglePoints[i] << endl; 2549 2550 } 2550 2551 2551 2552 triangles = FindTriangles(trianglePoints); 2552 *out<< Verbose(2) << "List of possible triangles:" << endl;2553 Log() << Verbose(2) << "List of possible triangles:" << endl; 2553 2554 for(list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) 2554 *out<< Verbose(3) << **Runner << endl;2555 Log() << Verbose(3) << **Runner << endl; 2555 2556 2556 2557 delete(connectedClosestPoints); 2557 2558 } else { 2558 2559 triangles = NULL; 2559 *out<< Verbose(1) << "There is no circle of connected points!" << endl;2560 Log() << Verbose(1) << "There is no circle of connected points!" << endl; 2560 2561 } 2561 2562 } 2562 2563 2563 2564 if ((triangles == NULL) || (triangles->empty())) { 2564 *out<< Verbose(0) << "ERROR: There is no nearest triangle. Please check the tesselation structure.";2565 Log() << Verbose(0) << "ERROR: There is no nearest triangle. Please check the tesselation structure."; 2565 2566 delete(triangles); 2566 2567 return NULL; … … 2575 2576 * \return list of BoundaryTriangleSet of nearest triangles or NULL. 2576 2577 */ 2577 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToPoint( ofstream *out,const Vector *x, const LinkedCell* LC) const2578 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToPoint(const Vector *x, const LinkedCell* LC) const 2578 2579 { 2579 2580 class BoundaryTriangleSet *result = NULL; 2580 list<BoundaryTriangleSet*> *triangles = FindClosestTrianglesToPoint( out,x, LC);2581 list<BoundaryTriangleSet*> *triangles = FindClosestTrianglesToPoint(x, LC); 2581 2582 Vector Center; 2582 2583 … … 2586 2587 if (triangles->size() == 1) { // there is no degenerate case 2587 2588 result = triangles->front(); 2588 *out<< Verbose(2) << "Normal Vector of this triangle is " << result->NormalVector << "." << endl;2589 Log() << Verbose(2) << "Normal Vector of this triangle is " << result->NormalVector << "." << endl; 2589 2590 } else { 2590 2591 result = triangles->front(); 2591 2592 result->GetCenter(&Center); 2592 2593 Center.SubtractVector(x); 2593 *out<< Verbose(2) << "Normal Vector of this front side is " << result->NormalVector << "." << endl;2594 Log() << Verbose(2) << "Normal Vector of this front side is " << result->NormalVector << "." << endl; 2594 2595 if (Center.ScalarProduct(&result->NormalVector) < 0) { 2595 2596 result = triangles->back(); 2596 *out<< Verbose(2) << "Normal Vector of this back side is " << result->NormalVector << "." << endl;2597 Log() << Verbose(2) << "Normal Vector of this back side is " << result->NormalVector << "." << endl; 2597 2598 if (Center.ScalarProduct(&result->NormalVector) < 0) { 2598 *out<< Verbose(1) << "ERROR: Front and back side yield NormalVector in wrong direction!" << endl;2599 Log() << Verbose(1) << "ERROR: Front and back side yield NormalVector in wrong direction!" << endl; 2599 2600 } 2600 2601 } … … 2611 2612 * @return true if the point is inside the tesselation structure, false otherwise 2612 2613 */ 2613 bool Tesselation::IsInnerPoint( ofstream *out,const Vector &Point, const LinkedCell* const LC) const2614 { 2615 class BoundaryTriangleSet *result = FindClosestTriangleToPoint( out,&Point, LC);2614 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const 2615 { 2616 class BoundaryTriangleSet *result = FindClosestTriangleToPoint(&Point, LC); 2616 2617 Vector Center; 2617 2618 2618 2619 if (result == NULL) {// is boundary point or only point in point cloud? 2619 *out<< Verbose(1) << Point << " is the only point in vicinity." << endl;2620 Log() << Verbose(1) << Point << " is the only point in vicinity." << endl; 2620 2621 return false; 2621 2622 } 2622 2623 2623 2624 result->GetCenter(&Center); 2624 *out<< Verbose(3) << "INFO: Central point of the triangle is " << Center << "." << endl;2625 Log() << Verbose(3) << "INFO: Central point of the triangle is " << Center << "." << endl; 2625 2626 Center.SubtractVector(&Point); 2626 *out<< Verbose(3) << "INFO: Vector from center to point to test is " << Center << "." << endl;2627 Log() << Verbose(3) << "INFO: Vector from center to point to test is " << Center << "." << endl; 2627 2628 if (Center.ScalarProduct(&result->NormalVector) > -MYEPSILON) { 2628 *out<< Verbose(1) << Point << " is an inner point." << endl;2629 Log() << Verbose(1) << Point << " is an inner point." << endl; 2629 2630 return true; 2630 2631 } else { 2631 *out<< Verbose(1) << Point << " is NOT an inner point." << endl;2632 Log() << Verbose(1) << Point << " is NOT an inner point." << endl; 2632 2633 return false; 2633 2634 } … … 2641 2642 * @return true if the point is inside the tesselation structure, false otherwise 2642 2643 */ 2643 bool Tesselation::IsInnerPoint( ofstream *out,const TesselPoint * const Point, const LinkedCell* const LC) const2644 { 2645 return IsInnerPoint( out,*(Point->node), LC);2644 bool Tesselation::IsInnerPoint(const TesselPoint * const Point, const LinkedCell* const LC) const 2645 { 2646 return IsInnerPoint(*(Point->node), LC); 2646 2647 } 2647 2648 … … 2652 2653 * @return set of the all points linked to the provided one 2653 2654 */ 2654 set<TesselPoint*> * Tesselation::GetAllConnectedPoints( ofstream *out,const TesselPoint* const Point) const2655 set<TesselPoint*> * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const 2655 2656 { 2656 2657 set<TesselPoint*> *connectedPoints = new set<TesselPoint*>; … … 2659 2660 bool takePoint = false; 2660 2661 2661 *out<< Verbose(3) << "Begin of GetAllConnectedPoints" << endl;2662 Log() << Verbose(3) << "Begin of GetAllConnectedPoints" << endl; 2662 2663 2663 2664 // find the respective boundary point … … 2666 2667 ReferencePoint = PointRunner->second; 2667 2668 } else { 2668 *out<< Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;2669 Log() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl; 2669 2670 ReferencePoint = NULL; 2670 2671 } … … 2690 2691 2691 2692 if (takePoint) { 2692 *out<< Verbose(5) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl;2693 Log() << Verbose(5) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl; 2693 2694 connectedPoints->insert(current); 2694 2695 } … … 2698 2699 2699 2700 if (connectedPoints->size() == 0) { // if have not found any points 2700 *out<< Verbose(1) << "ERROR: We have not found any connected points to " << *Point<< "." << endl;2701 Log() << Verbose(1) << "ERROR: We have not found any connected points to " << *Point<< "." << endl; 2701 2702 return NULL; 2702 2703 } 2703 2704 2704 *out<< Verbose(3) << "End of GetAllConnectedPoints" << endl;2705 Log() << Verbose(3) << "End of GetAllConnectedPoints" << endl; 2705 2706 return connectedPoints; 2706 2707 }; … … 2718 2719 * @return list of the all points linked to the provided one 2719 2720 */ 2720 list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints( ofstream *out,const TesselPoint* const Point, const Vector * const Reference) const2721 list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints(const TesselPoint* const Point, const Vector * const Reference) const 2721 2722 { 2722 2723 map<double, TesselPoint*> anglesOfPoints; 2723 set<TesselPoint*> *connectedPoints = GetAllConnectedPoints( out,Point);2724 set<TesselPoint*> *connectedPoints = GetAllConnectedPoints(Point); 2724 2725 list<TesselPoint*> *connectedCircle = new list<TesselPoint*>; 2725 2726 Vector center; … … 2730 2731 2731 2732 if (connectedPoints == NULL) { 2732 *out<< Verbose(2) << "Could not find any connected points!" << endl;2733 Log() << Verbose(2) << "Could not find any connected points!" << endl; 2733 2734 delete(connectedCircle); 2734 2735 return NULL; 2735 2736 } 2736 *out<< Verbose(2) << "Begin of GetCircleOfConnectedPoints" << endl;2737 Log() << Verbose(2) << "Begin of GetCircleOfConnectedPoints" << endl; 2737 2738 2738 2739 // calculate central point 2739 2740 for (set<TesselPoint*>::const_iterator TesselRunner = connectedPoints->begin(); TesselRunner != connectedPoints->end(); TesselRunner++) 2740 2741 center.AddVector((*TesselRunner)->node); 2741 // *out<< "Summed vectors " << center << "; number of points " << connectedPoints.size()2742 //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size() 2742 2743 // << "; scale factor " << 1.0/connectedPoints.size(); 2743 2744 center.Scale(1.0/connectedPoints->size()); 2744 *out<< Verbose(4) << "INFO: Calculated center of all circle points is " << center << "." << endl;2745 Log() << Verbose(4) << "INFO: Calculated center of all circle points is " << center << "." << endl; 2745 2746 2746 2747 // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points … … 2748 2749 PlaneNormal.SubtractVector(¢er); 2749 2750 PlaneNormal.Normalize(); 2750 *out<< Verbose(4) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl;2751 Log() << Verbose(4) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl; 2751 2752 2752 2753 // construct one orthogonal vector … … 2757 2758 } 2758 2759 if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) { 2759 *out<< Verbose(4) << "Using alternatively " << *(*connectedPoints->begin())->node << " as angle 0 referencer." << endl;2760 Log() << Verbose(4) << "Using alternatively " << *(*connectedPoints->begin())->node << " as angle 0 referencer." << endl; 2760 2761 AngleZero.CopyVector((*connectedPoints->begin())->node); 2761 2762 AngleZero.SubtractVector(Point->node); 2762 2763 AngleZero.ProjectOntoPlane(&PlaneNormal); 2763 2764 if (AngleZero.NormSquared() < MYEPSILON) { 2764 cerr<< Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;2765 eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl; 2765 2766 performCriticalExit(); 2766 2767 } 2767 2768 } 2768 *out<< Verbose(4) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;2769 Log() << Verbose(4) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl; 2769 2770 if (AngleZero.NormSquared() > MYEPSILON) 2770 2771 OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero); 2771 2772 else 2772 2773 OrthogonalVector.MakeNormalVector(&PlaneNormal); 2773 *out<< Verbose(4) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;2774 Log() << Verbose(4) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl; 2774 2775 2775 2776 // go through all connected points and calculate angle … … 2779 2780 helper.ProjectOntoPlane(&PlaneNormal); 2780 2781 double angle = GetAngle(helper, AngleZero, OrthogonalVector); 2781 *out<< Verbose(3) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl;2782 Log() << Verbose(3) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl; 2782 2783 anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner))); 2783 2784 } … … 2789 2790 delete(connectedPoints); 2790 2791 2791 *out<< Verbose(2) << "End of GetCircleOfConnectedPoints" << endl;2792 Log() << Verbose(2) << "End of GetCircleOfConnectedPoints" << endl; 2792 2793 2793 2794 return connectedCircle; … … 2800 2801 * @return list of the all points linked to the provided one 2801 2802 */ 2802 list<list<TesselPoint*> *> * Tesselation::GetPathsOfConnectedPoints( ofstream *out,const TesselPoint* const Point) const2803 list<list<TesselPoint*> *> * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const 2803 2804 { 2804 2805 map<double, TesselPoint*> anglesOfPoints; … … 2821 2822 ReferencePoint = PointRunner->second; 2822 2823 } else { 2823 *out<< Verbose(2) << "ERROR: GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;2824 Log() << Verbose(2) << "ERROR: GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl; 2824 2825 return NULL; 2825 2826 } … … 2838 2839 LineRunner = TouchedLine.find(runner->second); 2839 2840 if (LineRunner == TouchedLine.end()) { 2840 *out<< Verbose(2) << "ERROR: I could not find " << *runner->second << " in the touched list." << endl;2841 Log() << Verbose(2) << "ERROR: I could not find " << *runner->second << " in the touched list." << endl; 2841 2842 } else if (!LineRunner->second) { 2842 2843 LineRunner->second = true; … … 2846 2847 StartLine = CurrentLine; 2847 2848 CurrentPoint = CurrentLine->GetOtherEndpoint(ReferencePoint); 2848 *out<< Verbose(3)<< "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl;2849 Log() << Verbose(3)<< "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl; 2849 2850 do { 2850 2851 // push current one 2851 *out<< Verbose(3) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;2852 Log() << Verbose(3) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl; 2852 2853 connectedPath->push_back(CurrentPoint->node); 2853 2854 2854 2855 // find next triangle 2855 2856 for (TriangleMap::iterator Runner = CurrentLine->triangles.begin(); Runner != CurrentLine->triangles.end(); Runner++) { 2856 *out<< Verbose(3) << "INFO: Inspecting triangle " << *Runner->second << "." << endl;2857 Log() << Verbose(3) << "INFO: Inspecting triangle " << *Runner->second << "." << endl; 2857 2858 if ((Runner->second != triangle)) { // look for first triangle not equal to old one 2858 2859 triangle = Runner->second; … … 2861 2862 if (!TriangleRunner->second) { 2862 2863 TriangleRunner->second = true; 2863 *out<< Verbose(3) << "INFO: Connecting triangle is " << *triangle << "." << endl;2864 Log() << Verbose(3) << "INFO: Connecting triangle is " << *triangle << "." << endl; 2864 2865 break; 2865 2866 } else { 2866 *out<< Verbose(3) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl;2867 Log() << Verbose(3) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl; 2867 2868 triangle = NULL; 2868 2869 } 2869 2870 } else { 2870 *out<< Verbose(2) << "ERROR: I could not find " << *triangle << " in the touched list." << endl;2871 Log() << Verbose(2) << "ERROR: I could not find " << *triangle << " in the touched list." << endl; 2871 2872 triangle = NULL; 2872 2873 } … … 2879 2880 if ((triangle->lines[i] != CurrentLine) && (triangle->lines[i]->ContainsBoundaryPoint(ReferencePoint))) { // not the current line and still containing Point 2880 2881 CurrentLine = triangle->lines[i]; 2881 *out<< Verbose(3) << "INFO: Connecting line is " << *CurrentLine << "." << endl;2882 Log() << Verbose(3) << "INFO: Connecting line is " << *CurrentLine << "." << endl; 2882 2883 break; 2883 2884 } … … 2885 2886 LineRunner = TouchedLine.find(CurrentLine); 2886 2887 if (LineRunner == TouchedLine.end()) 2887 *out<< Verbose(2) << "ERROR: I could not find " << *CurrentLine << " in the touched list." << endl;2888 Log() << Verbose(2) << "ERROR: I could not find " << *CurrentLine << " in the touched list." << endl; 2888 2889 else 2889 2890 LineRunner->second = true; … … 2893 2894 } while (CurrentLine != StartLine); 2894 2895 // last point is missing, as it's on start line 2895 *out<< Verbose(3) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;2896 Log() << Verbose(3) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl; 2896 2897 if (StartLine->GetOtherEndpoint(ReferencePoint)->node != connectedPath->back()) 2897 2898 connectedPath->push_back(StartLine->GetOtherEndpoint(ReferencePoint)->node); … … 2899 2900 ListOfPaths->push_back(connectedPath); 2900 2901 } else { 2901 *out<< Verbose(3) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl;2902 Log() << Verbose(3) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl; 2902 2903 } 2903 2904 } 2904 2905 } else { 2905 *out<< Verbose(1) << "ERROR: There are no lines attached to " << *ReferencePoint << "." << endl;2906 Log() << Verbose(1) << "ERROR: There are no lines attached to " << *ReferencePoint << "." << endl; 2906 2907 } 2907 2908 … … 2915 2916 * @return list of the closed paths 2916 2917 */ 2917 list<list<TesselPoint*> *> * Tesselation::GetClosedPathsOfConnectedPoints( ofstream *out,const TesselPoint* const Point) const2918 { 2919 list<list<TesselPoint*> *> *ListofPaths = GetPathsOfConnectedPoints( out,Point);2918 list<list<TesselPoint*> *> * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const 2919 { 2920 list<list<TesselPoint*> *> *ListofPaths = GetPathsOfConnectedPoints(Point); 2920 2921 list<list<TesselPoint*> *> *ListofClosedPaths = new list<list<TesselPoint*> *>; 2921 2922 list<TesselPoint*> *connectedPath = NULL; … … 2930 2931 connectedPath = *ListRunner; 2931 2932 2932 *out<< Verbose(2) << "INFO: Current path is " << connectedPath << "." << endl;2933 Log() << Verbose(2) << "INFO: Current path is " << connectedPath << "." << endl; 2933 2934 2934 2935 // go through list, look for reappearance of starting Point and count … … 2940 2941 if ((*CircleRunner == *CircleStart) && (CircleRunner != CircleStart)) { // is not the very first point 2941 2942 // we have a closed circle from Marker to new Marker 2942 *out<< Verbose(3) << count+1 << ". closed path consists of: ";2943 Log() << Verbose(3) << count+1 << ". closed path consists of: "; 2943 2944 newPath = new list<TesselPoint*>; 2944 2945 list<TesselPoint*>::iterator CircleSprinter = Marker; 2945 2946 for (; CircleSprinter != CircleRunner; CircleSprinter++) { 2946 2947 newPath->push_back(*CircleSprinter); 2947 *out<< (**CircleSprinter) << " <-> ";2948 Log() << Verbose(0) << (**CircleSprinter) << " <-> "; 2948 2949 } 2949 *out<< ".." << endl;2950 Log() << Verbose(0) << ".." << endl; 2950 2951 count++; 2951 2952 Marker = CircleRunner; … … 2956 2957 } 2957 2958 } 2958 *out<< Verbose(3) << "INFO: " << count << " closed additional path(s) have been created." << endl;2959 Log() << Verbose(3) << "INFO: " << count << " closed additional path(s) have been created." << endl; 2959 2960 2960 2961 // delete list of paths … … 2976 2977 * \return pointer to allocated list of triangles 2977 2978 */ 2978 set<BoundaryTriangleSet*> *Tesselation::GetAllTriangles( ofstream *out,const BoundaryPointSet * const Point) const2979 set<BoundaryTriangleSet*> *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const 2979 2980 { 2980 2981 set<BoundaryTriangleSet*> *connectedTriangles = new set<BoundaryTriangleSet*>; 2981 2982 2982 2983 if (Point == NULL) { 2983 *out<< Verbose(1) << "ERROR: Point given is NULL." << endl;2984 Log() << Verbose(1) << "ERROR: Point given is NULL." << endl; 2984 2985 } else { 2985 2986 // go through its lines and insert all triangles … … 3005 3006 * \return volume added to the volume inside the tesselated surface by the removal 3006 3007 */ 3007 double Tesselation::RemovePointFromTesselatedSurface( ofstream *out,class BoundaryPointSet *point) {3008 double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point) { 3008 3009 class BoundaryLineSet *line = NULL; 3009 3010 class BoundaryTriangleSet *triangle = NULL; … … 3013 3014 3014 3015 if (point == NULL) { 3015 *out<< Verbose(1) << "ERROR: Cannot remove the point " << point << ", it's NULL!" << endl;3016 Log() << Verbose(1) << "ERROR: Cannot remove the point " << point << ", it's NULL!" << endl; 3016 3017 return 0.; 3017 3018 } else 3018 *out<< Verbose(2) << "Removing point " << *point << " from tesselated boundary ..." << endl;3019 Log() << Verbose(2) << "Removing point " << *point << " from tesselated boundary ..." << endl; 3019 3020 3020 3021 // copy old location for the volume … … 3023 3024 // get list of connected points 3024 3025 if (point->lines.empty()) { 3025 *out<< Verbose(1) << "ERROR: Cannot remove the point " << *point << ", it's connected to no lines!" << endl;3026 Log() << Verbose(1) << "ERROR: Cannot remove the point " << *point << ", it's connected to no lines!" << endl; 3026 3027 return 0.; 3027 3028 } 3028 3029 3029 list<list<TesselPoint*> *> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints( out,point->node);3030 list<list<TesselPoint*> *> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node); 3030 3031 list<TesselPoint*> *connectedPath = NULL; 3031 3032 … … 3046 3047 NormalVector.Zero(); 3047 3048 for (map<class BoundaryTriangleSet *, int>::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) { 3048 *out<< Verbose(3) << "INFO: Removing triangle " << *(Runner->first) << "." << endl;3049 Log() << Verbose(3) << "INFO: Removing triangle " << *(Runner->first) << "." << endl; 3049 3050 NormalVector.SubtractVector(&Runner->first->NormalVector); // has to point inward 3050 3051 RemoveTesselationTriangle(Runner->first); 3051 3052 count++; 3052 3053 } 3053 *out<< Verbose(1) << count << " triangles were removed." << endl;3054 Log() << Verbose(1) << count << " triangles were removed." << endl; 3054 3055 3055 3056 list<list<TesselPoint*> *>::iterator ListAdvance = ListOfClosedPaths->begin(); … … 3076 3077 smallestangle = 0.; 3077 3078 for (MiddleNode = connectedPath->begin(); MiddleNode != connectedPath->end(); MiddleNode++) { 3078 cout<< Verbose(3) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;3079 Log() << Verbose(3) << "INFO: MiddleNode is " << **MiddleNode << "." << endl; 3079 3080 // construct vectors to next and previous neighbour 3080 3081 StartNode = MiddleNode; … … 3082 3083 StartNode = connectedPath->end(); 3083 3084 StartNode--; 3084 // cout<< Verbose(3) << "INFO: StartNode is " << **StartNode << "." << endl;3085 //Log() << Verbose(3) << "INFO: StartNode is " << **StartNode << "." << endl; 3085 3086 Point.CopyVector((*StartNode)->node); 3086 3087 Point.SubtractVector((*MiddleNode)->node); … … 3089 3090 if (StartNode == connectedPath->end()) 3090 3091 StartNode = connectedPath->begin(); 3091 // cout<< Verbose(3) << "INFO: EndNode is " << **StartNode << "." << endl;3092 //Log() << Verbose(3) << "INFO: EndNode is " << **StartNode << "." << endl; 3092 3093 Reference.CopyVector((*StartNode)->node); 3093 3094 Reference.SubtractVector((*MiddleNode)->node); … … 3104 3105 MiddleNode = EndNode; 3105 3106 if (MiddleNode == connectedPath->end()) { 3106 cout<< Verbose(1) << "CRITICAL: Could not find a smallest angle!" << endl;3107 Log() << Verbose(1) << "CRITICAL: Could not find a smallest angle!" << endl; 3107 3108 exit(255); 3108 3109 } … … 3114 3115 if (EndNode == connectedPath->end()) 3115 3116 EndNode = connectedPath->begin(); 3116 cout<< Verbose(4) << "INFO: StartNode is " << **StartNode << "." << endl;3117 cout<< Verbose(4) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;3118 cout<< Verbose(4) << "INFO: EndNode is " << **EndNode << "." << endl;3119 *out<< Verbose(3) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl;3117 Log() << Verbose(4) << "INFO: StartNode is " << **StartNode << "." << endl; 3118 Log() << Verbose(4) << "INFO: MiddleNode is " << **MiddleNode << "." << endl; 3119 Log() << Verbose(4) << "INFO: EndNode is " << **EndNode << "." << endl; 3120 Log() << Verbose(3) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl; 3120 3121 TriangleCandidates[0] = *StartNode; 3121 3122 TriangleCandidates[1] = *MiddleNode; 3122 3123 TriangleCandidates[2] = *EndNode; 3123 triangle = GetPresentTriangle( out,TriangleCandidates);3124 triangle = GetPresentTriangle(TriangleCandidates); 3124 3125 if (triangle != NULL) { 3125 cout<< Verbose(1) << "WARNING: New triangle already present, skipping!" << endl;3126 Log() << Verbose(1) << "WARNING: New triangle already present, skipping!" << endl; 3126 3127 StartNode++; 3127 3128 MiddleNode++; … … 3135 3136 continue; 3136 3137 } 3137 *out<< Verbose(5) << "Adding new triangle points."<< endl;3138 Log() << Verbose(5) << "Adding new triangle points."<< endl; 3138 3139 AddTesselationPoint(*StartNode, 0); 3139 3140 AddTesselationPoint(*MiddleNode, 1); 3140 3141 AddTesselationPoint(*EndNode, 2); 3141 *out<< Verbose(5) << "Adding new triangle lines."<< endl;3142 Log() << Verbose(5) << "Adding new triangle lines."<< endl; 3142 3143 AddTesselationLine(TPS[0], TPS[1], 0); 3143 3144 AddTesselationLine(TPS[0], TPS[2], 1); … … 3154 3155 // prepare nodes for next triangle 3155 3156 StartNode = EndNode; 3156 cout<< Verbose(4) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl;3157 Log() << Verbose(4) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl; 3157 3158 connectedPath->remove(*MiddleNode); // remove the middle node (it is surrounded by triangles) 3158 3159 if (connectedPath->size() == 2) { // we are done … … 3161 3162 break; 3162 3163 } else if (connectedPath->size() < 2) { // something's gone wrong! 3163 cout<< Verbose(1) << "CRITICAL: There are only two endpoints left!" << endl;3164 Log() << Verbose(1) << "CRITICAL: There are only two endpoints left!" << endl; 3164 3165 exit(255); 3165 3166 } else { … … 3182 3183 maxgain = 0; 3183 3184 for(list<class BoundaryLineSet *>::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) { 3184 tmp = PickFarthestofTwoBaselines( out,*Runner);3185 tmp = PickFarthestofTwoBaselines(*Runner); 3185 3186 if (maxgain < tmp) { 3186 3187 maxgain = tmp; … … 3190 3191 if (maxgain != 0) { 3191 3192 volume += maxgain; 3192 cout<< Verbose(3) << "Flipping baseline with highest volume" << **Candidate << "." << endl;3193 OtherBase = FlipBaseline( out,*Candidate);3193 Log() << Verbose(3) << "Flipping baseline with highest volume" << **Candidate << "." << endl; 3194 OtherBase = FlipBaseline(*Candidate); 3194 3195 NewLines.erase(Candidate); 3195 3196 NewLines.push_back(OtherBase); … … 3201 3202 delete(connectedPath); 3202 3203 } 3203 *out<< Verbose(1) << count << " triangles were created." << endl;3204 Log() << Verbose(1) << count << " triangles were created." << endl; 3204 3205 } else { 3205 3206 while (!ListOfClosedPaths->empty()) { … … 3209 3210 delete(connectedPath); 3210 3211 } 3211 *out<< Verbose(1) << "No need to create any triangles." << endl;3212 Log() << Verbose(1) << "No need to create any triangles." << endl; 3212 3213 } 3213 3214 delete(ListOfClosedPaths); 3214 3215 3215 *out<< Verbose(1) << "Removed volume is " << volume << "." << endl;3216 Log() << Verbose(1) << "Removed volume is " << volume << "." << endl; 3216 3217 3217 3218 return volume; … … 3283 3284 // sanity check 3284 3285 if (LinesOnBoundary.empty()) { 3285 cout<< Verbose(1) << "Warning: FindAllDegeneratedTriangles() was called without any tesselation structure.";3286 Log() << Verbose(1) << "Warning: FindAllDegeneratedTriangles() was called without any tesselation structure."; 3286 3287 return DegeneratedLines; 3287 3288 } … … 3299 3300 AllLines.clear(); 3300 3301 3301 cout<< Verbose(1) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl;3302 Log() << Verbose(1) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl; 3302 3303 map<int,int>::iterator it; 3303 3304 for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) 3304 cout<< Verbose(2) << (*it).first << " => " << (*it).second << endl;3305 Log() << Verbose(2) << (*it).first << " => " << (*it).second << endl; 3305 3306 3306 3307 return DegeneratedLines; … … 3342 3343 delete(DegeneratedLines); 3343 3344 3344 cout<< Verbose(1) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl;3345 Log() << Verbose(1) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl; 3345 3346 map<int,int>::iterator it; 3346 3347 for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++) 3347 cout<< Verbose(2) << (*it).first << " => " << (*it).second << endl;3348 Log() << Verbose(2) << (*it).first << " => " << (*it).second << endl; 3348 3349 3349 3350 return DegeneratedTriangles; … … 3361 3362 int count = 0; 3362 3363 3363 cout<< Verbose(1) << "Begin of RemoveDegeneratedTriangles" << endl;3364 Log() << Verbose(1) << "Begin of RemoveDegeneratedTriangles" << endl; 3364 3365 3365 3366 for (map<int, int>::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); … … 3420 3421 // erase the pair 3421 3422 count += (int) DegeneratedTriangles->erase(triangle->Nr); 3422 cout<< Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl;3423 Log() << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl; 3423 3424 RemoveTesselationTriangle(triangle); 3424 3425 count += (int) DegeneratedTriangles->erase(partnerTriangle->Nr); 3425 cout<< Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl;3426 Log() << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl; 3426 3427 RemoveTesselationTriangle(partnerTriangle); 3427 3428 } else { 3428 cout<< Verbose(1) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle3429 Log() << Verbose(1) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle 3429 3430 << " and its partner " << *partnerTriangle << " because it is essential for at" 3430 3431 << " least one of the endpoints to be kept in the tesselation structure." << endl; … … 3433 3434 delete(DegeneratedTriangles); 3434 3435 3435 cout<< Verbose(1) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl;3436 cout<< Verbose(1) << "End of RemoveDegeneratedTriangles" << endl;3436 Log() << Verbose(1) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl; 3437 Log() << Verbose(1) << "End of RemoveDegeneratedTriangles" << endl; 3437 3438 } 3438 3439 … … 3445 3446 * \param *LC Linked Cell structure to find nearest point 3446 3447 */ 3447 void Tesselation::AddBoundaryPointByDegeneratedTriangle( ofstream *out,class TesselPoint *point, LinkedCell *LC)3448 { 3449 *out<< Verbose(2) << "Begin of AddBoundaryPointByDegeneratedTriangle" << endl;3448 void Tesselation::AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC) 3449 { 3450 Log() << Verbose(2) << "Begin of AddBoundaryPointByDegeneratedTriangle" << endl; 3450 3451 3451 3452 // find nearest boundary point … … 3461 3462 NearestBoundaryPoint = PointRunner->second; 3462 3463 } else { 3463 *out<< Verbose(1) << "ERROR: I cannot find the boundary point." << endl;3464 Log() << Verbose(1) << "ERROR: I cannot find the boundary point." << endl; 3464 3465 return; 3465 3466 } 3466 *out<< Verbose(2) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl;3467 Log() << Verbose(2) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl; 3467 3468 3468 3469 // go through its lines and find the best one to split … … 3497 3498 3498 3499 // create new triangle to connect point (connects automatically with the missing spot of the chosen line) 3499 *out<< Verbose(5) << "Adding new triangle points."<< endl;3500 Log() << Verbose(5) << "Adding new triangle points."<< endl; 3500 3501 AddTesselationPoint((BestLine->endpoints[0]->node), 0); 3501 3502 AddTesselationPoint((BestLine->endpoints[1]->node), 1); 3502 3503 AddTesselationPoint(point, 2); 3503 *out<< Verbose(5) << "Adding new triangle lines."<< endl;3504 Log() << Verbose(5) << "Adding new triangle lines."<< endl; 3504 3505 AddTesselationLine(TPS[0], TPS[1], 0); 3505 3506 AddTesselationLine(TPS[0], TPS[2], 1); … … 3508 3509 BTS->GetNormalVector(TempTriangle->NormalVector); 3509 3510 BTS->NormalVector.Scale(-1.); 3510 *out<< Verbose(3) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl;3511 Log() << Verbose(3) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl; 3511 3512 AddTesselationTriangle(); 3512 3513 3513 3514 // create other side of this triangle and close both new sides of the first created triangle 3514 *out<< Verbose(5) << "Adding new triangle points."<< endl;3515 Log() << Verbose(5) << "Adding new triangle points."<< endl; 3515 3516 AddTesselationPoint((BestLine->endpoints[0]->node), 0); 3516 3517 AddTesselationPoint((BestLine->endpoints[1]->node), 1); 3517 3518 AddTesselationPoint(point, 2); 3518 *out<< Verbose(5) << "Adding new triangle lines."<< endl;3519 Log() << Verbose(5) << "Adding new triangle lines."<< endl; 3519 3520 AddTesselationLine(TPS[0], TPS[1], 0); 3520 3521 AddTesselationLine(TPS[0], TPS[2], 1); … … 3522 3523 BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount); 3523 3524 BTS->GetNormalVector(TempTriangle->NormalVector); 3524 *out<< Verbose(3) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl;3525 Log() << Verbose(3) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl; 3525 3526 AddTesselationTriangle(); 3526 3527 … … 3529 3530 if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) { 3530 3531 if (BestLine == BTS->lines[i]){ 3531 *out<< Verbose(1) << "CRITICAL: BestLine is same as found line, something's wrong here!" << endl;3532 Log() << Verbose(1) << "CRITICAL: BestLine is same as found line, something's wrong here!" << endl; 3532 3533 exit(255); 3533 3534 } … … 3539 3540 3540 3541 // exit 3541 *out<< Verbose(2) << "End of AddBoundaryPointByDegeneratedTriangle" << endl;3542 Log() << Verbose(2) << "End of AddBoundaryPointByDegeneratedTriangle" << endl; 3542 3543 }; 3543 3544 … … 3547 3548 * \param *cloud PointCloud structure with all nodes 3548 3549 */ 3549 void Tesselation::Output( ofstream *out,const char *filename, const PointCloud * const cloud)3550 void Tesselation::Output(const char *filename, const PointCloud * const cloud) 3550 3551 { 3551 3552 ofstream *tempstream = NULL; … … 3561 3562 NameofTempFile.erase(npos, 1); 3562 3563 NameofTempFile.append(TecplotSuffix); 3563 *out<< Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";3564 Log() << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n"; 3564 3565 tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc); 3565 WriteTecplotFile( out,tempstream, this, cloud, TriangleFilesWritten);3566 WriteTecplotFile(tempstream, this, cloud, TriangleFilesWritten); 3566 3567 tempstream->close(); 3567 3568 tempstream->flush(); … … 3575 3576 NameofTempFile.erase(npos, 1); 3576 3577 NameofTempFile.append(Raster3DSuffix); 3577 *out<< Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";3578 Log() << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n"; 3578 3579 tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc); 3579 WriteRaster3dFile( out,tempstream, this, cloud);3580 IncludeSphereinRaster3D( out,tempstream, this, cloud);3580 WriteRaster3dFile(tempstream, this, cloud); 3581 IncludeSphereinRaster3D(tempstream, this, cloud); 3581 3582 tempstream->close(); 3582 3583 tempstream->flush();
Note:
See TracChangeset
for help on using the changeset viewer.