Files
igl/tutorial/701_Statistics/main.cpp
T
b0fd49d598 CMake refactor (#1805)
* Start CMake refactoring.

* WIP on instlal().

* Handle install + hunter setup.

* Handle module options + igl_include helper.

* Build all tutorials again.

* Update CMake for unit tests.

* Update triangle lib.

* Update Hunter integration.

* Fix for header-only mode.

* Fix Windows compilation + add GMP/MPFR find_package + set VS folders.

* Fix CGAL build.

* Add copy dll for Windows + improve find gmp/mpfr.

* Update Github Actions.

* Update README.

* Fixes for CMake 3.18

* Fix include option.

* Rename libigl_imgui_front to avoid conflicts.

* Fix when disabling unit tests.

* Build imguizmo with C++11.

* Update CMake option comments.

* Rename nonfree -> restricted.

* Update triangle and tetgen versions.

* Fix compilation issue.

* Update continuous.yml

* remove cork

* finding matlab with default

* mosek module compiles; default detected; osx dylib hack

* Reduce build parallelism.

* Fix find GMP/MPFR on Windows + cleanup CGAL changes.

* Update readme.

Co-authored-by: Alec Jacobson <alecjacobson@adobe.com>
Co-authored-by: Alec Jacobson <alecjacobson@gmail.com>
2022-02-09 18:58:40 -08:00

58 lines
1.7 KiB
C++
Executable File

#include <igl/doublearea.h>
#include <igl/internal_angles.h>
#include <igl/is_irregular_vertex.h>
#include <igl/readOBJ.h>
#include <igl/PI.h>
#include <Eigen/Core>
#include <iostream>
int main(int argc, char *argv[])
{
using namespace Eigen;
using namespace std;
MatrixXd V;
MatrixXi F;
igl::readOBJ(TUTORIAL_SHARED_PATH "/horse_quad.obj",V,F);
// Count the number of irregular vertices, the border is ignored
vector<bool> irregular = igl::is_irregular_vertex(V,F);
int vertex_count = V.rows();
int irregular_vertex_count =
std::count(irregular.begin(),irregular.end(),true);
double irregular_ratio = double(irregular_vertex_count)/vertex_count;
printf("Irregular vertices: \n%d/%d (%.2f%%)\n",
irregular_vertex_count,vertex_count, irregular_ratio*100);
// Compute areas, min, max and standard deviation
VectorXd area;
igl::doublearea(V,F,area);
area = area.array() / 2;
double area_avg = area.mean();
double area_min = area.minCoeff() / area_avg;
double area_max = area.maxCoeff() / area_avg;
double area_sigma = sqrt(((area.array()-area_avg)/area_avg).square().mean());
printf("Areas (Min/Max)/Avg_Area Sigma: \n%.2f/%.2f (%.2f)\n",
area_min,area_max,area_sigma);
// Compute per face angles, min, max and standard deviation
MatrixXd angles;
igl::internal_angles(V,F,angles);
angles = 360.0 * (angles/(2*igl::PI)); // Convert to degrees
double angle_avg = angles.mean();
double angle_min = angles.minCoeff();
double angle_max = angles.maxCoeff();
double angle_sigma = sqrt( (angles.array()-angle_avg).square().mean() );
printf("Angles in degrees (Min/Max) Sigma: \n%.2f/%.2f (%.2f)\n",
angle_min,angle_max,angle_sigma);
}