Changeset 84b811 for molecuilder/src/tesselation.cpp
- Timestamp:
- Aug 20, 2009, 7:48:07 AM (16 years ago)
- Children:
- 5f4960, 6c6d84
- Parents:
- 78dac6 (diff), d6b011 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (08/19/09 14:40:33)
- git-committer:
- Frederik Heber <heber@…> (08/20/09 07:48:07)
- File:
-
- 1 edited
-
molecuilder/src/tesselation.cpp (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/tesselation.cpp
r78dac6 r84b811 219 219 return true; 220 220 } 221 double angle = getAngle(helper[0], helper[1], BaseLineNormal);221 double angle = GetAngle(helper[0], helper[1], BaseLineNormal); 222 222 if ((angle - M_PI) > -MYEPSILON) { 223 223 *out << Verbose(2) << "ACCEPT: Angle is greater than pi: convex." << endl; … … 1402 1402 1403 1403 1404 /** Finds the starting triangle for find_non_convex_border().1405 * Looks at the outermost point per axis, then Find _second_point_for_Tesselation()1406 * for the second and Find _next_suitable_point_via_Angle_of_Sphere() for the third1404 /** Finds the starting triangle for FindNonConvexBorder(). 1405 * Looks at the outermost point per axis, then FindSecondPointForTesselation() 1406 * for the second and FindNextSuitablePointViaAngleOfSphere() for the third 1407 1407 * point are called. 1408 1408 * \param *out output stream for debugging … … 1410 1410 * \param *LC LinkedCell structure with neighbouring TesselPoint's 1411 1411 */ 1412 void Tesselation::Find _starting_triangle(ofstream *out, const double RADIUS, LinkedCell *LC)1413 { 1414 cout << Verbose(1) << "Begin of Find _starting_triangle\n";1412 void Tesselation::FindStartingTriangle(ofstream *out, const double RADIUS, LinkedCell *LC) 1413 { 1414 cout << Verbose(1) << "Begin of FindStartingTriangle\n"; 1415 1415 int i = 0; 1416 1416 LinkedNodes *List = NULL; … … 1418 1418 TesselPoint* SecondPoint = NULL; 1419 1419 TesselPoint* MaxPoint[NDIM]; 1420 double max _coordinate[NDIM];1420 double maxCoordinate[NDIM]; 1421 1421 Vector Oben; 1422 1422 Vector helper; … … 1428 1428 for (i = 0; i < 3; i++) { 1429 1429 MaxPoint[i] = NULL; 1430 max _coordinate[i] = -1;1430 maxCoordinate[i] = -1; 1431 1431 } 1432 1432 … … 1440 1440 if (List != NULL) { 1441 1441 for (LinkedNodes::iterator Runner = List->begin();Runner != List->end();Runner++) { 1442 if ((*Runner)->node->x[i] > max _coordinate[i]) {1442 if ((*Runner)->node->x[i] > maxCoordinate[i]) { 1443 1443 cout << Verbose(2) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl; 1444 max _coordinate[i] = (*Runner)->node->x[i];1444 maxCoordinate[i] = (*Runner)->node->x[i]; 1445 1445 MaxPoint[i] = (*Runner); 1446 1446 } … … 1458 1458 1459 1459 BTS = NULL; 1460 CandidateList *Opt _Candidates = new CandidateList();1460 CandidateList *OptCandidates = new CandidateList(); 1461 1461 for (int k=0;k<NDIM;k++) { 1462 1462 Oben.x[k] = 1.; … … 1465 1465 1466 1466 double ShortestAngle; 1467 TesselPoint* Opt _Candidate = NULL;1467 TesselPoint* OptCandidate = NULL; 1468 1468 ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant. 1469 1469 1470 Find _second_point_for_Tesselation(FirstPoint, NULL, Oben, Opt_Candidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...1471 SecondPoint = Opt _Candidate;1470 FindSecondPointForTesselation(FirstPoint, NULL, Oben, OptCandidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_... 1471 SecondPoint = OptCandidate; 1472 1472 if (SecondPoint == NULL) // have we found a second point? 1473 1473 continue; … … 1500 1500 1501 1501 //cout << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n"; 1502 Find _third_point_for_Tesselation(1503 Oben, SearchDirection, helper, BLS[0], NULL, *&Opt _Candidates, &ShortestAngle, RADIUS, LC1502 FindThirdPointForTesselation( 1503 Oben, SearchDirection, helper, BLS[0], NULL, *&OptCandidates, &ShortestAngle, RADIUS, LC 1504 1504 ); 1505 1505 cout << Verbose(1) << "List of third Points is "; 1506 for (CandidateList::iterator it = Opt _Candidates->begin(); it != Opt_Candidates->end(); ++it) {1506 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1507 1507 cout << " " << *(*it)->point; 1508 1508 } 1509 1509 cout << endl; 1510 1510 1511 for (CandidateList::iterator it = Opt _Candidates->begin(); it != Opt_Candidates->end(); ++it) {1511 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1512 1512 // add third triangle point 1513 1513 AddTesselationPoint((*it)->point, 2); … … 1526 1526 1527 1527 // if we do not reach the end with the next step of iteration, we need to setup a new first line 1528 if (it != Opt _Candidates->end()--) {1528 if (it != OptCandidates->end()--) { 1529 1529 FirstPoint = (*it)->BaseLine->endpoints[0]->node; 1530 1530 SecondPoint = (*it)->point; … … 1541 1541 // remove all candidates from the list and then the list itself 1542 1542 class CandidateForTesselation *remover = NULL; 1543 for (CandidateList::iterator it = Opt _Candidates->begin(); it != Opt_Candidates->end(); ++it) {1543 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1544 1544 remover = *it; 1545 1545 delete(remover); 1546 1546 } 1547 Opt _Candidates->clear();1547 OptCandidates->clear(); 1548 1548 } 1549 1549 } … … 1551 1551 // remove all candidates from the list and then the list itself 1552 1552 class CandidateForTesselation *remover = NULL; 1553 for (CandidateList::iterator it = Opt _Candidates->begin(); it != Opt_Candidates->end(); ++it) {1553 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1554 1554 remover = *it; 1555 1555 delete(remover); 1556 1556 } 1557 delete(Opt _Candidates);1558 cout << Verbose(1) << "End of Find _starting_triangle\n";1557 delete(OptCandidates); 1558 cout << Verbose(1) << "End of FindStartingTriangle\n"; 1559 1559 }; 1560 1560 … … 1568 1568 * @param *LC LinkedCell structure with neighbouring points 1569 1569 */ 1570 bool Tesselation::Find _next_suitable_triangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, LinkedCell *LC)1571 { 1572 cout << Verbose(0) << "Begin of Find _next_suitable_triangle\n";1570 bool Tesselation::FindNextSuitableTriangle(ofstream *out, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, LinkedCell *LC) 1571 { 1572 cout << Verbose(0) << "Begin of FindNextSuitableTriangle\n"; 1573 1573 bool result = true; 1574 CandidateList *Opt _Candidates = new CandidateList();1574 CandidateList *OptCandidates = new CandidateList(); 1575 1575 1576 1576 Vector CircleCenter; … … 1629 1629 1630 1630 // add third point 1631 Find _third_point_for_Tesselation(1632 T.NormalVector, SearchDirection, OldSphereCenter, &Line, ThirdNode, Opt _Candidates,1631 FindThirdPointForTesselation( 1632 T.NormalVector, SearchDirection, OldSphereCenter, &Line, ThirdNode, OptCandidates, 1633 1633 &ShortestAngle, RADIUS, LC 1634 1634 ); … … 1638 1638 } 1639 1639 1640 if (Opt _Candidates->begin() == Opt_Candidates->end()) {1640 if (OptCandidates->begin() == OptCandidates->end()) { 1641 1641 cerr << "WARNING: Could not find a suitable candidate." << endl; 1642 1642 return false; 1643 1643 } 1644 1644 cout << Verbose(1) << "Third Points are "; 1645 for (CandidateList::iterator it = Opt _Candidates->begin(); it != Opt_Candidates->end(); ++it) {1645 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1646 1646 cout << " " << *(*it)->point; 1647 1647 } … … 1649 1649 1650 1650 BoundaryLineSet *BaseRay = &Line; 1651 for (CandidateList::iterator it = Opt _Candidates->begin(); it != Opt_Candidates->end(); ++it) {1651 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1652 1652 cout << Verbose(1) << " Third point candidate is " << *(*it)->point 1653 1653 << " with circumsphere's center at " << (*it)->OptCenter << "." << endl; … … 1668 1668 AddTesselationPoint(BaseRay->endpoints[1]->node, 2); 1669 1669 1670 if (CheckLineCriteria forDegeneratedTriangle(TPS)) {1670 if (CheckLineCriteriaForDegeneratedTriangle(TPS)) { 1671 1671 AddTesselationLine(TPS[0], TPS[1], 0); 1672 1672 AddTesselationLine(TPS[0], TPS[2], 1); … … 1697 1697 // We demand that at most one new degenerate line is created and that this line also already exists (which has to be the case due to existentTrianglesCount == 1) 1698 1698 // i.e. at least one of the three lines must be present with TriangleCount <= 1 1699 if (CheckLineCriteria forDegeneratedTriangle(TPS)) {1699 if (CheckLineCriteriaForDegeneratedTriangle(TPS)) { 1700 1700 AddTesselationLine(TPS[0], TPS[1], 0); 1701 1701 AddTesselationLine(TPS[0], TPS[2], 1); … … 1735 1735 // remove all candidates from the list and then the list itself 1736 1736 class CandidateForTesselation *remover = NULL; 1737 for (CandidateList::iterator it = Opt _Candidates->begin(); it != Opt_Candidates->end(); ++it) {1737 for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) { 1738 1738 remover = *it; 1739 1739 delete(remover); 1740 1740 } 1741 delete(Opt _Candidates);1742 cout << Verbose(0) << "End of Find _next_suitable_triangle\n";1741 delete(OptCandidates); 1742 cout << Verbose(0) << "End of FindNextSuitableTriangle\n"; 1743 1743 return result; 1744 1744 }; … … 2047 2047 * \param *Candidate pointer to candidate node on return 2048 2048 * \param Oben vector indicating the outside 2049 * \param Opt _Candidate reference to recommended candidate on return2049 * \param OptCandidate reference to recommended candidate on return 2050 2050 * \param Storage[3] array storing angles and other candidate information 2051 2051 * \param RADIUS radius of virtual sphere 2052 2052 * \param *LC LinkedCell structure with neighbouring points 2053 2053 */ 2054 void Tesselation::Find _second_point_for_Tesselation(TesselPoint* a, TesselPoint* Candidate, Vector Oben, TesselPoint*& Opt_Candidate, double Storage[3], double RADIUS, LinkedCell *LC)2055 { 2056 cout << Verbose(2) << "Begin of Find _second_point_for_Tesselation" << endl;2054 void Tesselation::FindSecondPointForTesselation(TesselPoint* a, TesselPoint* Candidate, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, LinkedCell *LC) 2055 { 2056 cout << Verbose(2) << "Begin of FindSecondPointForTesselation" << endl; 2057 2057 Vector AngleCheck; 2058 2058 double norm = -1., angle; … … 2092 2092 if (a != Candidate) { 2093 2093 // Calculate center of the circle with radius RADIUS through points a and Candidate 2094 Vector OrthogonalizedOben, a _Candidate, Center;2094 Vector OrthogonalizedOben, aCandidate, Center; 2095 2095 double distance, scaleFactor; 2096 2096 2097 2097 OrthogonalizedOben.CopyVector(&Oben); 2098 a _Candidate.CopyVector(a->node);2099 a _Candidate.SubtractVector(Candidate->node);2100 OrthogonalizedOben.ProjectOntoPlane(&a _Candidate);2098 aCandidate.CopyVector(a->node); 2099 aCandidate.SubtractVector(Candidate->node); 2100 OrthogonalizedOben.ProjectOntoPlane(&aCandidate); 2101 2101 OrthogonalizedOben.Normalize(); 2102 distance = 0.5 * a _Candidate.Norm();2102 distance = 0.5 * aCandidate.Norm(); 2103 2103 scaleFactor = sqrt(((RADIUS * RADIUS) - (distance * distance))); 2104 2104 OrthogonalizedOben.Scale(scaleFactor); … … 2111 2111 AngleCheck.CopyVector(&Center); 2112 2112 AngleCheck.SubtractVector(a->node); 2113 norm = a _Candidate.Norm();2113 norm = aCandidate.Norm(); 2114 2114 // second point shall have smallest angle with respect to Oben vector 2115 2115 if (norm < RADIUS*2.) { … … 2118 2118 //cout << Verbose(3) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]); 2119 2119 cout << Verbose(3) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n"; 2120 Opt _Candidate = Candidate;2120 OptCandidate = Candidate; 2121 2121 Storage[0] = angle; 2122 2122 //cout << Verbose(3) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]); 2123 2123 } else { 2124 //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *Opt _Candidate << endl;2124 //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *OptCandidate << endl; 2125 2125 } 2126 2126 } else { … … 2135 2135 } 2136 2136 } 2137 cout << Verbose(2) << "End of Find _second_point_for_Tesselation" << endl;2137 cout << Verbose(2) << "End of FindSecondPointForTesselation" << endl; 2138 2138 }; 2139 2139 … … 2161 2161 * holds. Then, the normalized projection onto the SearchDirection is either +1 or -1 and thus states whether 2162 2162 * the angle is uniquely in either (0,M_PI] or [M_PI, 2.*M_PI). 2163 * @param NormalVector normal direction of the base triangle (here the unit axis vector, \sa Find _starting_triangle())2163 * @param NormalVector normal direction of the base triangle (here the unit axis vector, \sa FindStartingTriangle()) 2164 2164 * @param SearchDirection general direction where to search for the next point, relative to center of BaseLine 2165 2165 * @param OldSphereCenter center of sphere for base triangle, relative to center of BaseLine, giving null angle for the parameter circle … … 2167 2167 * @param ThirdNode third point to avoid in search 2168 2168 * @param candidates list of equally good candidates to return 2169 * @param ShortestAngle the current path length on this circle band for the current Opt _Candidate2169 * @param ShortestAngle the current path length on this circle band for the current OptCandidate 2170 2170 * @param RADIUS radius of sphere 2171 2171 * @param *LC LinkedCell structure with neighbouring points 2172 2172 */ 2173 void Tesselation::Find _third_point_for_Tesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, LinkedCell *LC)2173 void Tesselation::FindThirdPointForTesselation(Vector NormalVector, Vector SearchDirection, Vector OldSphereCenter, class BoundaryLineSet *BaseLine, class TesselPoint *ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, LinkedCell *LC) 2174 2174 { 2175 2175 Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers … … 2188 2188 CandidateForTesselation *optCandidate = NULL; 2189 2189 2190 cout << Verbose(1) << "Begin of Find _third_point_for_Tesselation" << endl;2190 cout << Verbose(1) << "Begin of FindThirdPointForTesselation" << endl; 2191 2191 2192 2192 //cout << Verbose(2) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl; … … 2345 2345 if (candidates->size() > 1) { 2346 2346 candidates->unique(); 2347 candidates->sort( sortCandidates);2348 } 2349 2350 cout << Verbose(1) << "End of Find _third_point_for_Tesselation" << endl;2347 candidates->sort(SortCandidates); 2348 } 2349 2350 cout << Verbose(1) << "End of FindThirdPointForTesselation" << endl; 2351 2351 }; 2352 2352 … … 2397 2397 } 2398 2398 2399 trianglePoints[0] = findClosestPoint(x, SecondPoint, LC);2399 trianglePoints[0] = FindClosestPoint(x, SecondPoint, LC); 2400 2400 2401 2401 // check whether closest point is "too close" :), then it's inside … … 2408 2408 return NULL; 2409 2409 } 2410 list<TesselPoint*> *connectedPoints = getCircleOfConnectedPoints(out, trianglePoints[0]);2411 list<TesselPoint*> *connectedClosestPoints = getNeighboursonCircleofConnectedPoints(out, connectedPoints, trianglePoints[0], x);2410 list<TesselPoint*> *connectedPoints = GetCircleOfConnectedPoints(out, trianglePoints[0]); 2411 list<TesselPoint*> *connectedClosestPoints = GetNeighboursOnCircleOfConnectedPoints(out, connectedPoints, trianglePoints[0], x); 2412 2412 delete(connectedPoints); 2413 2413 trianglePoints[1] = connectedClosestPoints->front(); … … 2497 2497 * @return list of the all points linked to the provided one 2498 2498 */ 2499 list<TesselPoint*> * Tesselation:: getCircleOfConnectedPoints(ofstream *out, TesselPoint* Point)2499 list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints(ofstream *out, TesselPoint* Point) 2500 2500 { 2501 2501 list<TesselPoint*> *connectedPoints = new list<TesselPoint*>; … … 2558 2558 * @return list of the two points linked to the provided one and closest to the point to be checked, 2559 2559 */ 2560 list<TesselPoint*> * Tesselation:: getNeighboursonCircleofConnectedPoints(ofstream *out, list<TesselPoint*> *connectedPoints, TesselPoint* Point, Vector* Reference)2560 list<TesselPoint*> * Tesselation::GetNeighboursOnCircleOfConnectedPoints(ofstream *out, list<TesselPoint*> *connectedPoints, TesselPoint* Point, Vector* Reference) 2561 2561 { 2562 2562 map<double, TesselPoint*> anglesOfPoints; … … 2597 2597 helper.SubtractVector(Point->node); 2598 2598 helper.ProjectOntoPlane(&PlaneNormal); 2599 double angle = getAngle(helper, AngleZero, OrthogonalVector);2599 double angle = GetAngle(helper, AngleZero, OrthogonalVector); 2600 2600 *out << Verbose(2) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl; 2601 2601 anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner))); … … 2644 2644 return 0.; 2645 2645 } 2646 list<TesselPoint*> *CircleofPoints = getCircleOfConnectedPoints(out, point->node);2646 list<TesselPoint*> *CircleofPoints = GetCircleOfConnectedPoints(out, point->node); 2647 2647 2648 2648 // remove all triangles … … 2716 2716 * \return true - there is such a line (i.e. creation of degenerated triangle is valid), false - no such line (don't create) 2717 2717 */ 2718 bool CheckLineCriteria forDegeneratedTriangle(class BoundaryPointSet *nodes[3])2718 bool CheckLineCriteriaForDegeneratedTriangle(class BoundaryPointSet *nodes[3]) 2719 2719 { 2720 2720 bool result = false; … … 2750 2750 /** Sort function for the candidate list. 2751 2751 */ 2752 bool sortCandidates(CandidateForTesselation* candidate1, CandidateForTesselation* candidate2)2752 bool SortCandidates(CandidateForTesselation* candidate1, CandidateForTesselation* candidate2) 2753 2753 { 2754 2754 Vector BaseLineVector, OrthogonalVector, helper; … … 2800 2800 * @return point which is second closest to the provided one 2801 2801 */ 2802 TesselPoint* findSecondClosestPoint(const Vector* Point, LinkedCell* LC)2802 TesselPoint* FindSecondClosestPoint(const Vector* Point, LinkedCell* LC) 2803 2803 { 2804 2804 LinkedNodes *List = NULL; … … 2846 2846 }; 2847 2847 2848 2849 2850 2848 /** 2851 2849 * Finds the point which is closest to the provided one. … … 2857 2855 * @return point which is closest to the provided one, NULL if none found 2858 2856 */ 2859 TesselPoint* findClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, LinkedCell* LC)2857 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, LinkedCell* LC) 2860 2858 { 2861 2859 LinkedNodes *List = NULL; … … 2904 2902 return closestPoint; 2905 2903 }; 2906 2907 2904 2908 2905 /** … … 2971 2968 } 2972 2969 2970 /** 2971 * Finds all degenerated triangles within the tesselation structure. 2972 * 2973 * @return map of keys of degenerated triangle pairs, each triangle occurs twice 2974 * in the list, once as key and once as value 2975 */ 2976 map<int, int> Tesselation::FindAllDegeneratedTriangles() 2977 { 2978 map<int, int> DegeneratedTriangles; 2979 2980 // sanity check 2981 if (LinesOnBoundary.empty()) { 2982 cout << Verbose(1) << "Warning: FindAllDegeneratedTriangles() was called without any tesselation structure."; 2983 return DegeneratedTriangles; 2984 } 2985 2986 LineMap::iterator LineRunner1, LineRunner2; 2987 2988 for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) { 2989 for (LineRunner2 = LinesOnBoundary.begin(); LineRunner2 != LinesOnBoundary.end(); ++LineRunner2) { 2990 if ((LineRunner1->second != LineRunner2->second) 2991 && (LineRunner1->second->endpoints[0] == LineRunner2->second->endpoints[0]) 2992 && (LineRunner1->second->endpoints[1] == LineRunner2->second->endpoints[1]) 2993 ) { 2994 TriangleMap::iterator TriangleRunner1 = LineRunner1->second->triangles.begin(), 2995 TriangleRunner2 = LineRunner2->second->triangles.begin(); 2996 2997 for (; TriangleRunner1 != LineRunner1->second->triangles.end(); ++TriangleRunner1) { 2998 for (; TriangleRunner2 != LineRunner2->second->triangles.end(); ++TriangleRunner2) { 2999 if ((TriangleRunner1->second != TriangleRunner2->second) 3000 && (TriangleRunner1->second->endpoints[0] == TriangleRunner2->second->endpoints[0]) 3001 && (TriangleRunner1->second->endpoints[1] == TriangleRunner2->second->endpoints[1]) 3002 && (TriangleRunner1->second->endpoints[2] == TriangleRunner2->second->endpoints[2]) 3003 ) { 3004 DegeneratedTriangles[TriangleRunner1->second->Nr] = TriangleRunner2->second->Nr; 3005 DegeneratedTriangles[TriangleRunner2->second->Nr] = TriangleRunner1->second->Nr; 3006 } 3007 } 3008 } 3009 } 3010 } 3011 } 3012 3013 cout << Verbose(1) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles.size() << " triangles." << endl; 3014 map<int,int>::iterator it; 3015 for (it = DegeneratedTriangles.begin(); it != DegeneratedTriangles.end(); it++) 3016 cout << Verbose(2) << (*it).first << " => " << (*it).second << endl; 3017 3018 return DegeneratedTriangles; 3019 } 3020 3021 /** 3022 * Purges degenerated triangles from the tesselation structure if they are not 3023 * necessary to keep a single point within the structure. 3024 */ 3025 void Tesselation::RemoveDegeneratedTriangles() 3026 { 3027 map<int, int> DegeneratedTriangles = FindAllDegeneratedTriangles(); 3028 3029 for (map<int, int>::iterator TriangleKeyRunner = DegeneratedTriangles.begin(); 3030 TriangleKeyRunner != DegeneratedTriangles.end(); ++TriangleKeyRunner 3031 ) { 3032 BoundaryTriangleSet *triangle = TrianglesOnBoundary.find(TriangleKeyRunner->first)->second, 3033 *partnerTriangle = TrianglesOnBoundary.find(TriangleKeyRunner->second)->second; 3034 3035 bool trianglesShareLine = false; 3036 for (int i = 0; i < 3; ++i) 3037 for (int j = 0; j < 3; ++j) 3038 trianglesShareLine = trianglesShareLine || triangle->lines[i] == partnerTriangle->lines[j]; 3039 3040 if (trianglesShareLine 3041 && (triangle->endpoints[1]->LinesCount > 2) 3042 && (triangle->endpoints[2]->LinesCount > 2) 3043 && (triangle->endpoints[0]->LinesCount > 2) 3044 ) { 3045 cout << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl; 3046 RemoveTesselationTriangle(triangle); 3047 cout << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl; 3048 RemoveTesselationTriangle(partnerTriangle); 3049 DegeneratedTriangles.erase(DegeneratedTriangles.find(partnerTriangle->Nr)); 3050 } else { 3051 cout << Verbose(1) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle 3052 << " and its partner " << *partnerTriangle << " because it is essential for at" 3053 << " least one of the endpoints to be kept in the tesselation structure." << endl; 3054 } 3055 } 3056 } 3057 2973 3058 /** Gets the angle between a point and a reference relative to the provided center. 2974 3059 * We have two shanks point and reference between which the angle is calculated … … 2980 3065 * @return angle between point and reference 2981 3066 */ 2982 double getAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector)3067 double GetAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector) 2983 3068 { 2984 3069 if (reference.IsZero())
Note:
See TracChangeset
for help on using the changeset viewer.
