2020-04-07 14:23:28 -07:00
|
|
|
/*
|
|
|
|
Title : Assignment 2 Execution
|
|
|
|
Author: Edward R. Gonzalez
|
2020-04-06 17:09:57 -07:00
|
|
|
|
2020-04-07 14:23:28 -07:00
|
|
|
Description:
|
|
|
|
Uses the OMeshInterface with the VerifyMesh function to complete the mesh verification based on the requirements listed in the pdf.
|
|
|
|
*/
|
2020-04-06 17:09:57 -07:00
|
|
|
|
2020-04-07 14:23:28 -07:00
|
|
|
#pragma once
|
2020-04-06 17:09:57 -07:00
|
|
|
|
2020-04-06 14:40:20 -07:00
|
|
|
#include "DGL/DGL.hpp"
|
|
|
|
|
|
|
|
#include "Cpp_Alias.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Execution
|
|
|
|
{
|
|
|
|
inline namespace LibraryReferences
|
|
|
|
{
|
|
|
|
using DGL::HE_Model;
|
2020-04-06 17:09:57 -07:00
|
|
|
|
|
|
|
using OMeshInterface::OMesh_HE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerifyMesh(string _filePathForMesh, int genus)
|
|
|
|
{
|
|
|
|
cout << "Verifying: " << _filePathForMesh << endl;
|
|
|
|
|
|
|
|
OMesh_HE mesh;
|
|
|
|
|
|
|
|
mesh.Load(_filePathForMesh);
|
|
|
|
|
|
|
|
|
|
|
|
// Euler Number:
|
|
|
|
|
|
|
|
int eulerNumLeft = mesh.GetVerticies().size() + mesh.GetFaces().size() - mesh.GetEdges().size();
|
|
|
|
|
|
|
|
cout << "Left Side Value: " << eulerNumLeft << endl;
|
|
|
|
|
|
|
|
int eulerNumRight = 2 - 2 * genus;
|
|
|
|
|
|
|
|
cout << "Right Side Value: " << eulerNumRight << endl << endl;
|
|
|
|
|
|
|
|
|
|
|
|
// Gauss Curvatures:
|
|
|
|
|
2020-04-07 14:05:39 -07:00
|
|
|
cout << "Calculating Discrete Gauss Curvatures... (Accuracy is up to 0.0001 epsilon on the floats)" << endl;
|
2020-04-06 17:09:57 -07:00
|
|
|
|
|
|
|
double curvatureByVertex = mesh.GetGuassianCurvature_Discretely();
|
|
|
|
|
|
|
|
cout << "Curvature by Vertex: " << curvatureByVertex << endl;
|
|
|
|
|
|
|
|
double curvatureByEuler = 2 * OMeshInterface::PI() * eulerNumRight;
|
|
|
|
|
|
|
|
cout << "Curvature by Euler : " << curvatureByEuler << endl << endl;
|
|
|
|
|
2020-04-07 14:05:39 -07:00
|
|
|
double fabsResult = fabs(curvatureByEuler - curvatureByVertex);
|
|
|
|
|
|
|
|
if (eulerNumRight == eulerNumLeft && fabs(curvatureByEuler - curvatureByVertex) < 0.0001)
|
2020-04-06 17:09:57 -07:00
|
|
|
{
|
|
|
|
cout << _filePathForMesh << " is valid." << endl << endl;;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-07 14:23:28 -07:00
|
|
|
cout << _filePathForMesh << " is invalid." << endl << endl;
|
2020-04-06 17:09:57 -07:00
|
|
|
}
|
2020-04-06 14:40:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Execute_Assignment2()
|
|
|
|
{
|
2020-04-06 17:09:57 -07:00
|
|
|
cout << "Assignment 2: Mesh operations" << endl << endl;
|
|
|
|
|
|
|
|
VerifyMesh("./Models/bunny.obj", 0);
|
|
|
|
|
|
|
|
VerifyMesh("./Models/eight.obj", 2);
|
|
|
|
|
|
|
|
VerifyMesh("./Models/gargoyle.obj", 0);
|
2020-04-06 14:40:20 -07:00
|
|
|
|
2020-04-06 17:09:57 -07:00
|
|
|
VerifyMesh("./Models/horse.obj", 0);
|
2020-04-06 14:40:20 -07:00
|
|
|
|
2020-04-06 17:09:57 -07:00
|
|
|
VerifyMesh("./Models/torus.obj", 1);
|
|
|
|
|
2020-04-06 14:40:20 -07:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|