Changeset daf956 for molecuilder/src/tesselation.cpp
- Timestamp:
- Oct 2, 2009, 3:19:51 PM (16 years ago)
- Children:
- e1f6d7
- Parents:
- fca6e7
- File:
-
- 1 edited
-
molecuilder/src/tesselation.cpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/tesselation.cpp
rfca6e7 rdaf956 215 215 node = runner->second->GetThirdEndpoint(this); 216 216 if (node != NULL) { 217 *out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;217 //*out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl; 218 218 helper[i].CopyVector(node->node->node); 219 219 helper[i].SubtractVector(&BaseLineCenter); 220 220 helper[i].MakeNormalVector(&BaseLine); // we want to compare the triangle's heights' angles! 221 *out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;221 //*out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl; 222 222 i++; 223 223 } else { … … 226 226 } 227 227 } 228 *out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;228 //*out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl; 229 229 if (NormalCheck.NormSquared() < MYEPSILON) { 230 230 *out << Verbose(3) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl; … … 374 374 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane 375 375 * This we test if it's really on the plane and whether it's inside the triangle on the plane or not. 376 * The latter is done as follows: if it's really outside, then for any endpoint of the triangle and it's opposite377 * base line, the intersection between the line from endpoint to intersection and the base line will have a Vector::NormSquared()378 * smaller than the first line.376 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line 377 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between 378 * the first two basepoints) or not. 379 379 * \param *out output stream for debugging 380 380 * \param *MolCenter offset vector of line … … 408 408 exit(255); 409 409 } 410 CrossPoint.SubtractVector(endpoints[i%3]->node->node); 410 CrossPoint.SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector 411 411 412 412 // check whether intersection is inside or not by comparing length of intersection and length of cross point 413 if ((CrossPoint.NormSquared() - helper.NormSquared()) > -MYEPSILON) { // inside413 if ((CrossPoint.NormSquared() - helper.NormSquared()) < MYEPSILON) { // inside 414 414 return true; 415 415 } else { // outside! … … 439 439 for(int i=0;i<3;i++) 440 440 if (point == endpoints[i]) 441 return true; 442 return false; 443 }; 444 445 /** Checks whether point is any of the three endpoints this triangle contains. 446 * \param *point TesselPoint to test 447 * \return true - point is of the triangle, false - is not 448 */ 449 bool BoundaryTriangleSet::ContainsBoundaryPoint(class TesselPoint *point) 450 { 451 for(int i=0;i<3;i++) 452 if (point == endpoints[i]->node) 441 453 return true; 442 454 return false; … … 1088 1100 Vector *Center = cloud->GetCenter(out); 1089 1101 list<BoundaryTriangleSet*> *triangles = NULL; 1102 bool AddFlag = false; 1103 LinkedCell *BoundaryPoints = NULL; 1090 1104 1091 1105 *out << Verbose(1) << "Begin of InsertStraddlingPoints" << endl; 1092 1106 1093 1107 cloud->GoToFirst(); 1108 BoundaryPoints = new LinkedCell(this, 5.); 1094 1109 while (!cloud->IsEnd()) { // we only have to go once through all points, as boundary can become only bigger 1095 LinkedCell BoundaryPoints(this, 5.); 1110 if (AddFlag) { 1111 delete(BoundaryPoints); 1112 BoundaryPoints = new LinkedCell(this, 5.); 1113 AddFlag = false; 1114 } 1096 1115 Walker = cloud->GetPoint(); 1097 1116 *out << Verbose(2) << "Current point is " << *Walker << "." << endl; 1098 1117 // get the next triangle 1099 triangles = FindClosestTrianglesToPoint(out, Walker->node, &BoundaryPoints); 1100 if (triangles == NULL) { 1101 *out << Verbose(1) << "No triangles found, probably a tesselation point itself." << endl; 1118 triangles = FindClosestTrianglesToPoint(out, Walker->node, BoundaryPoints); 1119 BTS = triangles->front(); 1120 if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) { 1121 *out << Verbose(2) << "No triangles found, probably a tesselation point itself." << endl; 1102 1122 cloud->GoToNext(); 1103 1123 continue; 1104 1124 } else { 1105 BTS = triangles->front();1106 1125 } 1107 1126 *out << Verbose(2) << "Closest triangle is " << *BTS << "." << endl; … … 1126 1145 // add Walker to boundary points 1127 1146 *out << Verbose(2) << "Adding " << *Walker << " to BoundaryPoints." << endl; 1147 AddFlag = true; 1128 1148 if (AddBoundaryPoint(Walker,0)) 1129 1149 NewPoint = BPS[0]; … … 1279 1299 }; 1280 1300 1281 /** Function tries to add Triangle just created to Triangle and remarks if already existent (Failure of algorithm).1282 * Furthermore it adds the triangle to all of its lines, in order to recognize those which are saturated later.1301 /** Function adds triangle to global list. 1302 * Furthermore, the triangle receives the next free id and id counter \a TrianglesOnBoundaryCount is increased. 1283 1303 */ 1284 1304 void Tesselation::AddTesselationTriangle() … … 1289 1309 TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS)); 1290 1310 TrianglesOnBoundaryCount++; 1311 1312 // set as last new triangle 1313 LastTriangle = BTS; 1314 1315 // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet 1316 }; 1317 1318 /** Function adds triangle to global list. 1319 * Furthermore, the triangle number is set to \a nr. 1320 * \param nr triangle number 1321 */ 1322 void Tesselation::AddTesselationTriangle(int nr) 1323 { 1324 cout << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl; 1325 1326 // add triangle to global map 1327 TrianglesOnBoundary.insert(TrianglePair(nr, BTS)); 1291 1328 1292 1329 // set as last new triangle … … 2097 2134 BTS = new class BoundaryTriangleSet(BLS, OldTriangleNrs[0]); 2098 2135 BTS->GetNormalVector(BaseLineNormal); 2099 TrianglesOnBoundary.insert(TrianglePair(OldTriangleNrs[0], BTS));2136 AddTesselationTriangle(OldTriangleNrs[0]); 2100 2137 *out << Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl; 2101 2138 … … 2105 2142 BTS = new class BoundaryTriangleSet(BLS, OldTriangleNrs[1]); 2106 2143 BTS->GetNormalVector(BaseLineNormal); 2107 TrianglesOnBoundary.insert(TrianglePair(OldTriangleNrs[1], BTS));2144 AddTesselationTriangle(OldTriangleNrs[1]); 2108 2145 *out << Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl; 2109 2146 } else { … … 2481 2518 } 2482 2519 if (trianglePoints[0]->node->DistanceSquared(x) < MYEPSILON) { 2483 *out << Verbose( 2) << "Point is right on a tesselation point, no nearest triangle." << endl;2520 *out << Verbose(3) << "Point is right on a tesselation point, no nearest triangle." << endl; 2484 2521 PointMap::iterator PointRunner = PointsOnBoundary.find(trianglePoints[0]->nr); 2485 2522 triangles = new list<BoundaryTriangleSet*>; … … 2512 2549 *out << Verbose(1) << "ERROR: IsInnerPoint encounters serious error, point " << i << " not found." << endl; 2513 2550 } 2514 *out << Verbose(1) << "List of triangle points:" << endl;2515 *out << Verbose(2) << *trianglePoints[i] << endl;2551 //*out << Verbose(2) << "List of triangle points:" << endl; 2552 //*out << Verbose(3) << *trianglePoints[i] << endl; 2516 2553 } 2517 2554 2518 2555 triangles = FindTriangles(trianglePoints); 2519 *out << Verbose( 1) << "List of possible triangles:" << endl;2556 *out << Verbose(2) << "List of possible triangles:" << endl; 2520 2557 for(list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) 2521 *out << Verbose( 2) << **Runner << endl;2558 *out << Verbose(3) << **Runner << endl; 2522 2559 2523 2560 delete(connectedClosestPoints); … … 3299 3336 int count = 0; 3300 3337 3338 cout << Verbose(1) << "Begin of RemoveDegeneratedTriangles" << endl; 3339 3301 3340 for (map<int, int>::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); 3302 3341 TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner … … 3370 3409 3371 3410 cout << Verbose(1) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl; 3411 cout << Verbose(1) << "End of RemoveDegeneratedTriangles" << endl; 3372 3412 } 3373 3413
Note:
See TracChangeset
for help on using the changeset viewer.
