Changeset 249522 for molecuilder/src
- Timestamp:
- Jan 13, 2010, 2:01:55 PM (16 years ago)
- Children:
- 252790
- Parents:
- 3dea05
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/tesselation.cpp
r3dea05 r249522 3135 3135 // for each point, check its lines, remember closest 3136 3136 Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl; 3137 BoundaryLineSet *ClosestLine = NULL;3137 LineSet ClosestLines; 3138 3138 double MinDistance = 1e+16; 3139 3139 Vector BaseLineIntersection; … … 3157 3157 3158 3158 if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) { // intersection would be outside, take closer endpoint 3159 if ((lengthEndA < MinDistance) && (lengthEndA < lengthEndB)) { 3160 ClosestLine = LineRunner->second; 3161 MinDistance = lengthEndA; 3162 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEndA << "." << endl; 3163 } else if (lengthEndB < MinDistance) { 3164 ClosestLine = LineRunner->second; 3165 MinDistance = lengthEndB; 3166 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is closer with " << lengthEndB << "." << endl; 3167 } else { 3159 const double lengthEnd = Min(lengthEndA, lengthEndB); 3160 if (lengthEnd - MinDistance < -MYEPSILON) { // new best line 3161 ClosestLines.clear(); 3162 ClosestLines.insert(LineRunner->second); 3163 MinDistance = lengthEnd; 3164 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl; 3165 } else if (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate 3166 ClosestLines.insert(LineRunner->second); 3167 Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl; 3168 } else { // line is worse 3168 3169 Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl; 3169 3170 } … … 3179 3180 eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl; 3180 3181 } 3181 if ((ClosestLine == NULL) || (distance < MinDistance)) {3182 ClosestLine = LineRunner->second;3182 if ((ClosestLines.empty()) || (distance < MinDistance)) { 3183 ClosestLines.insert(LineRunner->second); 3183 3184 MinDistance = distance; 3184 Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl;3185 Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl; 3185 3186 } else { 3186 3187 Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl; … … 3192 3193 3193 3194 // check whether closest line is "too close" :), then it's inside 3194 if (ClosestLine == NULL) {3195 if (ClosestLines.empty()) { 3195 3196 Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl; 3196 3197 return NULL; 3197 3198 } 3198 3199 TriangleList * candidates = new TriangleList; 3199 for (TriangleMap::iterator Runner = ClosestLine->triangles.begin(); Runner != ClosestLine->triangles.end(); Runner++) { 3200 for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++) 3201 for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) { 3200 3202 candidates->push_back(Runner->second); 3201 3203 }
Note:
See TracChangeset
for help on using the changeset viewer.