#include "boundary_conditions.h" #include "verbose.h" #include "EPS.h" #include "project_to_line.h" #include #include IGL_INLINE bool igl::boundary_conditions( const Eigen::MatrixXd & V , const Eigen::MatrixXi & /*Ele*/, const Eigen::MatrixXd & C , const Eigen::VectorXi & P , const Eigen::MatrixXi & BE , const Eigen::MatrixXi & CE , Eigen::VectorXi & b , Eigen::MatrixXd & bc ) { using namespace Eigen; using namespace igl; using namespace std; if(P.size()+BE.rows() == 0) { verbose("^%s: Error: no handles found\n",__FUNCTION__); return false; } vector bci; vector bcj; vector bcv; // loop over points for(int p = 0;p=-FLOAT_EPS && t<=(1.0f+FLOAT_EPS) && sqrd<=FLOAT_EPS) { bci.push_back(i); bcj.push_back(P.size()+e); bcv.push_back(1.0); } } } // Cage edges are not considered yet // loop over cage edges for(int e = 0;e=-FLOAT_EPS && t<=(1.0f+FLOAT_EPS) && sqrd<=FLOAT_EPS) { bci.push_back(i); bcj.push_back(CE(e,0)); bcv.push_back(1.0-t); bci.push_back(i); bcj.push_back(CE(e,1)); bcv.push_back(t); } } } // find unique boundary indices vector vb = bci; sort(vb.begin(),vb.end()); vb.erase(unique(vb.begin(), vb.end()), vb.end()); b.resize(vb.size()); bc = MatrixXd::Zero(vb.size(),P.size()+BE.rows()); // Map from boundary index to index in boundary map bim; int i = 0; // Also fill in b for(vector::iterator bit = vb.begin();bit != vb.end();bit++) { b(i) = *bit; bim[*bit] = i; i++; } // Build BC for(i = 0;i < (int)bci.size();i++) { assert(bim.find(bci[i]) != bim.end()); bc(bim[bci[i]],bcj[i]) = bcv[i]; } // Normalize accross rows so that conditions sum to one for(i = 0;i FLOAT_EPS) { verbose("^%s: Error: handle %d does not receive 0 weight\n",__FUNCTION__,i); return false; } if(max_c< (1-FLOAT_EPS)) { verbose("^%s: Error: handle %d does not receive 1 weight\n",__FUNCTION__,i); return false; } } return true; }