Changeset 0310b8 for molecuilder
- Timestamp:
- Dec 17, 2009, 5:45:35 PM (16 years ago)
- Children:
- f4df97
- Parents:
- 281324
- Location:
- molecuilder/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/tesselation.cpp
r281324 r0310b8 879 879 CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) : 880 880 BaseLine(line), 881 IsDegenerated(false),882 881 ShortestAngle(2.*M_PI), 883 882 OtherShortestAngle(2.*M_PI) … … 2781 2780 double otherradius; 2782 2781 double alpha, Otheralpha; // angles (i.e. parameter for the circle). 2783 bool IsDegenerated;2784 2782 int N[NDIM], Nlower[NDIM], Nupper[NDIM]; 2785 2783 TesselPoint *Candidate = NULL; 2786 TesselPoint *CandidateTriangle[3];2787 2784 2788 2785 Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl; … … 2799 2796 RelativeOldSphereCenter.CopyVector(&OldSphereCenter); 2800 2797 RelativeOldSphereCenter.SubtractVector(&CircleCenter); 2801 2802 CandidateTriangle[0] = CandidateLine.BaseLine->endpoints[0]->node;2803 CandidateTriangle[1] = CandidateLine.BaseLine->endpoints[1]->node;2804 2798 2805 2799 // calculate squared radius TesselPoint *ThirdNode,f circle … … 2859 2853 Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl; 2860 2854 2861 if ( (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node))2855 if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node) 2862 2856 && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON) 2863 2857 ) { … … 2889 2883 alpha = min(alpha, Otheralpha); 2890 2884 2891 CandidateTriangle[2] = Candidate; 2892 // the idea of the IsDegenerated flag is not to put a penalty on degenerated triangles, but to push them to the 2893 // very end of the Tesselation::OpenLines list. 2894 IsDegenerated = (CheckPresenceOfTriangle(CandidateTriangle) >= 3); 2895 if (!IsDegenerated && CandidateLine.IsDegenerated) { // if current is not, but old one was, comparison would be unfair 2896 // if there is a better candidate, drop the current list and add the new candidate 2897 // otherwise ignore the new candidate and keep the list 2898 if (CandidateLine.ShortestAngle-2.*M_PI > (alpha - HULLEPSILON)) { 2899 if (fabs(alpha - Otheralpha) > MYEPSILON) { 2900 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 2901 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 2902 } else { 2903 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 2904 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 2905 } 2906 // if there is an equal candidate, add it to the list without clearing the list 2907 if ((CandidateLine.ShortestAngle-2.*M_PI - HULLEPSILON) < alpha) { 2908 CandidateLine.pointlist.push_back(Candidate); 2909 Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " 2910 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2911 } else { 2912 // remove all candidates from the list and then the list itself 2913 CandidateLine.pointlist.clear(); 2914 CandidateLine.pointlist.push_back(Candidate); 2915 Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " 2916 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2917 } 2918 CandidateLine.ShortestAngle = alpha; 2919 CandidateLine.IsDegenerated = IsDegenerated; 2920 if (IsDegenerated) 2921 CandidateLine.ShortestAngle += 2.*M_PI; 2922 Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl; 2885 // if there is a better candidate, drop the current list and add the new candidate 2886 // otherwise ignore the new candidate and keep the list 2887 if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) { 2888 if (fabs(alpha - Otheralpha) > MYEPSILON) { 2889 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 2890 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 2923 2891 } else { 2924 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 2925 Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2926 } else { 2927 Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2928 } 2892 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 2893 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 2929 2894 } 2895 // if there is an equal candidate, add it to the list without clearing the list 2896 if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) { 2897 CandidateLine.pointlist.push_back(Candidate); 2898 Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " 2899 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2900 } else { 2901 // remove all candidates from the list and then the list itself 2902 CandidateLine.pointlist.clear(); 2903 CandidateLine.pointlist.push_back(Candidate); 2904 Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " 2905 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2906 } 2907 CandidateLine.ShortestAngle = alpha; 2908 Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl; 2930 2909 } else { 2931 // if there is a better candidate, drop the current list and add the new candidate 2932 // otherwise ignore the new candidate and keep the list 2933 if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) { 2934 if (fabs(alpha - Otheralpha) > MYEPSILON) { 2935 CandidateLine.OptCenter.CopyVector(&NewSphereCenter); 2936 CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter); 2937 } else { 2938 CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter); 2939 CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter); 2940 } 2941 // if there is an equal candidate, add it to the list without clearing the list 2942 if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) { 2943 CandidateLine.pointlist.push_back(Candidate); 2944 Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " 2945 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2946 } else { 2947 // remove all candidates from the list and then the list itself 2948 CandidateLine.pointlist.clear(); 2949 CandidateLine.pointlist.push_back(Candidate); 2950 Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " 2951 << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl; 2952 } 2953 CandidateLine.ShortestAngle = alpha; 2954 Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl; 2910 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 2911 Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2955 2912 } else { 2956 if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) { 2957 Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl; 2958 } else { 2959 Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2960 } 2913 Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl; 2961 2914 } 2962 2915 } 2963 2964 2916 } else { 2965 2917 Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl; … … 4288 4240 TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints(); 4289 4241 4242 // check whether number is bigger than 2, otherwise it's just a simply degenerated one and nothing to do. 4290 4243 if (T->size() == 2) { 4291 4244 Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl; 4292 4245 delete(T); 4293 4246 continue; 4247 } 4248 4249 // check whether number is even 4250 // If this case occurs, we have to think about it! 4251 // The Problem is probably due to two degenerated polygons being connected by a bridging, non-degenerated polygon, as somehow one node has 4252 // connections to either polygon ... 4253 if (T->size() % 2 != 0) { 4254 eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl; 4255 performCriticalExit(); 4294 4256 } 4295 4257 -
molecuilder/src/tesselation.hpp
r281324 r0310b8 246 246 Vector OptCenter; 247 247 Vector OtherOptCenter; 248 bool IsDegenerated;249 248 double ShortestAngle; 250 249 double OtherShortestAngle;
Note:
See TracChangeset
for help on using the changeset viewer.