https://github.com/HTDerekLiu/surface_multigrid_code
Raw File
Tip revision: a827578755d864df68b103c71048c7da7a00ce59 authored by HTDerekLiu on 09 August 2021, 18:36:04 UTC
add a faster example
Tip revision: a827578
main.cpp
#include <igl/read_triangle_mesh.h>

#include <igl/opengl/glfw/Viewer.h>

#include <Eigen/Dense>
#include <Eigen/Core>
#include <Eigen/Sparse>

#include <iostream>
#include <vector>

#include <single_collapse_data.h>
#include <query_fine_to_coarse.h>
#include <get_prolong.h>

int main(int argc, char *argv[])
{
	using namespace Eigen;
	using namespace std;

	// load mesh
	MatrixXd VO,V;
	MatrixXi FO,F;
	{
		igl::read_triangle_mesh("../../meshes/bunny.obj", VO, FO);
		cout << "original mesh: |V| " << VO.rows() << ", |F|: " << FO.rows() << endl;
	}

	// decimate the input mesh and obtain the prolongation operator via SSP
	SparseMatrix<double> P;
	int tarF = 1000; // target number of faces
	int dec_type = 0; // decimation type (0:qslim, 1:midpoint, 2:vertex removal)
	get_prolong(VO,FO,tarF,dec_type,V,F,P);

	MatrixXd pt = P * V;

	// visualize the prolongation operator
	igl::opengl::glfw::Viewer viewer;
	{
		viewer.data().set_mesh(V, F);
			viewer.data().add_points(pt, Eigen::RowVector3d(0, 0, 0));
		viewer.data().point_size = 10;
		viewer.launch();
	}
	
}
back to top