Skip to content

Commit

Permalink
Add fallback for numerically unstable triple points.
Browse files Browse the repository at this point in the history
This change modifies the LinearInterfaceCalculator to fallback to
computing triple points as barycentric points when the indicator
function produces numerically unstable coordinates.

TetMesh angles output now only prints out degenerate tetes.
Previously, it printed all tets after the first degenerate tet.
Additionally, the number of bad tets is printed in the summary.
  • Loading branch information
jonbronson committed May 17, 2017
1 parent 854ed1a commit 68b593d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/lib/cleaver/LinearInterfaceCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,9 @@ void LinearInterfaceCalculator::computeTripleForFace(HalfFace *face) {
bool success = planeIntersect(v1, v2, v3, origin, ray, result);
if (!success)
{
//std::cout << "Failed to Project Triple BACK into 3D: Using Barycenter" << std::endl;
//result = (1.0/3.0)*(v1->pos() + v2->pos() + v3->pos());
//axis = 2;
std::cout << "Failed Axis==1, the most likely candidate to succeeed..." << std::endl;
exit(0);
std::cout << "Numerical Failure projecting triple into 3D: Fall back to Barycenter" << std::endl;
result = (1.0/3.0)*(v1->pos() + v2->pos() + v3->pos());
// std::cout << "Failed Axis==1, the most likely candidate to succeeed..." << std::endl;
}

} else if (axis == 2)
Expand Down Expand Up @@ -378,9 +376,9 @@ void LinearInterfaceCalculator::computeTripleForFace(HalfFace *face) {
bool success = planeIntersect(v1, v2, v3, origin, ray, result);
if (!success)
{
//axis = 3;
std::cout << "Failed Axis==2, the most likely candidate to succeeed..." << std::endl;
exit(0);
std::cout << "Numerical Failure projecting triple into 3D: Fall back to Barycenter" << std::endl;
result = (1.0/3.0)*(v1->pos() + v2->pos() + v3->pos());
// std::cout << "Failed Axis==2, the most likely candidate to succeeed..." << std::endl;
}
} else if (axis == 3)
{
Expand Down Expand Up @@ -429,8 +427,9 @@ void LinearInterfaceCalculator::computeTripleForFace(HalfFace *face) {
bool success = planeIntersect(v1, v2, v3, origin, ray, result);
if (!success)
{
std::cout << "Failed Axis==3, the most likely candidate to succeeed..." << std::endl;
exit(0);
std::cout << "Numerical Failure projecting triple into 3D: Fall back to Barycenter" << std::endl;
result = (1.0/3.0)*(v1->pos() + v2->pos() + v3->pos());
// std::cout << "Failed Axis==3, the most likely candidate to succeeed..." << std::endl;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/lib/cleaver/TetMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ namespace cleaver
}

// DEBUG for flat tets
if(max == 180){
if(local_max == 180){
if (bad_tets > 0)
debug_dump << "," << std::endl;
bad_tets++;
Expand Down Expand Up @@ -1180,6 +1180,9 @@ namespace cleaver
debug_dump << "]}" << std::endl;
debug_dump.close();
status.done();
if (bad_tets > 0) {
std::cout << "Errors: " << bad_tets << " degenerate tets." << std::endl;
}

min_angle = min;
max_angle = max;
Expand Down

0 comments on commit 68b593d

Please sign in to comment.