-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (34 loc) · 935 Bytes
/
main.cpp
File metadata and controls
38 lines (34 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <igl/barycenter.h>
#include <igl/colon.h>
#include <igl/jet.h>
#include <igl/readOFF.h>
#include <igl/slice_into.h>
#include <igl/sortrows.h>
#include <igl/opengl/glfw/Viewer.h>
#include <iostream>
int main(int argc, char *argv[])
{
using namespace Eigen;
using namespace std;
MatrixXd V;
MatrixXi F;
igl::readOFF(TUTORIAL_SHARED_PATH "/decimated-knight.off",V,F);
// Sort barycenters lexicographically
MatrixXd BC,sorted_BC;
igl::barycenter(V,F,BC);
VectorXi I,J;
// sorted_BC = BC(I,:)
igl::sortrows(BC,true,sorted_BC,I);
// Get sorted "place" from sorted indices
J.resize(I.rows());
// J(I) = 1:numel(I)
igl::slice_into(igl::colon<int>(0,I.size()-1),I,J);
// Pseudo-color based on sorted place
MatrixXd C;
igl::jet(J,true,C);
// Plot the mesh with pseudocolors
igl::opengl::glfw::Viewer viewer;
viewer.data().set_mesh(V, F);
viewer.data().set_colors(C);
viewer.launch();
}