- reorganized PVF tutorials

This commit is contained in:
Daniele Panozzo
2014-06-30 11:59:40 +02:00
parent 5c81bd50ff
commit b14137eaaf
8 changed files with 289 additions and 528 deletions
+14 -15
View File
@@ -21,15 +21,12 @@ double global_scale;
Eigen::VectorXi isConstrained;
std::vector<Eigen::MatrixXd> constraints;
bool key_down(igl::Viewer& viewer, unsigned char key, int modifier)
{
using namespace std;
using namespace Eigen;
if (key <'0' || key >'4')
if (key <'1' || key >'4')
return false;
viewer.clear();
@@ -39,32 +36,35 @@ bool key_down(igl::Viewer& viewer, unsigned char key, int modifier)
int num = key - '0';
if (num == 0)
return false;
// Interpolate
cerr<<"Interpolating for n = "<<num<<"... ";
// Interpolated polyVector field
cerr<<"Interpolating N-PolyVector field for N = "<<num<<"... ";
// Interpolated PolyVector field
Eigen::MatrixXd pvf;
igl::n_polyvector(V, F, isConstrained, constraints[num-1], pvf);
cerr<<"done." <<endl;
// Highlight in red the constrained faces
MatrixXd C = MatrixXd::Constant(F.rows(),3,1);
for (unsigned i=0; i<F.rows();++i)
if (isConstrained[i])
C.row(i) << 1, 0, 0;
C.row(i) << 1, 0, 0;
viewer.set_colors(C);
for (int n =0; n<num; ++n)
for (int n=0; n<num; ++n)
{
// Frame field constraints
MatrixXd F_t = MatrixXd::Zero(F.rows(),3);
for (unsigned i=0; i<F.rows();++i)
if (isConstrained[i])
F_t.row(i) = constraints[num-1].block(i,n*3,1,3);
viewer.add_edges (B, B + global_scale*F_t , Eigen::RowVector3d(0,0,1));
const Eigen::MatrixXd &pvf_t = pvf.block(0,n*3,F.rows(),3);
viewer.add_edges (B - global_scale*F_t, B + global_scale*F_t , Eigen::RowVector3d(0,0,1));
viewer.add_edges (B - global_scale*pvf_t, B + global_scale*pvf_t , Eigen::RowVector3d(0,1,0));
for (unsigned i=0; i<F.rows();++i)
if (isConstrained[i])
F_t.row(i) *= 0;
viewer.add_edges (B, B + global_scale*pvf_t , Eigen::RowVector3d(0,0,1));
}
@@ -103,8 +103,7 @@ int main(int argc, char *argv[])
igl::Viewer viewer;
// Plot the original mesh with a texture parametrization
key_down(viewer,'0',0);
key_down(viewer,'5',0);
// Launch the viewer
viewer.callback_key_down = &key_down;