本文整理汇总了C++中eigen::MatrixXi::cols方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixXi::cols方法的具体用法?C++ MatrixXi::cols怎么用?C++ MatrixXi::cols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::MatrixXi
的用法示例。
在下文中一共展示了MatrixXi::cols方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: key_down
bool key_down(igl::Viewer& viewer, unsigned char key, int modifier)
{
if (key == 'E')
{
extend_arrows = !extend_arrows;
}
if (key <'1' || key >'8')
return false;
viewer.data.clear();
viewer.core.show_lines = false;
viewer.core.show_texture = false;
if (key == '1')
{
// Cross field
viewer.data.set_mesh(V, F);
viewer.data.add_edges(extend_arrows ? B - global_scale*X1 : B, B + global_scale*X1 ,Eigen::RowVector3d(1,0,0));
viewer.data.add_edges(extend_arrows ? B - global_scale*X2 : B, B + global_scale*X2 ,Eigen::RowVector3d(0,0,1));
}
if (key == '2')
{
// Bisector field
viewer.data.set_mesh(V, F);
viewer.data.add_edges(extend_arrows ? B - global_scale*BIS1 : B, B + global_scale*BIS1 ,Eigen::RowVector3d(1,0,0));
viewer.data.add_edges(extend_arrows ? B - global_scale*BIS2 : B, B + global_scale*BIS2 ,Eigen::RowVector3d(0,0,1));
}
if (key == '3')
{
// Bisector field combed
viewer.data.set_mesh(V, F);
viewer.data.add_edges(extend_arrows ? B - global_scale*BIS1_combed : B, B + global_scale*BIS1_combed ,Eigen::RowVector3d(1,0,0));
viewer.data.add_edges(extend_arrows ? B - global_scale*BIS2_combed : B, B + global_scale*BIS2_combed ,Eigen::RowVector3d(0,0,1));
}
if (key == '4')
{
// Singularities and cuts
viewer.data.set_mesh(V, F);
// Plot cuts
int l_count = Seams.sum();
Eigen::MatrixXd P1(l_count,3);
Eigen::MatrixXd P2(l_count,3);
for (unsigned i=0; i<Seams.rows(); ++i)
{
for (unsigned j=0; j<Seams.cols(); ++j)
{
if (Seams(i,j) != 0)
{
P1.row(l_count-1) = V.row(F(i,j));
P2.row(l_count-1) = V.row(F(i,(j+1)%3));
l_count--;
}
}
}
viewer.data.add_edges(P1, P2, Eigen::RowVector3d(1, 0, 0));
// Plot the singularities as colored dots (red for negative, blue for positive)
for (unsigned i=0; i<singularityIndex.size();++i)
{
if (singularityIndex(i) < 2 && singularityIndex(i) > 0)
viewer.data.add_points(V.row(i),Eigen::RowVector3d(1,0,0));
else if (singularityIndex(i) > 2)
viewer.data.add_points(V.row(i),Eigen::RowVector3d(0,1,0));
}
}
if (key == '5')
{
// Singularities and cuts, original field
// Singularities and cuts
viewer.data.set_mesh(V, F);
viewer.data.add_edges(extend_arrows ? B - global_scale*X1_combed : B, B + global_scale*X1_combed ,Eigen::RowVector3d(1,0,0));
viewer.data.add_edges(extend_arrows ? B - global_scale*X2_combed : B, B + global_scale*X2_combed ,Eigen::RowVector3d(0,0,1));
// Plot cuts
int l_count = Seams.sum();
Eigen::MatrixXd P1(l_count,3);
Eigen::MatrixXd P2(l_count,3);
for (unsigned i=0; i<Seams.rows(); ++i)
{
for (unsigned j=0; j<Seams.cols(); ++j)
{
if (Seams(i,j) != 0)
{
P1.row(l_count-1) = V.row(F(i,j));
P2.row(l_count-1) = V.row(F(i,(j+1)%3));
l_count--;
}
}
}
//.........这里部分代码省略.........
示例2: VV
IGL_INLINE bool igl::copyleft::boolean::mesh_boolean(
const Eigen::PlainObjectBase<DerivedVA> & VA,
const Eigen::PlainObjectBase<DerivedFA> & FA,
const Eigen::PlainObjectBase<DerivedVB> & VB,
const Eigen::PlainObjectBase<DerivedFB> & FB,
const WindingNumberOp& wind_num_op,
const KeepFunc& keep,
const ResolveFunc& resolve_fun,
Eigen::PlainObjectBase<DerivedVC > & VC,
Eigen::PlainObjectBase<DerivedFC > & FC,
Eigen::PlainObjectBase<DerivedJ > & J)
{
#ifdef MESH_BOOLEAN_TIMING
const auto & tictoc = []() -> double
{
static double t_start = igl::get_seconds();
double diff = igl::get_seconds()-t_start;
t_start += diff;
return diff;
};
const auto log_time = [&](const std::string& label) -> void {
std::cout << "mesh_boolean." << label << ": "
<< tictoc() << std::endl;
};
tictoc();
#endif
typedef typename DerivedVC::Scalar Scalar;
//typedef typename DerivedFC::Scalar Index;
typedef CGAL::Epeck Kernel;
typedef Kernel::FT ExactScalar;
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,3> MatrixX3S;
//typedef Eigen::Matrix<Index,Eigen::Dynamic,Eigen::Dynamic> MatrixXI;
typedef Eigen::Matrix<typename DerivedJ::Scalar,Eigen::Dynamic,1> VectorXJ;
// Generate combined mesh.
typedef Eigen::Matrix<
ExactScalar,
Eigen::Dynamic,
Eigen::Dynamic,
DerivedVC::IsRowMajor> MatrixXES;
MatrixXES V;
DerivedFC F;
VectorXJ CJ;
{
DerivedVA VV(VA.rows() + VB.rows(), 3);
DerivedFC FF(FA.rows() + FB.rows(), 3);
VV << VA, VB;
FF << FA, FB.array() + VA.rows();
//// Handle annoying empty cases
//if(VA.size()>0)
//{
// VV<<VA;
//}
//if(VB.size()>0)
//{
// VV<<VB;
//}
//if(FA.size()>0)
//{
// FF<<FA;
//}
//if(FB.size()>0)
//{
// FF<<FB.array()+VA.rows();
//}
resolve_fun(VV, FF, V, F, CJ);
}
#ifdef MESH_BOOLEAN_TIMING
log_time("resolve_self_intersection");
#endif
// Compute winding numbers on each side of each facet.
const size_t num_faces = F.rows();
Eigen::MatrixXi W;
Eigen::VectorXi labels(num_faces);
std::transform(CJ.data(), CJ.data()+CJ.size(), labels.data(),
[&](int i) { return i<FA.rows() ? 0:1; });
bool valid = true;
if (num_faces > 0)
{
valid = valid &
igl::copyleft::cgal::propagate_winding_numbers(V, F, labels, W);
} else
{
W.resize(0, 4);
}
assert((size_t)W.rows() == num_faces);
if (W.cols() == 2)
{
assert(FB.rows() == 0);
Eigen::MatrixXi W_tmp(num_faces, 4);
W_tmp << W, Eigen::MatrixXi::Zero(num_faces, 2);
W = W_tmp;
} else {
assert(W.cols() == 4);
}
#ifdef MESH_BOOLEAN_TIMING
log_time("propagate_input_winding_number");
//.........这里部分代码省略.........
示例3: VV
IGL_INLINE void igl::copyleft::boolean::mesh_boolean(
const Eigen::PlainObjectBase<DerivedVA> & VA,
const Eigen::PlainObjectBase<DerivedFA> & FA,
const Eigen::PlainObjectBase<DerivedVB> & VB,
const Eigen::PlainObjectBase<DerivedFB> & FB,
const WindingNumberOp& wind_num_op,
const KeepFunc& keep,
const ResolveFunc& resolve_fun,
Eigen::PlainObjectBase<DerivedVC > & VC,
Eigen::PlainObjectBase<DerivedFC > & FC,
Eigen::PlainObjectBase<DerivedJ > & J) {
typedef typename DerivedVC::Scalar Scalar;
//typedef typename DerivedFC::Scalar Index;
typedef CGAL::Epeck Kernel;
typedef Kernel::FT ExactScalar;
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,3> MatrixX3S;
//typedef Eigen::Matrix<Index,Eigen::Dynamic,Eigen::Dynamic> MatrixXI;
typedef Eigen::Matrix<typename DerivedJ::Scalar,Eigen::Dynamic,1> VectorXJ;
// Generate combined mesh.
typedef Eigen::Matrix<
ExactScalar,
Eigen::Dynamic,
Eigen::Dynamic,
DerivedVC::IsRowMajor> MatrixXES;
MatrixXES V;
DerivedFC F;
VectorXJ CJ;
{
DerivedVA VV(VA.rows() + VB.rows(), 3);
DerivedFC FF(FA.rows() + FB.rows(), 3);
VV << VA, VB;
FF << FA, FB.array() + VA.rows();
//// Handle annoying empty cases
//if(VA.size()>0)
//{
// VV<<VA;
//}
//if(VB.size()>0)
//{
// VV<<VB;
//}
//if(FA.size()>0)
//{
// FF<<FA;
//}
//if(FB.size()>0)
//{
// FF<<FB.array()+VA.rows();
//}
resolve_fun(VV, FF, V, F, CJ);
}
// Compute winding numbers on each side of each facet.
const size_t num_faces = F.rows();
Eigen::MatrixXi W;
Eigen::VectorXi labels(num_faces);
std::transform(CJ.data(), CJ.data()+CJ.size(), labels.data(),
[&](int i) { return i<FA.rows() ? 0:1; });
igl::copyleft::cgal::propagate_winding_numbers(V, F, labels, W);
assert((size_t)W.rows() == num_faces);
if (W.cols() == 2) {
assert(FB.rows() == 0);
Eigen::MatrixXi W_tmp(num_faces, 4);
W_tmp << W, Eigen::MatrixXi::Zero(num_faces, 2);
W = W_tmp;
} else {
assert(W.cols() == 4);
}
// Compute resulting winding number.
Eigen::MatrixXi Wr(num_faces, 2);
for (size_t i=0; i<num_faces; i++) {
Eigen::MatrixXi w_out(1,2), w_in(1,2);
w_out << W(i,0), W(i,2);
w_in << W(i,1), W(i,3);
Wr(i,0) = wind_num_op(w_out);
Wr(i,1) = wind_num_op(w_in);
}
// Extract boundary separating inside from outside.
auto index_to_signed_index = [&](size_t i, bool ori) -> int{
return (i+1)*(ori?1:-1);
};
//auto signed_index_to_index = [&](int i) -> size_t {
// return abs(i) - 1;
//};
std::vector<int> selected;
for(size_t i=0; i<num_faces; i++) {
auto should_keep = keep(Wr(i,0), Wr(i,1));
if (should_keep > 0) {
selected.push_back(index_to_signed_index(i, true));
} else if (should_keep < 0) {
selected.push_back(index_to_signed_index(i, false));
}
}
const size_t num_selected = selected.size();
DerivedFC kept_faces(num_selected, 3);
//.........这里部分代码省略.........
示例4: fromIntEigenMatrix_16
void fromIntEigenMatrix_16(const Eigen::MatrixXi& from_mat, int **&to_mat)
{
fromIntEigenMatrix_16(from_mat, to_mat, from_mat.rows(), from_mat.cols());
}
示例5: arap_dof_precomputation
IGL_INLINE bool igl::arap_dof_precomputation(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
const LbsMatrixType & M,
const Eigen::Matrix<int,Eigen::Dynamic,1> & G,
ArapDOFData<LbsMatrixType, SSCALAR> & data)
{
using namespace Eigen;
typedef Matrix<SSCALAR, Dynamic, Dynamic> MatrixXS;
// number of mesh (domain) vertices
int n = V.rows();
// cache problem size
data.n = n;
// dimension of mesh
data.dim = V.cols();
assert(data.dim == M.rows()/n);
assert(data.dim*n == M.rows());
if(data.dim == 3)
{
// Check if z-coordinate is all zeros
if(V.col(2).minCoeff() == 0 && V.col(2).maxCoeff() == 0)
{
data.effective_dim = 2;
}
}else
{
data.effective_dim = data.dim;
}
// Number of handles
data.m = M.cols()/data.dim/(data.dim+1);
assert(data.m*data.dim*(data.dim+1) == M.cols());
//assert(m == C.rows());
//printf("n=%d; dim=%d; m=%d;\n",n,data.dim,data.m);
// Build cotangent laplacian
SparseMatrix<double> Lcot;
//printf("cotmatrix()\n");
cotmatrix(V,F,Lcot);
// Discrete laplacian (should be minus matlab version)
SparseMatrix<double> Lapl = -2.0*Lcot;
#ifdef EXTREME_VERBOSE
cout<<"LaplIJV=["<<endl;print_ijv(Lapl,1);cout<<endl<<"];"<<
endl<<"Lapl=sparse(LaplIJV(:,1),LaplIJV(:,2),LaplIJV(:,3),"<<
Lapl.rows()<<","<<Lapl.cols()<<");"<<endl;
#endif
// Get group sum scatter matrix, when applied sums all entries of the same
// group according to G
SparseMatrix<double> G_sum;
if(G.size() == 0)
{
speye(n,G_sum);
}else
{
// groups are defined per vertex, convert to per face using mode
Eigen::Matrix<int,Eigen::Dynamic,1> GG;
if(data.energy == ARAP_ENERGY_TYPE_ELEMENTS)
{
MatrixXi GF(F.rows(),F.cols());
for(int j = 0;j<F.cols();j++)
{
Matrix<int,Eigen::Dynamic,1> GFj;
slice(G,F.col(j),GFj);
GF.col(j) = GFj;
}
mode<int>(GF,2,GG);
}else
{
GG=G;
}
//printf("group_sum_matrix()\n");
group_sum_matrix(GG,G_sum);
}
#ifdef EXTREME_VERBOSE
cout<<"G_sumIJV=["<<endl;print_ijv(G_sum,1);cout<<endl<<"];"<<
endl<<"G_sum=sparse(G_sumIJV(:,1),G_sumIJV(:,2),G_sumIJV(:,3),"<<
G_sum.rows()<<","<<G_sum.cols()<<");"<<endl;
#endif
// Get covariance scatter matrix, when applied collects the covariance matrices
// used to fit rotations to during optimization
SparseMatrix<double> CSM;
//printf("covariance_scatter_matrix()\n");
covariance_scatter_matrix(V,F,data.energy,CSM);
#ifdef EXTREME_VERBOSE
cout<<"CSMIJV=["<<endl;print_ijv(CSM,1);cout<<endl<<"];"<<
endl<<"CSM=sparse(CSMIJV(:,1),CSMIJV(:,2),CSMIJV(:,3),"<<
CSM.rows()<<","<<CSM.cols()<<");"<<endl;
#endif
// Build the covariance matrix "constructor". This is a set of *scatter*
// matrices that when multiplied on the right by column of the transformation
// matrix entries (the degrees of freedom) L, we get a stack of dim by 1
// covariance matrix column, with a column in the stack for each rotation
// *group*. The output is a list of matrices because we construct each column
// in the stack of covariance matrices with an independent matrix-vector
// multiplication.
//.........这里部分代码省略.........