From 987ae1f1293755b1738f67420a0c4a0ae97ebef1 Mon Sep 17 00:00:00 2001 From: Ed94 Date: Tue, 7 Apr 2020 17:05:39 -0400 Subject: [PATCH] Got the stuff to check those holes in the tape to work properly. --- Assignment_2_Execution.hpp | 40 ++++---------------------------------- OMesh/OMeshInterface.hpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/Assignment_2_Execution.hpp b/Assignment_2_Execution.hpp index 4b5eaf9..c8aed97 100644 --- a/Assignment_2_Execution.hpp +++ b/Assignment_2_Execution.hpp @@ -18,34 +18,6 @@ namespace Execution 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) { cout << "Verifying: " << _filePathForMesh << endl; @@ -68,7 +40,7 @@ namespace Execution // 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(); @@ -78,7 +50,9 @@ namespace Execution 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;; } @@ -99,14 +73,8 @@ namespace Execution VerifyMesh("./Models/gargoyle.obj", 0); - VerifyMesh("./Models/hand.obj", 1); - VerifyMesh("./Models/horse.obj", 0); - VerifyMesh("./Models/sculpture.obj", 3); - - VerifyMesh("./Models/topology.obj", 13); - VerifyMesh("./Models/torus.obj", 1); return EXIT_SUCCESS; diff --git a/OMesh/OMeshInterface.hpp b/OMesh/OMeshInterface.hpp index cd70875..1935f39 100644 --- a/OMesh/OMeshInterface.hpp +++ b/OMesh/OMeshInterface.hpp @@ -139,9 +139,9 @@ namespace OMeshInterface const double GetGuassianCurvature_Discretely() { - double result = 2 * PI(); + double result = 0; - using FAngleList = vector; + using FAngleList = vector; using AngleList = vector; AngleList vertAngleSumList; @@ -150,6 +150,8 @@ namespace OMeshInterface { using OutgoingEdgeIter = HE_Mesh::VertexOHalfedgeIter; + double vertResult = 2 * PI(); + FAngleList interiorAngles; double sumOfAngles = 0.0; @@ -165,7 +167,7 @@ namespace OMeshInterface float angle = oMeshObj.calc_sector_angle(*oEdgeElem); - angle *= PI() / 180.0; // To Radians + //angle *= PI() / 180.0; // To Radians interiorAngles.push_back(angle); @@ -174,7 +176,9 @@ namespace OMeshInterface vertAngleSumList.push_back(sumOfAngles); - result -= sumOfAngles; + vertResult -= sumOfAngles; + + result += vertResult; } return result;