本文整理汇总了C++中eigen::MatrixXi::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixXi::rows方法的具体用法?C++ MatrixXi::rows怎么用?C++ MatrixXi::rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::MatrixXi
的用法示例。
在下文中一共展示了MatrixXi::rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NumExactMatches
int NumExactMatches(const Eigen::MatrixXi& M, const Eigen::MatrixXi& m, int& best_score, int& best_r, int& best_c)
{
const int border = std::min((int)std::min(m.rows(),m.cols())-2, 2);
best_score = std::numeric_limits<int>::max();
const Eigen::Vector2i rcmax( 2*border + M.rows() - m.rows(), 2*border + M.cols() - m.cols());
int num_zeros = 0;
for(int r=-border; r < rcmax(0); ++r ) {
for(int c=-border; c < rcmax(1); ++c) {
const int hd = HammingDistance(M, m, r,c );
if(hd < best_score) {
best_score = hd;
best_r = r;
best_c = c;
}
if(hd==0) {
++num_zeros;
}
}
}
return num_zeros;
}
示例2: tree
TEST(CSGTree, extrusion) {
Eigen::MatrixXd V;
Eigen::MatrixXi F;
test_common::load_mesh("extrusion.obj", V, F);
igl::copyleft::cgal::CSGTree tree(V, F);
igl::copyleft::cgal::CSGTree inter(tree, tree, "i"); // returns error
Eigen::MatrixXd V2 = inter.cast_V<Eigen::MatrixXd>();
Eigen::MatrixXi F2 = inter.F();
ASSERT_EQ(V.rows(), V2.rows());
ASSERT_EQ(F.rows(), F2.rows());
}
示例3: project
void PointProjector::project(Eigen::MatrixXi &indexImage,
Eigen::MatrixXf &depthImage,
const HomogeneousPoint3fVector &points) const {
depthImage.resize(indexImage.rows(), indexImage.cols());
depthImage.fill(std::numeric_limits<float>::max());
indexImage.fill(-1);
const HomogeneousPoint3f* point = &points[0];
for (size_t i=0; i<points.size(); i++, point++){
int x, y;
float d;
if (!project(x, y, d, *point) ||
x<0 || x>=indexImage.rows() ||
y<0 || y>=indexImage.cols() )
continue;
float& otherDistance=depthImage(x,y);
int& otherIndex=indexImage(x,y);
if (otherDistance>d) {
otherDistance = d;
otherIndex = i;
}
}
}
示例4: assert
IGL_INLINE void igl::ViewerData::set_edges(
const Eigen::MatrixXd& P,
const Eigen::MatrixXi& E,
const Eigen::MatrixXd& C)
{
using namespace Eigen;
lines.resize(E.rows(),9);
assert(C.cols() == 3);
for(int e = 0;e<E.rows();e++)
{
RowVector3d color;
if(C.size() == 3)
{
color<<C;
}else if(C.rows() == E.rows())
{
color<<C.row(e);
}
lines.row(e)<< P.row(E(e,0)), P.row(E(e,1)), color;
}
dirty |= DIRTY_OVERLAY_LINES;
}
示例5: optimize_index_buffer
void optimize_index_buffer(
const Eigen::MatrixXi& F,
const bool silent,
Eigen::MatrixXi& OF)
{
const int numTris = F.rows();
std::vector<int> triBuf;
for (int t=0; t<numTris; t++)
{
triBuf.push_back(F(t,0));
triBuf.push_back(F(t,1));
triBuf.push_back(F(t,2));
}
VertexCache vertex_cache;
int misses = vertex_cache.GetCacheMissCount(&triBuf[0], numTris);
if (!silent)
{
printf("*** Before optimization ***\n");
printf("Cache misses\t: %d\n", misses);
printf("ACMR\t\t: %f\n", (float)misses / (float)numTris);
}
VertexCacheOptimizer vco;
if(!silent)
{
printf("Optimizing ... \n");
}
// vco.draw_list is the new order
VertexCacheOptimizer::Result res = vco.Optimize(&triBuf[0], numTris);
if (res)
{
printf("Error in vertex cache optimization...\n");
}
misses = vertex_cache.GetCacheMissCount(&triBuf[0], numTris);
if (!silent)
{
printf("*** After optimization ***\n");
printf("Cache misses\t: %d\n", misses);
printf("ACMR\t\t: %f\n", (float)misses / (float)numTris);
}
for (int t=0; t<numTris; t++)
{
OF(t,0) = triBuf[3*t];
OF(t,1) = triBuf[3*t + 1];
OF(t,2) = triBuf[3*t + 2];
}
}
示例6: vertices
TEST(copyleft_cgal_peel_outer_hull_layers, TwoCubes) {
Eigen::MatrixXd V;
Eigen::MatrixXi F;
test_common::load_mesh("two-boxes-bad-self-union.ply", V, F);
ASSERT_EQ(486, V.rows());
ASSERT_EQ(708, F.rows());
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::FT Scalar;
typedef Eigen::Matrix<Scalar,
Eigen::Dynamic,
Eigen::Dynamic> MatrixXe;
MatrixXe Vs;
Eigen::MatrixXi Fs, IF;
Eigen::VectorXi J, IM;
igl::copyleft::cgal::RemeshSelfIntersectionsParam param;
igl::copyleft::cgal::remesh_self_intersections(V, F, param, Vs, Fs, IF, J, IM);
std::for_each(Fs.data(),Fs.data()+Fs.size(),
[&IM](int & a){ a=IM(a); });
MatrixXe Vt;
Eigen::MatrixXi Ft;
igl::remove_unreferenced(Vs,Fs,Vt,Ft,IM);
const size_t num_faces = Ft.rows();
Eigen::VectorXi I, flipped;
size_t num_peels = igl::copyleft::cgal::peel_outer_hull_layers(Vt, Ft, I, flipped);
Eigen::MatrixXd vertices(Vt.rows(), Vt.cols());
std::transform(Vt.data(), Vt.data() + Vt.rows() * Vt.cols(),
vertices.data(), [](Scalar v) { return CGAL::to_double(v); });
igl::writeOBJ("debug.obj", vertices, Ft);
ASSERT_EQ(num_faces, I.rows());
ASSERT_EQ(0, I.minCoeff());
ASSERT_EQ(1, I.maxCoeff());
}
示例7: adjacency_matrix
IGL_INLINE void igl::adjacency_matrix(
const Eigen::MatrixXi & F,
Eigen::SparseMatrix<T>& A)
{
using namespace std;
using namespace Eigen;
typedef Triplet<T> IJV;
vector<IJV > ijv;
ijv.reserve(F.size()*2);
// Loop over faces
for(int i = 0;i<F.rows();i++)
{
// Loop over this face
for(int j = 0;j<F.cols();j++)
{
// Get indices of edge: s --> d
int s = F(i,j);
int d = F(i,(j+1)%F.cols());
ijv.push_back(IJV(s,d,1));
ijv.push_back(IJV(d,s,1));
}
}
const int n = F.maxCoeff()+1;
A.resize(n,n);
switch(F.cols())
{
case 3:
A.reserve(6*(F.maxCoeff()+1));
break;
case 4:
A.reserve(26*(F.maxCoeff()+1));
break;
}
A.setFromTriplets(ijv.begin(),ijv.end());
// Force all non-zeros to be one
// Iterate over outside
for(int k=0; k<A.outerSize(); ++k)
{
// Iterate over inside
for(typename Eigen::SparseMatrix<T>::InnerIterator it (A,k); it; ++it)
{
assert(it.value() != 0);
A.coeffRef(it.row(),it.col()) = 1;
}
}
}
示例8: ck
IGL_INLINE void igl::PolyVectorFieldFinder<DerivedV, DerivedF>::getGeneralCoeffConstraints(const Eigen::VectorXi &isConstrained,
const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, Eigen::Dynamic> &cfW,
int k,
Eigen::Matrix<std::complex<typename DerivedV::Scalar>, Eigen::Dynamic,1> &Ck)
{
int numConstrained = isConstrained.sum();
Ck.resize(numConstrained,1);
int n = cfW.cols()/3;
Eigen::MatrixXi allCombs;
{
Eigen::VectorXi V = Eigen::VectorXi::LinSpaced(n,0,n-1);
igl::nchoosek(V,k+1,allCombs);
}
int ind = 0;
for (int fi = 0; fi <numF; ++fi)
{
const Eigen::Matrix<typename DerivedV::Scalar, 1, 3> &b1 = B1.row(fi);
const Eigen::Matrix<typename DerivedV::Scalar, 1, 3> &b2 = B2.row(fi);
if(isConstrained[fi])
{
std::complex<typename DerivedV::Scalar> ck(0);
for (int j = 0; j < allCombs.rows(); ++j)
{
std::complex<typename DerivedV::Scalar> tk(1.);
//collect products
for (int i = 0; i < allCombs.cols(); ++i)
{
int index = allCombs(j,i);
const Eigen::Matrix<typename DerivedV::Scalar, 1, 3> &w = cfW.block(fi,3*index,1,3);
typename DerivedV::Scalar w0 = w.dot(b1);
typename DerivedV::Scalar w1 = w.dot(b2);
std::complex<typename DerivedV::Scalar> u(w0,w1);
tk*= u*u;
}
//collect sum
ck += tk;
}
Ck(ind) = ck;
ind ++;
}
}
}
示例9: n_polyvector
IGL_INLINE void igl::n_polyvector(const Eigen::MatrixXd &V,
const Eigen::MatrixXi &F,
const Eigen::VectorXi& b,
const Eigen::MatrixXd& bc,
Eigen::MatrixXd &output)
{
Eigen::VectorXi isConstrained = Eigen::VectorXi::Constant(F.rows(),0);
Eigen::MatrixXd cfW = Eigen::MatrixXd::Constant(F.rows(),bc.cols(),0);
for(unsigned i=0; i<b.size();++i)
{
isConstrained(b(i)) = 1;
cfW.row(b(i)) << bc.row(i);
}
if (b.size() == F.rows())
{
output = cfW;
return;
}
int n = cfW.cols()/3;
igl::PolyVectorFieldFinder<Eigen::MatrixXd, Eigen::MatrixXi> pvff(V,F,n);
pvff.solve(isConstrained, cfW, output);
}
示例10: triangle_fan
IGL_INLINE void igl::triangle_fan(
const Eigen::MatrixXi & E,
Eigen::MatrixXi & cap)
{
using namespace std;
using namespace Eigen;
// Handle lame base case
if(E.size() == 0)
{
cap.resize(0,E.cols()+1);
return;
}
// "Triangulate" aka "close" the E trivially with facets
// Note: in 2D we need to know if E endpoints are incoming or
// outgoing (left or right). Thus this will not work.
assert(E.cols() == 2);
// Arbitrary starting vertex
//int s = E(int(((double)rand() / RAND_MAX)*E.rows()),0);
int s = E(rand()%E.rows(),0);
vector<vector<int> > lcap;
for(int i = 0;i<E.rows();i++)
{
// Skip edges incident on s (they would be zero-area)
if(E(i,0) == s || E(i,1) == s)
{
continue;
}
vector<int> e(3);
e[0] = s;
e[1] = E(i,0);
e[2] = E(i,1);
lcap.push_back(e);
}
list_to_matrix(lcap,cap);
}
示例11: main
int main(int argc, char * argv[])
{
using namespace Eigen;
using namespace igl;
using namespace std;
// init mesh
string filename = "../shared/decimated-knight.obj";
if(argc < 2)
{
cerr<<"Usage:"<<endl<<" ./example input.obj"<<endl;
cout<<endl<<"Opening default mesh..."<<endl;
}else
{
// Read and prepare mesh
filename = argv[1];
}
if(!read_triangle_mesh(filename,V,F))
{
return 1;
}
// Compute normals, centroid, colors, bounding box diagonal
per_face_normals(V,F,N);
normalize_row_lengths(N,N);
mean = V.colwise().mean();
C.resize(F.rows(),3);
init_C();
bbd =
(V.colwise().maxCoeff() -
V.colwise().minCoeff()).maxCoeff();
// Init embree
ei.init(V.cast<float>(),F.cast<int>());
// Init glut
glutInit(&argc,argv);
glutInitDisplayString( "rgba depth double samples>=8 ");
glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT));
glutCreateWindow("embree");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(key);
glutMouseFunc(mouse);
glutMotionFunc(mouse_drag);
glutPassiveMotionFunc(mouse_move);
glutMainLoop();
return 0;
}
示例12: matrix
int ComputationGraph::matrix(Eigen::MatrixXi matrix) {
std::vector<int> output;
for (int i = 0; i < matrix.rows(); i++) {
for (int j = 0; j < matrix.cols(); j++) {
output.push_back(matrix(i, j));
}
}
nodes.push_back({
-1,
{},
output
});
return nodes.size() - 1;
}
示例13: assert
IGL_INLINE std::vector<int> igl::circulation(
const int e,
const bool ccw,
const Eigen::MatrixXi & F,
const Eigen::MatrixXi & E,
const Eigen::VectorXi & EMAP,
const Eigen::MatrixXi & EF,
const Eigen::MatrixXi & EI)
{
// prepare output
std::vector<int> N;
N.reserve(6);
const int m = F.rows();
const auto & step = [&](
const int e,
const int ff,
int & ne,
int & nf)
{
assert((EF(e,1) == ff || EF(e,0) == ff) && "e should touch ff");
//const int fside = EF(e,1)==ff?1:0;
const int nside = EF(e,0)==ff?1:0;
const int nv = EI(e,nside);
// get next face
nf = EF(e,nside);
// get next edge
const int dir = ccw?-1:1;
ne = EMAP(nf+m*((nv+dir+3)%3));
};
// Always start with first face (ccw in step will be sure to turn right
// direction)
const int f0 = EF(e,0);
int fi = f0;
int ei = e;
while(true)
{
step(ei,fi,ei,fi);
N.push_back(fi);
// back to start?
if(fi == f0)
{
assert(ei == e);
break;
}
}
return N;
}
示例14: drawCuts
void drawCuts(igl::viewer::Viewer& viewer,
const Eigen::MatrixXi &cuts)
{
int maxCutNum = cuts.sum();
Eigen::MatrixXd start(maxCutNum,3);
Eigen::MatrixXd end(maxCutNum,3);
int ind = 0;
for (unsigned int i=0;i<F.rows();i++)
for (int j=0;j<3;j++)
if (cuts(i,j))
{
start.row(ind) = V.row(F(i,j));
end.row(ind) = V.row(F(i,(j+1)%3));
ind++;
}
viewer.data.add_edges(start, end , Eigen::RowVector3d(1.,0,1.));
}
示例15: plot_mesh_nrosy
// Plots the mesh with an N-RoSy field and its singularities on top
// The constrained faces (b) are colored in red.
void plot_mesh_nrosy(
igl::viewer::Viewer& viewer,
Eigen::MatrixXd& V,
Eigen::MatrixXi& F,
int N,
Eigen::MatrixXd& PD1,
Eigen::VectorXd& S,
Eigen::VectorXi& b)
{
using namespace Eigen;
using namespace std;
// Clear the mesh
viewer.data.clear();
viewer.data.set_mesh(V,F);
// Expand the representative vectors in the full vector set and plot them as lines
double avg = igl::avg_edge_length(V, F);
MatrixXd Y;
representative_to_nrosy(V, F, PD1, N, Y);
MatrixXd B;
igl::barycenter(V,F,B);
MatrixXd Be(B.rows()*N,3);
for(unsigned i=0; i<B.rows(); ++i)
for(unsigned j=0; j<N; ++j)
Be.row(i*N+j) = B.row(i);
viewer.data.add_edges(Be,Be+Y*(avg/2),RowVector3d(0,0,1));
// Plot the singularities as colored dots (red for negative, blue for positive)
for (unsigned i=0; i<S.size(); ++i)
{
if (S(i) < -0.001)
viewer.data.add_points(V.row(i),RowVector3d(1,0,0));
else if (S(i) > 0.001)
viewer.data.add_points(V.row(i),RowVector3d(0,1,0));
}
// Highlight in red the constrained faces
MatrixXd C = MatrixXd::Constant(F.rows(),3,1);
for (unsigned i=0; i<b.size(); ++i)
C.row(b(i)) << 1, 0, 0;
viewer.data.set_colors(C);
}