Files
igl/tutorial/301_Slice/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

41 lines
1.0 KiB
C++

#include <igl/floor.h>
#include <igl/readOFF.h>
#include <igl/slice.h>
#include <igl/slice_into.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);
// 100 random indices into rows of F
VectorXi I;
igl::floor((0.5*(VectorXd::Random(100,1).array()+1.)*F.rows()).eval(),I);
// 50 random indices into rows of I
VectorXi J;
igl::floor((0.5*(VectorXd::Random(50,1).array()+1.)*I.rows()).eval(),J);
// K = I(J);
VectorXi K;
igl::slice(I,J,K);
// default green for all faces
MatrixXd C = RowVector3d(0.4,0.8,0.3).replicate(F.rows(),1);
// Red for each in K
MatrixXd R = RowVector3d(1.0,0.3,0.3).replicate(K.rows(),1);
// C(K,:) = R
igl::slice_into(R,K,1,C);
// Plot the mesh with pseudocolors
igl::opengl::glfw::Viewer viewer;
viewer.data().set_mesh(V, F);
viewer.data().set_colors(C);
viewer.launch();
}