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>
This commit is contained in:
co-authored by
Alec Jacobson
Alec Jacobson
parent
79dc4f6838
commit
b0fd49d598
@@ -23,20 +23,17 @@
|
||||
#include <limits>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tutorial_shared_path.h"
|
||||
|
||||
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
typedef Eigen::SparseMatrix<double> SparseMat;
|
||||
typedef Eigen::Matrix<double, 1, 1> Vector1d;
|
||||
typedef Eigen::Matrix<int, 1, 1> Vector1i;
|
||||
|
||||
|
||||
//Constants used for smoothing
|
||||
const double howMuchToSmoothBy = 1e-1;
|
||||
const int howManySmoothingInterations = 50;
|
||||
|
||||
|
||||
//Read our mesh
|
||||
Eigen::MatrixXd V;
|
||||
Eigen::MatrixXi F;
|
||||
@@ -44,14 +41,14 @@ int main(int argc, char * argv[])
|
||||
(argc>1?argv[1]: TUTORIAL_SHARED_PATH "/cheburashka.off",V,F)) {
|
||||
std::cout << "Failed to load mesh." << std::endl;
|
||||
}
|
||||
|
||||
|
||||
//Compute vector Laplacian and mass matrix
|
||||
Eigen::MatrixXi E, oE;//Compute Laplacian and mass matrix
|
||||
SparseMat vecL, vecM;
|
||||
igl::cr_vector_mass(V, F, E, oE, vecM);
|
||||
igl::cr_vector_laplacian(V, F, E, oE, vecL);
|
||||
const int m = vecL.rows()/2; //The number of edges in the mesh
|
||||
|
||||
|
||||
//Convert the E / oE matrix format to list of edges / EMAP format required
|
||||
// by the functions constructing scalar Crouzeix-Raviart functions
|
||||
Eigen::MatrixXi Elist(m,2), EMAP(3*F.rows(),1);
|
||||
@@ -67,17 +64,17 @@ int main(int argc, char * argv[])
|
||||
SparseMat scalarL, scalarM;
|
||||
igl::crouzeix_raviart_massmatrix(V, F, Elist, EMAP, scalarM);
|
||||
igl::crouzeix_raviart_cotmatrix(V, F, Elist, EMAP, scalarL);
|
||||
|
||||
|
||||
//Compute edge midpoints & edge vectors
|
||||
Eigen::MatrixXd edgeMps, parVec, perpVec;
|
||||
igl::edge_midpoints(V, F, E, oE, edgeMps);
|
||||
igl::edge_vectors(V, F, E, oE, parVec, perpVec);
|
||||
|
||||
|
||||
//Perform the vector heat method
|
||||
const int initialIndex = 14319;
|
||||
const double initialPara=0.95, initialPerp=0.08;
|
||||
const double t = 0.01;
|
||||
|
||||
|
||||
SparseMat Aeq;
|
||||
Eigen::VectorXd Beq;
|
||||
Eigen::VectorXi known = Eigen::Vector2i(initialIndex, initialIndex+m);
|
||||
@@ -87,7 +84,7 @@ int main(int argc, char * argv[])
|
||||
igl::min_quad_with_fixed
|
||||
(SparseMat(vecM+t*vecL), Eigen::VectorXd(-vecM*Y0), known, knownVals,
|
||||
Aeq, Beq, false, Yt);
|
||||
|
||||
|
||||
Eigen::VectorXd u0 = Eigen::VectorXd::Zero(m), ut;
|
||||
u0(initialIndex) = sqrt(initialPara*initialPara + initialPerp*initialPerp);
|
||||
Eigen::VectorXi knownScal = Vector1i(initialIndex);
|
||||
@@ -95,37 +92,37 @@ int main(int argc, char * argv[])
|
||||
igl::min_quad_with_fixed
|
||||
(SparseMat(scalarM+t*scalarL), Eigen::VectorXd(-scalarM*u0), knownScal,
|
||||
knownScalVals, Aeq, Beq, false, ut);
|
||||
|
||||
|
||||
Eigen::VectorXd phi0 = Eigen::VectorXd::Zero(m), phit;
|
||||
phi0(initialIndex) = 1;
|
||||
Eigen::VectorXd knownScalValsPhi = Vector1d(1);
|
||||
igl::min_quad_with_fixed
|
||||
(SparseMat(scalarM+t*scalarL), Eigen::VectorXd(-scalarM*phi0), knownScal,
|
||||
knownScalValsPhi, Aeq, Beq, false, phit);
|
||||
|
||||
|
||||
Eigen::ArrayXd Xtfactor = ut.array() /
|
||||
(phit.array() * (Yt.array().segment(0,m)*Yt.array().segment(0,m)
|
||||
+ Yt.array().segment(m,m)*Yt.array().segment(m,m)).sqrt());
|
||||
Eigen::VectorXd Xt(2*m);
|
||||
Xt.segment(0,m) = Xtfactor * Yt.segment(0,m).array();
|
||||
Xt.segment(m,m) = Xtfactor * Yt.segment(m,m).array();
|
||||
|
||||
|
||||
|
||||
|
||||
//Compute scalar heat colors
|
||||
igl::HeatGeodesicsData<double> hgData;
|
||||
igl::heat_geodesics_precompute(V, F, hgData);
|
||||
Eigen::VectorXd heatColor;
|
||||
Eigen::VectorXi gamma = Elist.row(initialIndex);
|
||||
igl::heat_geodesics_solve(hgData, gamma, heatColor);
|
||||
|
||||
|
||||
|
||||
|
||||
//Convert vector field for plotting
|
||||
Eigen::MatrixXd vecs(m, 3);
|
||||
for(int i=0; i<edgeMps.rows(); ++i) {
|
||||
vecs.row(i) = Xt(i)*parVec.row(i) + Xt(i+edgeMps.rows())*perpVec.row(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Viewer that shows parallel transported vector
|
||||
igl::opengl::glfw::Viewer viewer;
|
||||
viewer.data().set_mesh(V,F);
|
||||
@@ -139,12 +136,12 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
vecColors.row(initialIndex) << 0.9, 0.1, 0.1;
|
||||
viewer.data().add_edges(edgeMps, edgeMps + s*vecs, vecColors);
|
||||
|
||||
|
||||
std::cout << R"(The red vector is parallel transported to every point on the surface.
|
||||
The surface is shaded by geodesic distance from the red vector.
|
||||
)"
|
||||
<< std::endl;
|
||||
viewer.launch();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user