Got the stuff to check those holes in the tape to work properly.

This commit is contained in:
Edward R. Gonzalez 2020-04-07 17:05:39 -04:00
parent b0b228d613
commit 987ae1f129
2 changed files with 12 additions and 40 deletions

View File

@ -18,34 +18,6 @@ namespace Execution
using OMeshInterface::OMesh_HE; using OMeshInterface::OMesh_HE;
} }
bool Float64_ApproxEqual(double _first, double _second)
{
//Implementation influenced by: https://floating-point-gui.de/errors/comparison/, https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
double firstAbs = fabsl(_first ),
secondAbs = fabsl(_second ),
diffAbs = fabsl(_first - _second) ;
bool ExactlyEqual,
CloseToZero ;
ExactlyEqual = (_first == _second );
CloseToZero = (_first == 0 || _second == 0 || diffAbs < DBL_MIN);
if (ExactlyEqual) //Handles infinites
{
return true;
}
else if (CloseToZero) //Close to zero
{
return (diffAbs < (DBL_EPSILON * DBL_EPSILON));
}
else //Relative Error
{
return (diffAbs / fminl(firstAbs + secondAbs, DBL_MAX) < DBL_EPSILON);
}
}
void VerifyMesh(string _filePathForMesh, int genus) void VerifyMesh(string _filePathForMesh, int genus)
{ {
cout << "Verifying: " << _filePathForMesh << endl; cout << "Verifying: " << _filePathForMesh << endl;
@ -68,7 +40,7 @@ namespace Execution
// Gauss Curvatures: // Gauss Curvatures:
cout << "Calculating Discrete Gauss Curvatures..." << endl; cout << "Calculating Discrete Gauss Curvatures... (Accuracy is up to 0.0001 epsilon on the floats)" << endl;
double curvatureByVertex = mesh.GetGuassianCurvature_Discretely(); double curvatureByVertex = mesh.GetGuassianCurvature_Discretely();
@ -78,7 +50,9 @@ namespace Execution
cout << "Curvature by Euler : " << curvatureByEuler << endl << endl; cout << "Curvature by Euler : " << curvatureByEuler << endl << endl;
if (eulerNumRight == eulerNumLeft && Float64_ApproxEqual(curvatureByVertex, curvatureByEuler)) double fabsResult = fabs(curvatureByEuler - curvatureByVertex);
if (eulerNumRight == eulerNumLeft && fabs(curvatureByEuler - curvatureByVertex) < 0.0001)
{ {
cout << _filePathForMesh << " is valid." << endl << endl;; cout << _filePathForMesh << " is valid." << endl << endl;;
} }
@ -99,14 +73,8 @@ namespace Execution
VerifyMesh("./Models/gargoyle.obj", 0); VerifyMesh("./Models/gargoyle.obj", 0);
VerifyMesh("./Models/hand.obj", 1);
VerifyMesh("./Models/horse.obj", 0); VerifyMesh("./Models/horse.obj", 0);
VerifyMesh("./Models/sculpture.obj", 3);
VerifyMesh("./Models/topology.obj", 13);
VerifyMesh("./Models/torus.obj", 1); VerifyMesh("./Models/torus.obj", 1);
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -139,9 +139,9 @@ namespace OMeshInterface
const double GetGuassianCurvature_Discretely() const double GetGuassianCurvature_Discretely()
{ {
double result = 2 * PI(); double result = 0;
using FAngleList = vector<float>; using FAngleList = vector<float >;
using AngleList = vector<double>; using AngleList = vector<double>;
AngleList vertAngleSumList; AngleList vertAngleSumList;
@ -150,6 +150,8 @@ namespace OMeshInterface
{ {
using OutgoingEdgeIter = HE_Mesh::VertexOHalfedgeIter; using OutgoingEdgeIter = HE_Mesh::VertexOHalfedgeIter;
double vertResult = 2 * PI();
FAngleList interiorAngles; FAngleList interiorAngles;
double sumOfAngles = 0.0; double sumOfAngles = 0.0;
@ -165,7 +167,7 @@ namespace OMeshInterface
float angle = oMeshObj.calc_sector_angle(*oEdgeElem); float angle = oMeshObj.calc_sector_angle(*oEdgeElem);
angle *= PI() / 180.0; // To Radians //angle *= PI() / 180.0; // To Radians
interiorAngles.push_back(angle); interiorAngles.push_back(angle);
@ -174,7 +176,9 @@ namespace OMeshInterface
vertAngleSumList.push_back(sumOfAngles); vertAngleSumList.push_back(sumOfAngles);
result -= sumOfAngles; vertResult -= sumOfAngles;
result += vertResult;
} }
return result; return result;