diff --git a/include/igl/WindingNumberTree.h b/include/igl/WindingNumberTree.h index 0725bb85b..1c3bc4fb1 100644 --- a/include/igl/WindingNumberTree.h +++ b/include/igl/WindingNumberTree.h @@ -194,7 +194,7 @@ inline void igl::WindingNumberTree::set_mesh( // Remove any exactly duplicate vertices // Q: Can this ever increase the complexity of the boundary? // Q: Would we gain even more by remove almost exactly duplicate vertices? - MatrixXF SF,SVI,SVJ; + Eigen::Matrix SVI,SVJ; igl::remove_duplicate_vertices(_V,_F,0.0,SV,SVI,SVJ,F); triangle_fan(igl::exterior_edges(F),cap); V = SV; diff --git a/include/igl/active_set.cpp b/include/igl/active_set.cpp index 4600c580a..58357662f 100644 --- a/include/igl/active_set.cpp +++ b/include/igl/active_set.cpp @@ -44,6 +44,7 @@ IGL_INLINE igl::SolverStatus igl::active_set( Eigen::PlainObjectBase & Z ) { + //#define ACTIVE_SET_CPP_DEBUG #if defined(ACTIVE_SET_CPP_DEBUG) && !defined(_MSC_VER) # warning "ACTIVE_SET_CPP_DEBUG" @@ -198,7 +199,7 @@ IGL_INLINE igl::SolverStatus igl::active_set( #endif // PREPARE FIXED VALUES - Derivedknown known_i; + Eigen::Matrix known_i; known_i.resize(nk + as_lx_count + as_ux_count,1); DerivedY Y_i; Y_i.resize(nk + as_lx_count + as_ux_count,1); @@ -278,7 +279,7 @@ IGL_INLINE igl::SolverStatus igl::active_set( cout<<" everything's fixed."< Ak; // Slow slice(A,known_i,1,Ak); - DerivedB Bk; - slice(B,known_i,Bk); + //slice(B,known_i,Bk); + DerivedB Bk = B(known_i,Eigen::all); MatrixXd Lambda_known_i = -(0.5*Ak*Z + 0.5*Bk); // reverse the lambda values for lx Lambda_known_i.block(nk,0,as_lx_count,1) = diff --git a/include/igl/arap.cpp b/include/igl/arap.cpp index 03bd0d048..5ab4132b6 100644 --- a/include/igl/arap.cpp +++ b/include/igl/arap.cpp @@ -14,7 +14,6 @@ #include "speye.h" #include "mode.h" #include "project_isometrically_to_plane.h" -#include "slice.h" #include "arap_rhs.h" #include "repdiag.h" #include "columnize.h" @@ -126,9 +125,7 @@ IGL_INLINE bool igl::arap_precomputation( MatrixXi GF(F.rows(),F.cols()); for(int j = 0;j GFj; - slice(data.G,F.col(j),GFj); - GF.col(j) = GFj; + GF.col(j) = data.G(F.col(j)); } mode(GF,2,GG); data.G=GG; diff --git a/include/igl/arap_dof.cpp b/include/igl/arap_dof.cpp index a7e2dcf08..5838f27b9 100644 --- a/include/igl/arap_dof.cpp +++ b/include/igl/arap_dof.cpp @@ -30,10 +30,32 @@ #include "kkt_inverse.h" #include "get_seconds.h" #include "columnize.h" +#include // defined if no early exit is supported, i.e., always take a fixed number of iterations #define IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT +// To avoid putting _any_ dense slices in the static library use a work around +// so that we can slice LbsMatrixType as sparse or dense below. +#if __cplusplus < 201703L +template struct arap_dof_slice_helper; +template struct arap_dof_slice_helper +{ + static void slice(const Mat & A, const Eigen::VectorXi & I, const Eigen::VectorXi & J, Mat & B) + { + static_assert(std::is_base_of, Mat>::value, "Mat must be sparse"); + igl::slice(A,I,J,B); + } +}; +template struct arap_dof_slice_helper +{ + static void slice(const Mat & A, const Eigen::VectorXi & I, const Eigen::VectorXi & J, Mat & B) + { + B = A(I,J); + } +}; +#endif + // A careful derivation of this implementation is given in the corresponding // matlab function arap_dof.m template @@ -99,9 +121,7 @@ IGL_INLINE bool igl::arap_dof_precomputation( MatrixXi GF(F.rows(),F.cols()); for(int j = 0;j GFj; - slice(G,F.col(j),GFj); - GF.col(j) = GFj; + GF.col(j) = G(F.col(j)); } mode(GF,2,GG); }else @@ -183,7 +203,20 @@ IGL_INLINE bool igl::arap_dof_precomputation( //printf("CSM_M(): Mi\n"); LbsMatrixType M_i; //printf("CSM_M(): slice\n"); - slice(M,(span_n.array()+i*n).matrix().eval(),span_mlbs_cols,M_i); +#if __cplusplus >= 201703L + // Check if LbsMatrixType is a sparse matrix + if constexpr (std::is_base_of, LbsMatrixType>::value) + { + slice(M,(span_n.array()+i*n).matrix().eval(),span_mlbs_cols,M_i); + } + else + { + M_i = M((span_n.array()+i*n).eval(),span_mlbs_cols); + } +#else + constexpr bool LbsMatrixTypeIsSparse = std::is_base_of, LbsMatrixType>::value; + arap_dof_slice_helper::slice(M,(span_n.array()+i*n).matrix().eval(),span_mlbs_cols,M_i); +#endif LbsMatrixType M_i_dim; data.CSM_M[i].resize(k*data.dim,data.m*data.dim*(data.dim+1)); assert(data.CSM_M[i].cols() == M.cols()); @@ -668,9 +701,8 @@ IGL_INLINE bool igl::arap_dof_update( MatrixXS R(data.dim,data.dim*k); Eigen::Matrix Rcol(data.dim * data.dim * k); Matrix B_eq_SSCALAR = B_eq.cast(); - Matrix B_eq_fix_SSCALAR; Matrix L0SSCALAR = L0.cast(); - slice(L0SSCALAR, data.fixed_dim, B_eq_fix_SSCALAR); + Matrix B_eq_fix_SSCALAR = L0SSCALAR(data.fixed_dim); //MatrixXS rhsFull(Rcol.rows() + B_eq.rows() + B_eq_fix_SSCALAR.rows(), 1); MatrixXS Lsep(data.m*(data.dim + 1), 3); diff --git a/include/igl/bijective_composite_harmonic_mapping.cpp b/include/igl/bijective_composite_harmonic_mapping.cpp index 272d10e54..8b253d99c 100644 --- a/include/igl/bijective_composite_harmonic_mapping.cpp +++ b/include/igl/bijective_composite_harmonic_mapping.cpp @@ -7,7 +7,6 @@ // obtain one at http://mozilla.org/MPL/2.0/. #include "bijective_composite_harmonic_mapping.h" -#include "slice.h" #include "doublearea.h" #include "harmonic.h" //#include "matlab/MatlabWorkspace.h" @@ -50,8 +49,8 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping( assert(V.cols() == 2 && bc.cols() == 2 && "Input should be 2D"); assert(F.cols() == 3 && "F should contain triangles"); int nsteps = min_steps; - Eigen::Matrix bc0; - slice(V,b.col(0),1,bc0); + Eigen::Matrix bc0 = + V(b.col(0),Eigen::all); // It's difficult to check for flips "robustly" in the sense that the input // mesh might not have positive/consistent sign to begin with. @@ -82,7 +81,7 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping( //mw.save(bct,"bct"); //mw.write("numerical.mat"); harmonic(Eigen::Matrix(U), F, b, bct, 1, U); - igl::slice(U,b.col(0),1,bct); + bct = U(b.col(0),Eigen::all); nans = (U.array() != U.array()).count(); if(test_for_flips) { diff --git a/include/igl/blue_noise.cpp b/include/igl/blue_noise.cpp index 87cd368cc..c2c49caaa 100644 --- a/include/igl/blue_noise.cpp +++ b/include/igl/blue_noise.cpp @@ -8,7 +8,6 @@ #include "blue_noise.h" #include "doublearea.h" #include "random_points_on_mesh.h" -#include "slice.h" #include "sortrows.h" #include "PI.h" #include "get_seconds.h" @@ -290,10 +289,10 @@ IGL_INLINE void igl::blue_noise( { Eigen::VectorXi I; igl::sortrows(decltype(Xs)(Xs),true,Xs,I); - igl::slice(decltype(X)(X),I,1,X); + X = X(I,Eigen::all).eval(); // These two could be spun off in their own thread. - igl::slice(decltype(XB)(XB),I,1,XB); - igl::slice(decltype(XFI)(XFI),I,1,XFI); + XB = XB(I,Eigen::all).eval(); + XFI = XFI(I,Eigen::all).eval(); } // Initialization std::unordered_map > M; diff --git a/include/igl/boundary_facets.cpp b/include/igl/boundary_facets.cpp index ddb00fd25..84b83865a 100644 --- a/include/igl/boundary_facets.cpp +++ b/include/igl/boundary_facets.cpp @@ -12,7 +12,6 @@ #include "sort.h" #include "unique_rows.h" #include "accumarray.h" -#include "slice_mask.h" #include diff --git a/include/igl/boundary_loop.cpp b/include/igl/boundary_loop.cpp index 537a23d1c..3cce1a0f1 100644 --- a/include/igl/boundary_loop.cpp +++ b/include/igl/boundary_loop.cpp @@ -6,7 +6,6 @@ // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "boundary_loop.h" -#include "slice.h" #include "triangle_triangle_adjacency.h" #include "vertex_triangle_adjacency.h" #include "is_border_vertex.h" diff --git a/include/igl/copyleft/cgal/intersect_other.cpp b/include/igl/copyleft/cgal/intersect_other.cpp index 1270dac1c..ea655d8d0 100644 --- a/include/igl/copyleft/cgal/intersect_other.cpp +++ b/include/igl/copyleft/cgal/intersect_other.cpp @@ -9,7 +9,6 @@ #include "CGAL_includes.hpp" #include "mesh_to_cgal_triangle_list.h" #include "remesh_intersections.h" -#include "../../slice_mask.h" #include "../../remove_unreferenced.h" #ifndef IGL_FIRST_HIT_EXCEPTION diff --git a/include/igl/copyleft/cgal/mesh_boolean.cpp b/include/igl/copyleft/cgal/mesh_boolean.cpp index 1da211d54..bead48340 100644 --- a/include/igl/copyleft/cgal/mesh_boolean.cpp +++ b/include/igl/copyleft/cgal/mesh_boolean.cpp @@ -22,7 +22,6 @@ #include "../../parallel_for.h" #include "../../remove_unreferenced.h" #include "../../resolve_duplicated_faces.h" -#include "../../slice.h" #include "../../unique_edge_map.h" #include "../../unique_simplices.h" #include "../../C_STR.h" @@ -370,7 +369,7 @@ IGL_INLINE bool igl::copyleft::cgal::mesh_boolean( DerivedFC G; DerivedJ JJ; igl::resolve_duplicated_faces(kept_faces, G, JJ); - igl::slice(kept_face_indices, JJ, 1, J); + J = kept_face_indices(JJ); #ifdef DOUBLE_CHECK_EXACT_OUTPUT { diff --git a/include/igl/copyleft/cgal/minkowski_sum.cpp b/include/igl/copyleft/cgal/minkowski_sum.cpp index aad6dd2a6..0741e4b7d 100644 --- a/include/igl/copyleft/cgal/minkowski_sum.cpp +++ b/include/igl/copyleft/cgal/minkowski_sum.cpp @@ -8,10 +8,9 @@ #include "minkowski_sum.h" #include "mesh_boolean.h" -#include "../../slice.h" -#include "../../slice_mask.h" #include "../../LinSpaced.h" #include "../../unique_rows.h" +#include "../../find.h" #include "../../get_seconds.h" #include "../../edges.h" #include @@ -142,7 +141,7 @@ IGL_INLINE void igl::copyleft::cgal::minkowski_sum( W, G, SJ); - slice(DerivedJ(J),SJ,1,J); + J = J(SJ).eval(); } } @@ -198,7 +197,7 @@ IGL_INLINE void igl::copyleft::cgal::minkowski_sum( //// Mask whether positive dot product, or negative: because of exactly zero, //// these are not necessarily complementary // Nevermind, actually P = !N - Matrix P(m,1),N(m,1); + Array P(m,1),N(m,1); // loop over faces int mp = 0,mn = 0; for(int f = 0;f MatrixXI; typedef Matrix VectorXI; MatrixXI GT(mp+mn,3); - GT<< slice_mask(FA,N,1), slice_mask((FA.array()+n).eval(),P,1); + GT<< + FA(igl::find(N),Eigen::all), + (FA.array()+n).eval()(igl::find(P),Eigen::all); + // J indexes FA for parts at s and m+FA for parts at d J.derived() = igl::LinSpaced(m,0,m-1); DerivedJ JT(mp+mn); - JT << slice_mask(J,P,1), slice_mask(J,N,1); + JT << + J(igl::find(P),Eigen::all), + J(igl::find(N),Eigen::all); JT.block(mp,0,mn,1).array()+=m; // Original non-co-planar faces with positively oriented reversed MatrixXI BA(mp+mn,3); - BA << slice_mask(FA,P,1).rowwise().reverse(), slice_mask(FA,N,1); + BA << + FA(igl::find(P),Eigen::all).rowwise().reverse(), + FA(igl::find(N),Eigen::all); // Quads along **all** sides MatrixXI GQ((mp+mn)*3,4); GQ<< @@ -289,7 +295,7 @@ IGL_INLINE void igl::copyleft::cgal::minkowski_sum( sF.block(f,1,1,d-1) = sF.block(f,1,1,d-1).reverse().eval(); } } - Matrix M = Matrix::Zero(m,1); + Array M = Array::Zero(m,1); { VectorXI P = igl::LinSpaced(d,0,d-1); for(int p = 0;p(),MatrixXI(), MESH_BOOLEAN_TYPE_UNION, W,G,SJ); - J.derived() = slice(DerivedJ(J),SJ,1); + J = J(SJ).eval(); } } diff --git a/include/igl/copyleft/cgal/point_areas.cpp b/include/igl/copyleft/cgal/point_areas.cpp index 0d55d3a7a..36313f8c0 100644 --- a/include/igl/copyleft/cgal/point_areas.cpp +++ b/include/igl/copyleft/cgal/point_areas.cpp @@ -1,9 +1,7 @@ #include "point_areas.h" #include "delaunay_triangulation.h" -#include "../../colon.h" -#include "../../slice.h" -#include "../../slice_mask.h" +#include "../../find.h" #include "../../parallel_for.h" #include "CGAL/Exact_predicates_inexact_constructions_kernel.h" @@ -69,19 +67,18 @@ namespace igl { T.setZero(n,3); igl::parallel_for(P.rows(),[&](int i) { - MatrixI neighbor_index = I.row(i); MatrixP neighbors; - igl::slice(P,neighbor_index,1,neighbors); + neighbors = P(I.row(i),Eigen::all); if(N.rows() && neighbors.rows() > 1){ MatrixN neighbor_normals; - igl::slice(N,neighbor_index,1,neighbor_normals); + neighbor_normals = N(I.row(i),Eigen::all); Eigen::Matrix poi_normal = neighbor_normals.row(0); Eigen::Matrix dotprod = poi_normal(0)*neighbor_normals.col(0) + poi_normal(1)*neighbor_normals.col(1) + poi_normal(2)*neighbor_normals.col(2); Eigen::Array keep = dotprod.array() > 0; - igl::slice_mask(Eigen::MatrixXd(neighbors),keep,1,neighbors); + neighbors = neighbors(igl::find(keep),Eigen::all).eval(); } if(neighbors.rows() <= 2){ A(i) = 0; @@ -99,9 +96,7 @@ namespace igl { T.row(i) *= -1; } - MatrixP plane; - igl::slice(scores,igl::colon(0,scores.rows()-1), - igl::colon(0,1),plane); + MatrixP plane = scores(Eigen::all,{0,1}); std::vector< std::pair > points; //This is where we obtain a delaunay triangulation of the points diff --git a/include/igl/copyleft/cgal/point_solid_signed_squared_distance.cpp b/include/igl/copyleft/cgal/point_solid_signed_squared_distance.cpp index d975b4580..cb60cb594 100644 --- a/include/igl/copyleft/cgal/point_solid_signed_squared_distance.cpp +++ b/include/igl/copyleft/cgal/point_solid_signed_squared_distance.cpp @@ -9,7 +9,7 @@ #include "points_inside_component.h" #include "point_mesh_squared_distance.h" #include "../../list_to_matrix.h" -#include "../../slice_mask.h" +#include "../../find.h" #include #include @@ -31,8 +31,7 @@ IGL_INLINE void igl::copyleft::cgal::point_solid_signed_squared_distance( // Collect queries that have non-zero distance Eigen::Array NZ = D.array()!=0; // Compute sign for non-zero distance queries - DerivedQ QNZ; - slice_mask(Q,NZ,1,QNZ); + DerivedQ QNZ = Q(igl::find(NZ),Eigen::all); Eigen::Array DNZ; igl::copyleft::cgal::points_inside_component(VB,FB,QNZ,DNZ); // Apply sign to distances diff --git a/include/igl/copyleft/cgal/remove_unreferenced.cpp b/include/igl/copyleft/cgal/remove_unreferenced.cpp index 3780d3449..d45f32aad 100644 --- a/include/igl/copyleft/cgal/remove_unreferenced.cpp +++ b/include/igl/copyleft/cgal/remove_unreferenced.cpp @@ -17,5 +17,4 @@ template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/cgal/slice_mask.cpp b/include/igl/copyleft/cgal/slice_mask.cpp index 28cb64510..f363b7ab2 100644 --- a/include/igl/copyleft/cgal/slice_mask.cpp +++ b/include/igl/copyleft/cgal/slice_mask.cpp @@ -11,5 +11,4 @@ #ifdef IGL_STATIC_LIBRARY #undef IGL_STATIC_LIBRARY #include "../../slice_mask.cpp" -template void igl::slice_mask, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::Array const&, int, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/cgal/trim_with_solid.cpp b/include/igl/copyleft/cgal/trim_with_solid.cpp index 470d08fc6..90cefbf2f 100644 --- a/include/igl/copyleft/cgal/trim_with_solid.cpp +++ b/include/igl/copyleft/cgal/trim_with_solid.cpp @@ -12,8 +12,8 @@ #include "../../extract_manifold_patches.h" #include "../../list_to_matrix.h" +#include "../../find.h" #include "../../remove_unreferenced.h" -#include "../../slice_mask.h" #include @@ -51,10 +51,11 @@ IGL_INLINE void igl::copyleft::cgal::trim_with_solid( Eigen::VectorXi P; const size_t num_patches = igl::extract_manifold_patches(F,P); // only keep faces from A - Eigen::Matrix A = J.array()< FA.rows(); - igl::slice_mask(Eigen::MatrixXi(F),A,1,F); - igl::slice_mask(Eigen::VectorXi(P),A,1,P); - igl::slice_mask(Eigen::VectorXi(J),A,1,J); + Eigen::Array A = J.array()< FA.rows(); + const auto AI = igl::find(A); + F = F(AI,Eigen::all).eval(); + P = P(AI).eval(); + J = J(AI).eval(); // Aggregate representative query points for each patch std::vector flag(num_patches); std::vector > vQ; diff --git a/include/igl/copyleft/cgal/wire_mesh.cpp b/include/igl/copyleft/cgal/wire_mesh.cpp index 3d527da17..393d2c66e 100644 --- a/include/igl/copyleft/cgal/wire_mesh.cpp +++ b/include/igl/copyleft/cgal/wire_mesh.cpp @@ -1,7 +1,6 @@ #include "wire_mesh.h" #include "../../list_to_matrix.h" -#include "../../slice.h" #include "../../PI.h" #include "convex_hull.h" #include "coplanar.h" @@ -116,8 +115,8 @@ IGL_INLINE void igl::copyleft::cgal::wire_mesh( const auto append_hull = [&V,&vF,&vJ](const Eigen::VectorXi & I, const int j) { - MatrixX3S Vv; - igl::slice(V,I,1,Vv); + MatrixX3S Vv = V(I,Eigen::all); + if(coplanar(Vv)) { return; diff --git a/include/igl/copyleft/comiso/miq.cpp b/include/igl/copyleft/comiso/miq.cpp index 5adde4416..6825f8b31 100644 --- a/include/igl/copyleft/comiso/miq.cpp +++ b/include/igl/copyleft/comiso/miq.cpp @@ -877,8 +877,8 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver::buildL // multiply with weights Eigen::VectorXd rhs1 = G2 * u * 0.5 * vfscale; Eigen::VectorXd rhs2 = -G2 * v * 0.5 * vfscale; - igl::slice_into(rhs1, idx, 1, rhs); - igl::slice_into(rhs2, idx2, 1, rhs); + rhs( idx) = rhs1; + rhs(idx2) = rhs2; } ///find different sized of the system diff --git a/include/igl/decimate.cpp b/include/igl/decimate.cpp index 3cc816af0..8597cf481 100644 --- a/include/igl/decimate.cpp +++ b/include/igl/decimate.cpp @@ -11,8 +11,7 @@ #include "decimate_trivial_callbacks.h" #include "is_edge_manifold.h" #include "remove_unreferenced.h" -#include "slice_mask.h" -#include "slice.h" +#include "find.h" #include "connect_boundary_to_infinity.h" #include "parallel_for.h" #include "max_faces_stopping_condition.h" @@ -69,11 +68,11 @@ IGL_INLINE bool igl::decimate( J, I); const Eigen::Array keep = (J.array() @@ -23,11 +21,11 @@ IGL_INLINE void igl::directed_edge_parents( VectorT I = VectorT::Constant(E.maxCoeff()+1,1,-1); //I(E.col(1)) = 0:E.rows()-1 - slice_into(colon(0, E.rows()-1), E.col(1).eval(), I); + I(E.col(1).eval()) = colon(0, E.rows()-1); VectorT roots,_; setdiff(E.col(0).eval(),E.col(1).eval(),roots,_); std::for_each(roots.data(),roots.data()+roots.size(),[&](typename VectorT::Scalar r){I(r)=-1;}); - slice(I,E.col(0).eval(),P); + P = I(E.col(0).eval()); } #ifdef IGL_STATIC_LIBRARY diff --git a/include/igl/ears.cpp b/include/igl/ears.cpp index 7e98fe0c7..3173c2bb0 100644 --- a/include/igl/ears.cpp +++ b/include/igl/ears.cpp @@ -1,7 +1,6 @@ #include "ears.h" #include "on_boundary.h" #include "find.h" -#include "slice.h" #include "min.h" #include @@ -20,9 +19,9 @@ IGL_INLINE void igl::ears( Eigen::Array I; on_boundary(F,I,B); } - find(B.rowwise().count() == 2, ear); - Eigen::Array Bear; - slice(B, ear, 1, Bear); + find((B.rowwise().count() == 2).eval(), ear); + // Why do I need this .derived()? + Eigen::Array Bear = B(ear.derived(),Eigen::all); Eigen::Array M; igl::min(Bear,2,M,ear_opp); } diff --git a/include/igl/edges_to_path.cpp b/include/igl/edges_to_path.cpp index 5c57e88c9..1f38fd730 100644 --- a/include/igl/edges_to_path.cpp +++ b/include/igl/edges_to_path.cpp @@ -1,7 +1,6 @@ #include "edges_to_path.h" #include "dfs.h" #include "sort.h" -#include "slice.h" #include "ismember_rows.h" #include "unique.h" #include "adjacency_list.h" @@ -93,11 +92,11 @@ IGL_INLINE void igl::edges_to_path( } // Map vertex indices onto original graph - slice(U,DerivedI(I),1,I); + I = U(I.derived()).eval(); } #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation -// generated by autoexplicit.sh +template void igl::edges_to_path, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); template void igl::edges_to_path, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/edges_to_path.h b/include/igl/edges_to_path.h index 09ceba6bb..9085bb034 100644 --- a/include/igl/edges_to_path.h +++ b/include/igl/edges_to_path.h @@ -12,7 +12,7 @@ namespace igl /// @param[out] I #E+1 list of nodes in order tracing the chain (loop), if the output /// is a loop then I(1) == I(end) /// @param[out] J #I-1 list of indices into E of edges tracing I - /// @param[out] K #I-1 list of indices into columns of E {1,2} so that K(i) means that + /// @param[out] K #I-1 list of indices into columns of E {0,1} so that K(i) means that /// E(i,K(i)) comes before the other (i.e., E(i,3-K(i)) ). This means that /// I(i) == E(J(i),K(i)) for i<#I, or /// I == E(sub2ind(size(E),J([1:end end]),[K;3-K(end)])))) diff --git a/include/igl/eigs.cpp b/include/igl/eigs.cpp index ee40b5c19..ac3da97ac 100644 --- a/include/igl/eigs.cpp +++ b/include/igl/eigs.cpp @@ -9,7 +9,6 @@ #include "cotmatrix.h" #include "sort.h" -#include "slice.h" #include "massmatrix.h" #include @@ -160,7 +159,7 @@ IGL_INLINE bool igl::eigs( // finally sort VectorXi I; igl::sort(S,1,false,sS,I); - igl::slice(U,I,2,sU); + sU = U(Eigen::all,I); sS /= rescale; sU /= sqrt(rescale); return true; diff --git a/include/igl/find.cpp b/include/igl/find.cpp index 84e6f392c..ebe330599 100644 --- a/include/igl/find.cpp +++ b/include/igl/find.cpp @@ -119,13 +119,28 @@ IGL_INLINE void igl::find( } } +template +IGL_INLINE std::vector igl::find( + const Eigen::Array & M) +{ + std::vector I; + // This reserve seems to be worth it even if it means running over M twice + I.reserve(M.count()); + for(int i = 0;i igl::find(Eigen::Array const&); template void igl::find, Eigen::Matrix, Eigen::Matrix >(Eigen::SparseMatrix const&, Eigen::DenseBase >&, Eigen::DenseBase >&, Eigen::DenseBase >&); -// generated by autoexplicit.sh template void igl::find, Eigen::Matrix, Eigen::Matrix >(Eigen::SparseMatrix const&, Eigen::DenseBase >&, Eigen::DenseBase >&, Eigen::DenseBase >&); - template void igl::find, Eigen::Matrix, Eigen::Array >(Eigen::SparseMatrix const&, Eigen::DenseBase >&, Eigen::DenseBase >&, Eigen::DenseBase >&); template void igl::find, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&); template void igl::find, Eigen::Matrix, Eigen::Matrix >(Eigen::SparseMatrix const&, Eigen::DenseBase >&, Eigen::DenseBase >&, Eigen::DenseBase >&); @@ -134,8 +149,5 @@ template void igl::find, Eigen::Matr template void igl::find, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&); template void igl::find, Eigen::Matrix, Eigen::Matrix >(Eigen::SparseMatrix const&, Eigen::DenseBase >&, Eigen::DenseBase >&, Eigen::DenseBase >&); template void igl::find, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&); -#if EIGEN_VERSION_AT_LEAST(3,3,0) -#else -#endif #endif diff --git a/include/igl/find.h b/include/igl/find.h index 0e0ad760c..d1f1913fa 100644 --- a/include/igl/find.h +++ b/include/igl/find.h @@ -11,6 +11,7 @@ #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET #include #include +#include namespace igl { /// Find the non-zero entries and there respective indices in a sparse matrix. @@ -58,6 +59,23 @@ namespace igl const Eigen::SparseVector& X, Eigen::Matrix & I, Eigen::Matrix & V); + /// \overload + /// \brief This overload facilitates the use of bool masks for Eigen slicing + /// @tparam RowsAtCompileTime number of rows in M at compile time + /// @return indices of true entries in M + /// + /// ##### Example + /// + /// ```cpp + /// igl::slice_mask(A,igl::find(M),igl::find(N),B); + /// // Is the same as + /// B = A(igl::find(M),igl::find(N)); + /// ``` + /// + /// \see slice_mask + template + IGL_INLINE std::vector find( + const Eigen::Array & M); } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/heat_geodesics.cpp b/include/igl/heat_geodesics.cpp index cf4b03173..dde67864a 100644 --- a/include/igl/heat_geodesics.cpp +++ b/include/igl/heat_geodesics.cpp @@ -16,7 +16,6 @@ #include "grad_intrinsic.h" #include "boundary_facets.h" #include "unique.h" -#include "slice.h" #include "avg_edge_length.h" @@ -152,8 +151,7 @@ IGL_INLINE void igl::heat_geodesics_solve( const DerivedD div_X = -data.Div*grad_u; const DerivedD Beq = (DerivedD(1,1)<<0).finished(); igl::min_quad_with_fixed_solve(data.Poisson,(-div_X).eval(),DerivedD(),Beq,D); - DerivedD Dgamma; - igl::slice(D,gamma,Dgamma); + DerivedD Dgamma = D(gamma.derived()); D.array() -= Dgamma.mean(); if(D.mean() < 0) { diff --git a/include/igl/is_boundary_edge.cpp b/include/igl/is_boundary_edge.cpp index 679214bbc..a91f5646f 100644 --- a/include/igl/is_boundary_edge.cpp +++ b/include/igl/is_boundary_edge.cpp @@ -41,12 +41,18 @@ void igl::is_boundary_edge( } } // sort directed edges into undirected edges - MatrixXi sorted_EallE,_; - sort(EallE,2,true,sorted_EallE,_); + MatrixXi sorted_EallE; + { + MatrixXi _; + sort(EallE,2,true,sorted_EallE,_); + } // Determine unique undirected edges E and map to directed edges EMAP MatrixXi uE; VectorXi EMAP; - unique_rows(sorted_EallE,uE,_,EMAP); + { + VectorXi _; + unique_rows(sorted_EallE,uE,_,EMAP); + } // Counts of occurrences VectorXi N = VectorXi::Zero(uE.rows()); for(int e = 0;e & E, Eigen::PlainObjectBase & EMAP) { + // B and EMAP need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1 + static_assert( + (DerivedB::RowsAtCompileTime == 1 || DerivedB::ColsAtCompileTime == 1) && + (DerivedEMAP::RowsAtCompileTime == 1 || DerivedEMAP::ColsAtCompileTime == 1), + "B and EMAP need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1"); using namespace Eigen; using namespace std; // Should be triangles @@ -93,10 +104,16 @@ void igl::is_boundary_edge( } } // sort directed edges into undirected edges - MatrixXi sorted_allE,_; - sort(allE,2,true,sorted_allE,_); + MatrixXi sorted_allE; + { + Eigen::MatrixXi _; + sort(allE,2,true,sorted_allE,_); + } // Determine unique undirected edges E and map to directed edges EMAP - unique_rows(sorted_allE,E,_,EMAP); + { + Eigen::VectorXi _; + unique_rows(sorted_allE,E,_,EMAP); + } // Counts of occurrences VectorXi N = VectorXi::Zero(E.rows()); for(int e = 0;e, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +// Explicit template instantiation +// generated by autoexplicit.sh +template void igl::is_boundary_edge, Eigen::Matrix, Eigen::Array, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::is_boundary_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template void igl::is_boundary_edge, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); template void igl::is_boundary_edge, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::is_boundary_edge, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::is_boundary_edge, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/ismember_rows.cpp b/include/igl/ismember_rows.cpp index bbd2cef79..4c838b8fa 100644 --- a/include/igl/ismember_rows.cpp +++ b/include/igl/ismember_rows.cpp @@ -104,8 +104,9 @@ IGL_INLINE void igl::ismember_rows( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh -template void igl::ismember_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::ismember_rows, Eigen::Matrix, Eigen::Array, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::MatrixBase> const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); // generated by autoexplicit.sh +template void igl::ismember_rows, Eigen::Matrix, Eigen::Array, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::ismember_rows, Eigen::Matrix, Eigen::Array, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::ismember_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::ismember_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); diff --git a/include/igl/iterative_closest_point.cpp b/include/igl/iterative_closest_point.cpp index 595d6a04a..c4c9b4b42 100644 --- a/include/igl/iterative_closest_point.cpp +++ b/include/igl/iterative_closest_point.cpp @@ -8,7 +8,6 @@ #include "iterative_closest_point.h" #include "AABB.h" #include "per_face_normals.h" -#include "slice.h" #include "random_points_on_mesh.h" #include "rigid_alignment.h" #include @@ -97,8 +96,7 @@ IGL_INLINE void igl::iterative_closest_point( Ytree.squared_distance(VY,FY,X,sqrD,I,P); } // Use better normals? - MatrixXS N; - slice(NY,I,1,N); + MatrixXS N = NY(I,Eigen::all); //MatrixXS N = (X - P).rowwise().normalized(); // fit rotation,translation Matrix3S Rup; diff --git a/include/igl/linprog.cpp b/include/igl/linprog.cpp index 3f84b64f7..e30ed5316 100644 --- a/include/igl/linprog.cpp +++ b/include/igl/linprog.cpp @@ -6,8 +6,6 @@ // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "linprog.h" -#include "slice.h" -#include "slice_into.h" #include "find.h" #include "colon.h" @@ -78,8 +76,7 @@ IGL_INLINE bool igl::linprog( J.head(j) = B.head(j); J.tail(B.size()-j-1) = B.tail(B.size()-j-1); B(j) = n+m; - MatrixXd AJ; - igl::slice(A,J,2,AJ); + MatrixXd AJ = A(Eigen::all,J); const VectorXd a = b - AJ.rowwise().sum(); { MatrixXd old_A = A; @@ -108,7 +105,7 @@ IGL_INLINE bool igl::linprog( double df = -1; int t = std::numeric_limits::max(); // Lagrange mutipliers fro Ax=b - VectorXd yb = D.transpose() * igl::slice(s,B); + VectorXd yb = D.transpose() * s(B); while(true) { if(MAXIT>0 && it>=MAXIT) @@ -125,8 +122,8 @@ IGL_INLINE bool igl::linprog( break; } // reduced costs - VectorXd sN = igl::slice(s,N); - MatrixXd AN = igl::slice(A,N,2); + VectorXd sN = s(N); + MatrixXd AN = A(Eigen::all,N); VectorXd r = sN - AN.transpose() * yb; int q; // determine new basic variable @@ -149,7 +146,7 @@ IGL_INLINE bool igl::linprog( success = false; } igl::find((r.array()<0).eval(),J); - double Nq = igl::slice(N,J).minCoeff(); + double Nq = N(J).minCoeff(); // again seems like q is assumed to be a scalar though matlab code // could produce a vector for multiple matches (N.array()==Nq).cast().maxCoeff(&q); @@ -167,7 +164,7 @@ IGL_INLINE bool igl::linprog( success = false; break; } - VectorXd xbd = igl::slice(xb,I).array()/igl::slice(d,I).array(); + VectorXd xbd = xb(I).array()/d(I).array(); // new use of r int p; { @@ -178,7 +175,7 @@ IGL_INLINE bool igl::linprog( if(df>=0) { igl::find((xbd.array()==r).eval(),J); - double Bp = igl::slice(B,igl::slice(I,J)).minCoeff(); + double Bp = B(I(J)).minCoeff(); // idiotic way of finding index in B of Bp // code down the line seems to assume p is a scalar though the matlab // code could find a vector of matches) @@ -192,7 +189,7 @@ IGL_INLINE bool igl::linprog( } // row vector RowVectorXd v = D.row(p)/d(p); - yb += v.transpose() * (s(N(q)) - d.transpose()*igl::slice(s,B)); + yb += v.transpose() * (s(N(q)) - d.transpose()*s(B)); d(p)-=1; // update inverse basis matrix D = D - d*v; @@ -212,22 +209,21 @@ IGL_INLINE bool igl::linprog( } } // iterative refinement - xb = (xb+D*(b-igl::slice(A,B,2)*xb)).eval(); + xb = (xb+D*(b-A(Eigen::all,B)*xb)).eval(); // must be due to rounding VectorXi I; igl::find((xb.array()<0).eval(),I); if(I.size()>0) { // so correct - VectorXd Z = VectorXd::Zero(I.size(),1); - igl::slice_into(Z,I,xb); + xb(I) = VectorXd::Zero(I.size(),1); } // B, xb,n,m,res=A(:,B)*xb-b if(phase == 2 || it<0) { break; } - if(xb.transpose()*igl::slice(s,B) > tol) + if(xb.transpose()*s(B) > tol) { it = -it; #ifdef IGL_LINPROG_VERBOSE @@ -242,7 +238,7 @@ IGL_INLINE bool igl::linprog( s.head(n) = c; } x.setZero(std::max(B.maxCoeff()+1,n)); - igl::slice_into(xb,B,x); + x(B) = xb; x = x.head(n).eval(); return success; } diff --git a/include/igl/min_quad_with_fixed.impl.h b/include/igl/min_quad_with_fixed.impl.h index e3026d90e..48da25703 100644 --- a/include/igl/min_quad_with_fixed.impl.h +++ b/include/igl/min_quad_with_fixed.impl.h @@ -440,8 +440,7 @@ IGL_INLINE bool igl::min_quad_with_fixed_solve( } // Build right hand side - MatrixXT BBequlcols; - igl::slice(BBeq,data.unknown_lagrange,1,BBequlcols); + MatrixXT BBequlcols = BBeq(data.unknown_lagrange,Eigen::all); MatrixXT NB; if(kr == 0) { @@ -490,8 +489,7 @@ IGL_INLINE bool igl::min_quad_with_fixed_solve( //data.AeqTQR.colsPermutation().transpose() * (-data.Aeqk * Y + Beq); data.AeqTET * (-data.Aeqk * Y + Beq.replicate(1,Beq.cols()==cols?1:cols)); // Where did this -0.5 come from? Probably the same place as above. - MatrixXT Bu; - slice(B,data.unknown,1,Bu); + MatrixXT Bu = B(data.unknown,Eigen::all); MatrixXT NB; NB = -0.5*(Bu.replicate(1,B.cols()==cols?1:cols) + data.preY * Y); // Trim eff_Beq diff --git a/include/igl/mosek/bbw.cpp b/include/igl/mosek/bbw.cpp index 99d28ab15..9cf5d900b 100644 --- a/include/igl/mosek/bbw.cpp +++ b/include/igl/mosek/bbw.cpp @@ -8,7 +8,6 @@ #include "bbw.h" #include "mosek_quadprog.h" #include "../harmonic.h" -#include "../slice_into.h" #include #include #include @@ -60,8 +59,8 @@ IGL_INLINE bool igl::mosek::bbw( VectorXd bci = bc.col(i); VectorXd Wi; // impose boundary conditions via bounds - slice_into(bci,b,ux); - slice_into(bci,b,lx); + ux(b) = bci; + lx(b) = bci; bool r = mosek_quadprog(Q,c,0,A,lc,uc,lx,ux,mosek_data,Wi); if(!r) { diff --git a/include/igl/normal_derivative.cpp b/include/igl/normal_derivative.cpp index 49a332d05..d020c7900 100644 --- a/include/igl/normal_derivative.cpp +++ b/include/igl/normal_derivative.cpp @@ -8,7 +8,6 @@ #include "LinSpaced.h" #include "normal_derivative.h" #include "cotmatrix_entries.h" -#include "slice.h" #include template < @@ -40,12 +39,8 @@ IGL_INLINE void igl::normal_derivative( return; case 4: { - const MatrixXi DDJ = - slice( - Ele, - (VectorXi(24)<< - 1,0,2,0,3,0,2,1,3,1,0,1,3,2,0,2,1,2,0,3,1,3,2,3).finished(), - 2); + const MatrixXi DDJ = + Ele(Eigen::all,{1,0,2,0,3,0,2,1,3,1,0,1,3,2,0,2,1,2,0,3,1,3,2,3}); MatrixXi DDI(m,24); for(size_t f = 0;f<4;f++) { @@ -58,11 +53,7 @@ IGL_INLINE void igl::normal_derivative( const DiagonalMatrix S = (Matrix(1,-1).template replicate<12,1>()).asDiagonal(); Matrix DDV = - slice( - C, - (VectorXi(24)<< - 2,2,1,1,3,3,0,0,4,4,2,2,5,5,1,1,0,0,3,3,4,4,5,5).finished(), - 2); + C(Eigen::all,{2,2,1,1,3,3,0,0,4,4,2,2,5,5,1,1,0,0,3,3,4,4,5,5}); DDV *= S; IJV.reserve(DDV.size()); @@ -79,8 +70,7 @@ IGL_INLINE void igl::normal_derivative( } case 3: { - const MatrixXi DDJ = - slice(Ele,(VectorXi(12)<<2,0,1,0,0,1,2,1,1,2,0,2).finished(),2); + const MatrixXi DDJ = Ele(Eigen::all,{2,0,1,0,0,1,2,1,1,2,0,2}); MatrixXi DDI(m,12); for(size_t f = 0;f<3;f++) { @@ -92,8 +82,7 @@ IGL_INLINE void igl::normal_derivative( } const DiagonalMatrix S = (Matrix(1,-1).template replicate<6,1>()).asDiagonal(); - Matrix DDV = - slice(C,(VectorXi(12)<<1,1,2,2,2,2,0,0,0,0,1,1).finished(),2); + Matrix DDV = C(Eigen::all,{1,1,2,2,2,2,0,0,0,0,1,1}); DDV *= S; IJV.reserve(DDV.size()); diff --git a/include/igl/per_edge_normals.cpp b/include/igl/per_edge_normals.cpp index 44792d9c4..4163be591 100644 --- a/include/igl/per_edge_normals.cpp +++ b/include/igl/per_edge_normals.cpp @@ -29,6 +29,9 @@ IGL_INLINE void igl::per_edge_normals( Eigen::PlainObjectBase & EMAP) { + static_assert( + (DerivedEMAP::RowsAtCompileTime == 1 || DerivedEMAP::ColsAtCompileTime == 1) , + "EMAP need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1"); using namespace Eigen; using namespace std; assert(F.cols() == 3 && "Faces must be triangles"); @@ -116,27 +119,15 @@ IGL_INLINE void igl::per_edge_normals( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::per_edge_normals, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, igl::PerEdgeNormalsWeightingType, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/predicates/ear_clipping.cpp b/include/igl/predicates/ear_clipping.cpp index 8c73df6c5..575e1190b 100644 --- a/include/igl/predicates/ear_clipping.cpp +++ b/include/igl/predicates/ear_clipping.cpp @@ -9,7 +9,6 @@ #include "ear_clipping.h" #include "predicates.h" #include "segment_segment_intersect.h" -#include "../slice.h" #include "../turning_number.h" template < diff --git a/include/igl/predicates/polygons_to_triangles.cpp b/include/igl/predicates/polygons_to_triangles.cpp index 888d022ba..1db6c2c4e 100644 --- a/include/igl/predicates/polygons_to_triangles.cpp +++ b/include/igl/predicates/polygons_to_triangles.cpp @@ -1,7 +1,6 @@ #include "polygons_to_triangles.h" #include "ear_clipping.h" #include "../sort.h" -#include "../slice.h" #include template < @@ -55,7 +54,7 @@ IGL_INLINE void igl::predicates::polygons_to_triangles( Eigen::Vector3d _1; Eigen::Vector3i I; igl::sort(es.eigenvalues().real().eval(),1,false,_1,I); - igl::slice(Eigen::Matrix3d(C),I,2,C); + C = C(Eigen::all,I).eval(); } S = P*C.leftCols(2); break; diff --git a/include/igl/qslim.cpp b/include/igl/qslim.cpp index 62195437c..4235f05f7 100644 --- a/include/igl/qslim.cpp +++ b/include/igl/qslim.cpp @@ -11,14 +11,13 @@ #include "connect_boundary_to_infinity.h" #include "decimate.h" #include "edge_flaps.h" +#include "find.h" #include "is_edge_manifold.h" #include "max_faces_stopping_condition.h" #include "per_vertex_point_to_plane_quadrics.h" #include "qslim_optimal_collapse_edge_callbacks.h" #include "quadric_binary_plus_operator.h" #include "remove_unreferenced.h" -#include "slice.h" -#include "slice_mask.h" IGL_INLINE bool igl::qslim( const Eigen::MatrixXd & V, @@ -74,11 +73,12 @@ IGL_INLINE bool igl::qslim( U, G, J, I); // Remove phony boundary faces and clean up const Eigen::Array keep = (J.array() IGL_INLINE void igl::ramer_douglas_peucker( @@ -65,8 +64,8 @@ IGL_INLINE void igl::ramer_douglas_peucker( } }; simplify(0,n-1); - slice_mask(P,I,1,S); - find(I,J); + igl::find(I,J); + S = P(J.derived(),Eigen::all); } template < @@ -106,13 +105,12 @@ IGL_INLINE void igl::ramer_douglas_peucker( J(J.size()-1) = J(J.size()-2); Eigen::VectorXi s,d; // Find index in original list of "start" vertices - slice(J,B,s); + s = J(B); // Find index in original list of "destination" vertices - slice(J,(B.array()+1).matrix().eval(),d); + d = J(B.array()+1); // Parameter between start and destination is linear in arc-length - VectorXS Ts,Td; - slice(T,s,Ts); - slice(T,d,Td); + VectorXS Ts = T(s); + VectorXS Td = T(d); T = ((T.head(T.size()-1)-Ts).array()/(Td-Ts).array()).eval(); for(int t =0;t template < @@ -24,12 +23,16 @@ IGL_INLINE void igl::remove_duplicate_vertices( Eigen::PlainObjectBase& SVI, Eigen::PlainObjectBase& SVJ) { + static_assert( + (DerivedSVI::RowsAtCompileTime == 1 || DerivedSVI::ColsAtCompileTime == 1) && + (DerivedSVJ::RowsAtCompileTime == 1 || DerivedSVJ::ColsAtCompileTime == 1), + "SVI and SVJ need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1"); if(epsilon > 0) { DerivedV rV,rSV; round((V/(epsilon)).eval(),rV); unique_rows(rV,rSV,SVI,SVJ); - slice(V,SVI,colon(0,V.cols()-1),SV); + SV = V(SVI.derived(),Eigen::all); }else { unique_rows(V,SV,SVI,SVJ); @@ -52,6 +55,11 @@ IGL_INLINE void igl::remove_duplicate_vertices( Eigen::PlainObjectBase& SVJ, Eigen::PlainObjectBase& SF) { + // SVI and SVJ need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1 + static_assert( + (DerivedSVI::RowsAtCompileTime == 1 || DerivedSVI::ColsAtCompileTime == 1) && + (DerivedSVJ::RowsAtCompileTime == 1 || DerivedSVJ::ColsAtCompileTime == 1), + "SVI and SVJ need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1"); using namespace Eigen; using namespace std; remove_duplicate_vertices(V,epsilon,SV,SVI,SVJ); @@ -67,23 +75,17 @@ IGL_INLINE void igl::remove_duplicate_vertices( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::MatrixBase> const&, double, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::MatrixBase> const&, Eigen::MatrixBase> const&, double, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); // generated by autoexplicit.sh -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_duplicate_vertices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, double, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/remove_unreferenced.cpp b/include/igl/remove_unreferenced.cpp index 98ed8fcf5..edf01755b 100644 --- a/include/igl/remove_unreferenced.cpp +++ b/include/igl/remove_unreferenced.cpp @@ -6,7 +6,6 @@ // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "remove_unreferenced.h" -#include "slice.h" #include template < @@ -47,7 +46,7 @@ IGL_INLINE void igl::remove_unreferenced( NF = F; std::for_each(NF.data(),NF.data()+NF.size(), [&I](typename DerivedNF::Scalar & a){a=I(a);}); - slice(V,J,1,NV); + NV = V(J.derived(),Eigen::all); } template < @@ -99,23 +98,11 @@ IGL_INLINE void igl::remove_unreferenced( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation -// generated by autoexplicit.sh template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -// generated by autoexplicit.sh -// generated by autoexplicit.sh template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -//template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix >(unsigned long, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); @@ -123,7 +110,4 @@ template void igl::remove_unreferenced, E template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/resolve_duplicated_faces.cpp b/include/igl/resolve_duplicated_faces.cpp index 8ee9409e6..a3ce9fd7b 100644 --- a/include/igl/resolve_duplicated_faces.cpp +++ b/include/igl/resolve_duplicated_faces.cpp @@ -10,8 +10,8 @@ #include "resolve_duplicated_faces.h" #include "IGL_ASSERT.h" -#include "slice.h" #include "unique_simplices.h" +#include template< typename DerivedF1, @@ -81,7 +81,7 @@ IGL_INLINE void igl::resolve_duplicated_faces( const size_t num_kept = kept_faces.size(); J.resize(num_kept, 1); std::copy(kept_faces.begin(), kept_faces.end(), J.data()); - igl::slice(F1, J, 1, F2); + F2 = F1(J.derived(),Eigen::all); } #ifdef IGL_STATIC_LIBRARY @@ -90,7 +90,6 @@ IGL_INLINE void igl::resolve_duplicated_faces( template void igl::resolve_duplicated_faces, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::resolve_duplicated_faces, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::resolve_duplicated_faces, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::resolve_duplicated_faces, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #ifdef WIN32 template void igl::resolve_duplicated_faces, class Eigen::Matrix, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::MatrixBase> const &, class Eigen::PlainObjectBase> &, class Eigen::PlainObjectBase> &); #endif diff --git a/include/igl/setxor.cpp b/include/igl/setxor.cpp index dde66f207..bbe14ac86 100644 --- a/include/igl/setxor.cpp +++ b/include/igl/setxor.cpp @@ -1,7 +1,6 @@ #include "setxor.h" #include "setdiff.h" #include "setunion.h" -#include "slice.h" template < typename DerivedA, @@ -21,8 +20,8 @@ IGL_INLINE void igl::setxor( setdiff(A,B,AB,IAB); setdiff(B,A,BA,IBA); setunion(AB,BA,C,IA,IB); - slice(IAB,DerivedIA(IA),IA); - slice(IBA,DerivedIB(IB),IB); + IA = IAB(IA.derived()).eval(); + IB = IBA(IB.derived()).eval(); } #ifdef IGL_STATIC_LIBRARY diff --git a/include/igl/slice.cpp b/include/igl/slice.cpp index e8eb42a25..54093ccf8 100644 --- a/include/igl/slice.cpp +++ b/include/igl/slice.cpp @@ -205,88 +205,16 @@ IGL_INLINE void igl::slice( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation -// generated by autoexplicit.sh -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::PlainObjectBase >&); -template Eigen::Matrix igl::slice, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::DenseBase > const&); -template Eigen::Matrix igl::slice, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::DenseBase > const&); -// generated by autoexplicit.sh -template void igl::slice, Eigen::Block, -1, 1, true>, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase, -1, 1, true> > const&, int, Eigen::Matrix&); -// generated by autoexplicit.sh -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::slice, Eigen::Matrix, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -// generated by autoexplicit.sh -template void igl::slice, Eigen::Block, -1, 1, true>, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase, -1, 1, true> > const&, int, Eigen::Matrix&); -// generated by autoexplicit.sh -template void igl::slice const, -1>, Eigen::Block, -1, 1, true>, Eigen::Matrix >(Eigen::VectorBlock const, -1> const&, Eigen::DenseBase, -1, 1, true> > const&, int, Eigen::Matrix&); -// generated by autoexplicit.sh -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::PlainObjectBase >&); -template Eigen::Matrix igl::slice, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, int); -template Eigen::Matrix igl::slice, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &); -template Eigen::Matrix igl::slice, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::DenseBase > const&, int); -template void igl::slice, Eigen::Matrix, Eigen::Array >(Eigen::Array const&, Eigen::DenseBase > const&, int, Eigen::Array&); -template void igl::slice, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix>(Eigen::Matrix const &, Eigen::DenseBase> const &, int, Eigen::Matrix &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::Matrix const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::DenseBase > const&, Eigen::PlainObjectBase >&); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -template void igl::slice, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::Matrix const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Block const, -1, 1, true>>(Eigen::DenseBase> const &, Eigen::DenseBase const, -1, 1, true>> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const &, Eigen::DenseBase> const &, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::Matrix>(Eigen::Matrix const &, Eigen::DenseBase> const &, int, Eigen::Matrix &); -template void igl::slice, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::Matrix const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::Matrix const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice >, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); -template void igl::slice >, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); -template void igl::slice>, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::PlainObjectBase> const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice>, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::PlainObjectBase> const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice>, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::PlainObjectBase> const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice>, Eigen::Matrix, Eigen::PlainObjectBase>>(Eigen::PlainObjectBase> const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); template void igl::slice, Eigen::Matrix, Eigen::SparseMatrix>(Eigen::SparseMatrix const &, Eigen::DenseBase> const &, int, Eigen::SparseMatrix &); template void igl::slice, Eigen::Array, Eigen::SparseMatrix >(Eigen::SparseMatrix const&, Eigen::DenseBase > const&, int, Eigen::SparseMatrix&); template void igl::slice, Eigen::Matrix, Eigen::SparseMatrix>(Eigen::SparseMatrix const &, Eigen::DenseBase> const &, int, Eigen::SparseMatrix &); template void igl::slice, Eigen::Matrix, Eigen::SparseMatrix>(Eigen::SparseMatrix const &, Eigen::DenseBase> const &, int, Eigen::SparseMatrix &); template void igl::slice, Eigen::Matrix, Eigen::SparseMatrix>(Eigen::SparseMatrix const &, Eigen::DenseBase> const &, int, Eigen::SparseMatrix &); - #ifdef WIN32 -template void igl::slice >,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::PlainObjectBase > >(class Eigen::DenseBase > const &,class Eigen::DenseBase > const &,int,class Eigen::PlainObjectBase > &); -template void igl::slice >,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::PlainObjectBase > >(class Eigen::MatrixBase > const &,class Eigen::DenseBase > const &,int,class Eigen::PlainObjectBase > &); -template void igl::slice, Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, Eigen::PlainObjectBase>>(Eigen::Matrix<__int64, -1, 1, 0, -1, 1> const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); -template void igl::slice>, Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, Eigen::PlainObjectBase>>(Eigen::PlainObjectBase> const &, Eigen::DenseBase> const &, int, Eigen::PlainObjectBase> &); template void igl::slice(class std::vector > const &,class std::vector > const &,class std::vector > &); template void igl::slice(class std::vector > const &,class std::vector > const &,class std::vector > &); template void igl::slice<__int64>(class std::vector<__int64,class std::allocator<__int64> > const &,class std::vector > const &,class std::vector<__int64,class std::allocator<__int64> > &); #endif - template void igl::slice(std::vector > const&, std::vector > const&, std::vector >&); template void igl::slice(std::vector > const&, std::vector > const&, std::vector >&); template void igl::slice(std::vector > const&, std::vector > const&, std::vector >&); @@ -295,5 +223,4 @@ template void igl::slice(std::vector > const&, #include "SortableRow.h" template void igl::slice > >(std::vector >, std::allocator > > > const&, std::vector > const&, std::vector >, std::allocator > > >&); template void igl::slice > >(std::vector >, std::allocator > > > const&, std::vector > const&, std::vector >, std::allocator > > >&); - #endif diff --git a/include/igl/slice.h b/include/igl/slice.h index 99a27c460..e17701c61 100644 --- a/include/igl/slice.h +++ b/include/igl/slice.h @@ -9,6 +9,28 @@ #define IGL_SLICE_H #include "igl_inline.h" +/// @file slice.h +/// +/// \deprecated The following dense versions are deprecated in favor of using +/// [Eigen v3.4's native +/// slicing](https://eigen.tuxfamily.org/dox-devel/group__TutorialSlicingIndexing.html) +/// which is more efficient, more flexible, and has better syntax. +/// +/// | igl | Eigen v3.4 | +/// |-------------------0--------|------------------------------------| | +/// `igl::slice(X,I,J,Y)` | `Y = X(I,J)` | | +/// `igl::slice(X,I,1,Y)` | `Y = X(I,Eigen::all)` | | +/// `igl::slice(X,J,2,Y)` | `Y = X(Eigen::all,J)` | | +/// `igl::slice_into(Z,I,J,X)` | `X(I,J) = Z` | | +/// `igl::slice_into(Z,I,1,X)` | `X(I,Eigen::all) = Z` | | +/// `igl::slice_into(Z,J,2,X)` | `X(Eigen::all,J) = Z` | | +/// `igl::slice_mask(X,M,N,Y)` | `Y = X(igl::find(M),igl::find(N))` | | _not +/// available_ | `X(igl::find(M),igl::find(N)) = Z` | +/// +/// Eigen's slicing supports much more than arrays of indices as input, as well. +/// +/// Unfortunately, Eigen v3.4 does not support slicing on sparse matrices. + #include #include namespace igl @@ -16,12 +38,10 @@ namespace igl /// Act like the matlab X(row_indices,col_indices) operator, where /// row_indices, col_indices are non-negative integer indices. /// - /// Inputs: - /// X m by n matrix - /// R list of row indices - /// C list of column indices - /// Output: - /// Y #R by #C matrix + /// @param[in] X m by n matrix + /// @param[in] R list of row indices + /// @param[in] C list of column indices + /// @param[out] Y #R by #C matrix /// /// \see slice_mask, slice_into /// @@ -37,17 +57,6 @@ namespace igl const Eigen::DenseBase & C, Eigen::SparseMatrix& Y); /// \overload - template < - typename DerivedX, - typename DerivedR, - typename DerivedC, - typename DerivedY> - IGL_INLINE void slice( - const Eigen::DenseBase & X, - const Eigen::DenseBase & R, - const Eigen::DenseBase & C, - Eigen::PlainObjectBase & Y); - /// \overload /// \brief Wrapper to only slice in one direction /// /// @param[in] dim dimension to slice in 1 or 2, dim=1 --> X(R,:), dim=2 --> X(:,R) @@ -63,13 +72,35 @@ namespace igl const int dim, MatY& Y); /// \overload + template< class T > + IGL_INLINE void slice( + const std::vector & X, + std::vector const & R, + std::vector & Y); + /// \overload /// \brief Vector version + /// \bug these templates are out of order template IGL_INLINE void slice( const Eigen::DenseBase & X, const Eigen::DenseBase & R, Eigen::PlainObjectBase & Y); /// \overload + /// + /// \deprecated + /// + /// See slice.h for more details + template < + typename DerivedX, + typename DerivedR, + typename DerivedC, + typename DerivedY> + IGL_INLINE void slice( + const Eigen::DenseBase & X, + const Eigen::DenseBase & R, + const Eigen::DenseBase & C, + Eigen::PlainObjectBase & Y); + /// \overload /// \brief VectorXi Y = slice(X,R); /// This templating is bad because the return type might not have the same /// size as `DerivedX`. This will probably only work if DerivedX has Dynamic @@ -85,13 +116,6 @@ namespace igl const Eigen::DenseBase& X, const Eigen::DenseBase & R, const int dim); - /// \overload - template< class T > - IGL_INLINE void slice( - const std::vector & X, - std::vector const & R, - std::vector & Y); - } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/slice_into.h b/include/igl/slice_into.h index 2c7dedbae..baafc6bcc 100644 --- a/include/igl/slice_into.h +++ b/include/igl/slice_into.h @@ -21,6 +21,9 @@ namespace igl /// @param[in] C list of column indices /// @param[in] Y ym by yn lhs matrix /// @param[out] Y ym by yn lhs matrix, same as input but Y(R,C) = X + /// + /// + /// \see slice template IGL_INLINE void slice_into( const Eigen::SparseMatrix& X, @@ -28,13 +31,6 @@ namespace igl const Eigen::MatrixBase & C, Eigen::SparseMatrix& Y); /// \overload - template - IGL_INLINE void slice_into( - const Eigen::MatrixBase & X, - const Eigen::MatrixBase & R, - const Eigen::MatrixBase & C, - Eigen::PlainObjectBase & Y); - /// \overload /// \brief Wrapper to only slice in one direction /// /// @param[int] dim dimension to slice in 1 or 2, dim=1 --> X(R,:), dim=2 --> X(:,R) @@ -47,6 +43,17 @@ namespace igl const int dim, MatY& Y); /// \overload + /// + /// \deprecated + /// + /// See slice.h for more details + template + IGL_INLINE void slice_into( + const Eigen::MatrixBase & X, + const Eigen::MatrixBase & R, + const Eigen::MatrixBase & C, + Eigen::PlainObjectBase & Y); + /// \overload /// \brief Vector version template IGL_INLINE void slice_into( diff --git a/include/igl/slice_mask.h b/include/igl/slice_mask.h index 4be2ea067..f87cb3dac 100644 --- a/include/igl/slice_mask.h +++ b/include/igl/slice_mask.h @@ -21,18 +21,35 @@ namespace igl /// @param[in] C n list of column bools /// @param[out] Y #trues-in-R by #trues-in-C matrix /// - /// \see slice_mask + /// \see slice + template + IGL_INLINE void slice_mask( + const Eigen::SparseMatrix & X, + const Eigen::Array & R, + const Eigen::Array & C, + Eigen::SparseMatrix & Y); + /// \overload + /// + /// \brief Wrapper to only slice in one direction + /// + /// @param[int] dim dimension to slice in 1 or 2, dim=1 --> X(R,:), dim=2 --> X(:,R) + template + IGL_INLINE void slice_mask( + const Eigen::SparseMatrix & X, + const Eigen::Array & R, + const int dim, + Eigen::SparseMatrix & Y); + /// \overload + /// + /// \deprecated + /// + /// See slice.h for more details template IGL_INLINE void slice_mask( const Eigen::DenseBase & X, const Eigen::Array & R, const Eigen::Array & C, Eigen::PlainObjectBase & Y); - /// \overload - /// - /// \brief Wrapper to only slice in one direction - /// - /// @param[int] dim dimension to slice in 1 or 2, dim=1 --> X(R,:), dim=2 --> X(:,R) template IGL_INLINE void slice_mask( const Eigen::DenseBase & X, @@ -55,20 +72,6 @@ namespace igl const Eigen::DenseBase & X, const Eigen::Array & R, const int dim); - /// \overload - template - IGL_INLINE void slice_mask( - const Eigen::SparseMatrix & X, - const Eigen::Array & R, - const int dim, - Eigen::SparseMatrix & Y); - /// \overload - template - IGL_INLINE void slice_mask( - const Eigen::SparseMatrix & X, - const Eigen::Array & R, - const Eigen::Array & C, - Eigen::SparseMatrix & Y); } diff --git a/include/igl/slim.cpp b/include/igl/slim.cpp index 4270a7028..447b771e4 100644 --- a/include/igl/slim.cpp +++ b/include/igl/slim.cpp @@ -20,7 +20,6 @@ #include "grad.h" #include "local_basis.h" #include "per_face_normals.h" -#include "slice_into.h" #include "volume.h" #include "polar_svd.h" #include "flip_avoiding_line_search.h" diff --git a/include/igl/sort.cpp b/include/igl/sort.cpp index 2aeb105c2..bf3299a39 100644 --- a/include/igl/sort.cpp +++ b/include/igl/sort.cpp @@ -328,6 +328,8 @@ if(!ascending) #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh +template void igl::sort, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, int, bool, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +// generated by autoexplicit.sh template void igl::sort, Eigen::Matrix >(Eigen::DenseBase > const&, int, bool, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh template void igl::sort, Eigen::Matrix >(Eigen::DenseBase > const&, int, bool, Eigen::PlainObjectBase >&); diff --git a/include/igl/sort_triangles.cpp b/include/igl/sort_triangles.cpp index 5f2cc2304..08b5f9106 100644 --- a/include/igl/sort_triangles.cpp +++ b/include/igl/sort_triangles.cpp @@ -46,7 +46,7 @@ IGL_INLINE void igl::sort_triangles( MV.template cast().transpose()* P.template cast().transpose().eval().col(2)); sort(D,1,false,sD,I); - slice(F,I,1,FF); + FF = F(I.derived(),Eigen::all); } diff --git a/include/igl/spectra/eigs.cpp b/include/igl/spectra/eigs.cpp index d554809fc..b5caaf304 100644 --- a/include/igl/spectra/eigs.cpp +++ b/include/igl/spectra/eigs.cpp @@ -1,6 +1,5 @@ #include "eigs.h" #include "../sort.h" -#include "../slice.h" #include "../IGL_ASSERT.h" #include @@ -128,7 +127,7 @@ IGL_INLINE bool igl::spectra::eigs( Eigen::VectorXi I; igl::sort( Eigen::VectorXd(S), 1, false, S, I); - igl::slice(Eigen::MatrixXd(U),I,2,U); + U = U(Eigen::all,I).eval(); return true; } diff --git a/include/igl/split_nonmanifold.cpp b/include/igl/split_nonmanifold.cpp index eb4c1bec6..761ba6e54 100644 --- a/include/igl/split_nonmanifold.cpp +++ b/include/igl/split_nonmanifold.cpp @@ -6,14 +6,10 @@ // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "split_nonmanifold.h" -#include "ismember_rows.h" -#include "slice.h" -#include "slice_into.h" -#include "slice_mask.h" #include "connected_components.h" #include "remove_unreferenced.h" -#include "matlab_format.h" -#include +#include "find.h" +#include "ismember_rows.h" template < typename DerivedF, @@ -61,16 +57,17 @@ IGL_INLINE void igl::split_nonmanifold( // Flip orientation Eigen::MatrixXi FE_flip = FE.rowwise().reverse(); // Find which exist in both directions - Eigen::VectorXi I,J; + + + Eigen::Array I; + Eigen::VectorXi J; igl::ismember_rows(FE,FE_flip,I,J); // Just keep those find - Eigen::MatrixXi EI; - igl::slice_mask(E,I.array().cast(),1,EI); + const auto II = igl::find(I); + Eigen::MatrixXi EI = E(II,Eigen::all); + Eigen::VectorXi JI = J(II); + Eigen::MatrixXi EJI = E(JI,Eigen::all); - Eigen::VectorXi JI; - igl::slice_mask(J,I.array().cast(),1,JI); - Eigen::MatrixXi EJI; - igl::slice(E,JI,1,EJI); Eigen::MatrixXi EJI_flip = EJI.rowwise().reverse(); // Build adjacency matrix std::vector > Aijv; @@ -125,7 +122,7 @@ IGL_INLINE void igl::split_nonmanifold( // Scatter via K // SVI1(K) = SVI(K); Eigen::VectorXi SVI1(m*3); - igl::slice_into(SVI0,K,1,SVI1); + SVI1(K) = SVI0; { Eigen::VectorXi _,J; @@ -138,7 +135,7 @@ IGL_INLINE void igl::split_nonmanifold( SF(i,j) = J(SF(i,j)); } } - igl::slice(SVI1,J,1,SVI); + SVI = SVI1(J); } } @@ -158,7 +155,7 @@ IGL_INLINE void igl::split_nonmanifold( Eigen::PlainObjectBase & SVI) { igl::split_nonmanifold(F,SF,SVI); - igl::slice(V,SVI,1,SV); + SV = V(SVI.derived(),Eigen::all); } #ifdef IGL_STATIC_LIBRARY diff --git a/include/igl/straighten_seams.cpp b/include/igl/straighten_seams.cpp index d15f1b634..3e1ccc858 100644 --- a/include/igl/straighten_seams.cpp +++ b/include/igl/straighten_seams.cpp @@ -12,8 +12,8 @@ #include "max.h" #include "count.h" #include "any.h" +#include "slice.h" #include "slice_mask.h" -#include "slice_into.h" #include "unique_simplices.h" #include "adjacency_matrix.h" #include "setxor.h" @@ -22,7 +22,6 @@ #include "vertex_components.h" #include "list_to_matrix.h" #include "ears.h" -#include "slice.h" #include "sum.h" #include "find.h" #include @@ -74,11 +73,10 @@ IGL_INLINE void igl::straighten_seams( } ArrayvBT = Map >(BT.data(),BT.size(),1); ArrayvBF = Map >(BF.data(),BF.size(),1); - MatrixX2I OF; - slice_mask(ET,vBT,1,OT); - slice_mask(EF,vBT,1,OF); - VectorXi OFMAP; - slice_mask(EFMAP,vBT,1,OFMAP); + const auto vBT_i = igl::find(vBT); + MatrixX2I OF = EF(vBT_i,Eigen::all); + OT = EF(vBT_i,Eigen::all); + VectorXi OFMAP = EFMAP(vBT_i); // Two boundary edges on the texture-mapping are "equivalent" to each other on // the 3D-mesh if their 3D-mesh vertex indices match SparseMatrix OEQ; @@ -117,10 +115,10 @@ IGL_INLINE void igl::straighten_seams( assert( (M.array() == 1).all() ); VectorXi DT; // Map counts onto texture-vertices - slice(DV,I,1,DT); + DT = DV(I,Eigen::all); // Boundary in 3D && UV - Array BTF; - slice_mask(vBF, vBT, 1, BTF); + Array BTF = vBF(igl::find(vBT)); + // Texture-vertex is "sharp" if incident on "half-"edge that is not a // boundary in the 3D mesh but is a boundary in the texture-mesh AND is not // "cut cleanly" (the vertex is mapped to exactly 2 locations) @@ -237,17 +235,14 @@ IGL_INLINE void igl::straighten_seams( { case 1: { - MatrixX2I OTIc; - slice(OT,Ic,1,OTIc); + MatrixX2I OTIc = OT(Ic,Eigen::all); edges_to_path(OTIc,vpath,epath,eend); - Array SVvpath; - slice(SV,vpath,1,SVvpath); + Array SVvpath = SV(vpath); assert( (vpath(0) != vpath(vpath.size()-1) || !SVvpath.any()) && "Not dealing with 1-loops touching 'sharp' corners"); // simple open boundary - MatrixX2S PI; - slice(VT,vpath,1,PI); + MatrixX2S PI = VT(vpath,Eigen::all); const Scalar bbd = (PI.colwise().maxCoeff() - PI.colwise().minCoeff()).norm(); // Do not collapse boundaries to fewer than 3 vertices @@ -261,7 +256,7 @@ IGL_INLINE void igl::straighten_seams( { MatrixX2S UPI,UTvpath; ramer_douglas_peucker(PI,eff_tol*bbd,UPI,UIc,UTvpath); - slice_into(UTvpath,vpath,1,UT); + UT(vpath,Eigen::all) = UTvpath; if(!is_closed || allow_boundary_collapse) { break; @@ -292,17 +287,15 @@ IGL_INLINE void igl::straighten_seams( igl::LinSpaced(Ic.size(),0,Ic.size()-1).array()).all()); assert(Icc.size() == Ic.size()); const int cc = C(Icc(0)); - Eigen::VectorXi CIcc; - slice(C,Icc,1,CIcc); + Eigen::VectorXi CIcc = C(Icc); assert((CIcc.array() == cc).all()); assert(!done[cc]); done[cc] = true; } Array flipped; { - MatrixX2I OFIc,OFIcc; - slice(OF,Ic,1,OFIc); - slice(OF,Icc,1,OFIcc); + MatrixX2I OFIc = OF(Ic,Eigen::all); + MatrixX2I OFIcc = OF(Icc,Eigen::all); Eigen::VectorXi XOR,IA,IB; setxor(OFIc,OFIcc,XOR,IA,IB); assert(XOR.size() == 0); @@ -316,8 +309,7 @@ IGL_INLINE void igl::straighten_seams( vUE.push_back({OT(Icc(0),flipped(0)?1:0),OT(Icc(0),flipped(0)?0:1)}); }else { - MatrixX2I OTIc; - slice(OT,Ic,1,OTIc); + MatrixX2I OTIc = OT(Ic,Eigen::all); edges_to_path(OTIc,vpath,epath,eend); // Flip endpoints if needed for(int e = 0;e UPI,SI; VectorXi UIc; ramer_douglas_peucker(PI,tol*bbd,UPI,UIc,SI); - slice_into(SI.leftCols (VT.cols()), vpath,1,UT); - slice_into(SI.rightCols(VT.cols()),vpathc,1,UT); + UT(vpath,Eigen::all) = SI.leftCols (VT.cols()); + UT(vpathc,Eigen::all) = SI.rightCols(VT.cols()); for(int i = 0;i keep = (WE.array().col(0) != WE.array().col(1)); + WE = WE(keep,Eigen::all).eval(); // c flag must be present igl::triangle::triangulate(DerivedWV(WV),WE,DerivedWV(),flags,WV,WF); Eigen::VectorXi UJ; diff --git a/include/igl/triangle/scaf.cpp b/include/igl/triangle/scaf.cpp index 50f8d2ac5..d75f2f15e 100644 --- a/include/igl/triangle/scaf.cpp +++ b/include/igl/triangle/scaf.cpp @@ -433,8 +433,8 @@ IGL_INLINE void build_surface_linear_system(const SCAFData &s, Eigen::SparseMatr } else { - MatrixXd bnd_pos; - igl::slice(s.w_uv, bnd_ids, 1, bnd_pos); + MatrixXd bnd_pos = s.w_uv(bnd_ids, Eigen::all); + ArrayXi known_ids(bnd_ids.size() * dim); ArrayXi unknown_ids((v_n - bnd_ids.rows()) * dim); get_complement(bnd_ids, v_n, unknown_ids); @@ -494,8 +494,7 @@ IGL_INLINE void build_scaffold_linear_system(const SCAFData &s, Eigen::SparseMat auto bnd_n = bnd_ids.size(); IGL_ASSERT(bnd_n > 0); - MatrixXd bnd_pos; - igl::slice(s.w_uv, bnd_ids, 1, bnd_pos); + MatrixXd bnd_pos = s.w_uv(bnd_ids, Eigen::all); ArrayXi known_ids(bnd_ids.size() * dim); ArrayXi unknown_ids((v_n - bnd_ids.rows()) * dim); @@ -566,8 +565,7 @@ IGL_INLINE void solve_weighted_arap(SCAFData &s, Eigen::MatrixXd &uv) const auto v_n = s.v_num; const auto bnd_n = bnd_ids.size(); assert(bnd_n > 0); - MatrixXd bnd_pos; - igl::slice(s.w_uv, bnd_ids, 1, bnd_pos); + MatrixXd bnd_pos = s.w_uv(bnd_ids, Eigen::all); ArrayXi known_ids(bnd_n * dim); ArrayXi unknown_ids((v_n - bnd_n) * dim); @@ -592,8 +590,8 @@ IGL_INLINE void solve_weighted_arap(SCAFData &s, Eigen::MatrixXd &uv) SimplicialLDLT> solver; unknown_Uc = solver.compute(L).solve(rhs); - igl::slice_into(unknown_Uc, unknown_ids.matrix(), 1, Uc); - igl::slice_into(known_pos, known_ids.matrix(), 1, Uc); + Uc(unknown_ids) = unknown_Uc; + Uc(known_ids) = known_pos; uv = Map>(Uc.data(), v_n, dim); } diff --git a/include/igl/uniformly_sample_two_manifold.cpp b/include/igl/uniformly_sample_two_manifold.cpp index 0a074e10d..421ae5b10 100644 --- a/include/igl/uniformly_sample_two_manifold.cpp +++ b/include/igl/uniformly_sample_two_manifold.cpp @@ -7,7 +7,6 @@ // obtain one at http://mozilla.org/MPL/2.0/. #include "uniformly_sample_two_manifold.h" #include "verbose.h" -#include "slice.h" #include "colon.h" #include "all_pairs_distances.h" #include "vertex_triangle_adjacency.h" @@ -89,7 +88,7 @@ IGL_INLINE void igl::uniformly_sample_two_manifold( // First get sampling as best as possible on mesh uniformly_sample_two_manifold_at_vertices(W,k,push,S); verbose("Lap: %g\n",get_seconds()-start); - slice(W,S,colon(0,W.cols()-1),WS); + WS = W(S,Eigen::all); //cout<<"WSmesh=["<(0,W.cols()-1),WS); + MatrixXd WS = W(S,Eigen::all); //cout<<"WSpartition=["< & EMAP, std::vector > & uE2E) { + static_assert( + (DerivedEMAP::RowsAtCompileTime == 1 || DerivedEMAP::ColsAtCompileTime == 1) , + "EMAP need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1"); using namespace Eigen; using namespace std; unique_edge_map(F,E,uE,EMAP); @@ -107,6 +110,7 @@ IGL_INLINE void igl::unique_edge_map( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh +// generated by autoexplicit.sh template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #ifdef WIN32 template void __cdecl igl::unique_edge_map, class Eigen::Matrix, class Eigen::Matrix, class Eigen::Matrix, unsigned __int64>(class Eigen::MatrixBase > const&, class Eigen::PlainObjectBase >&, class Eigen::PlainObjectBase >&, class Eigen::PlainObjectBase >&, class std::vector >, class std::allocator > > >&); @@ -125,8 +129,6 @@ template void igl::unique_edge_map, Eigen: template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, unsigned long>(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, std::vector >, std::allocator > > >&); -template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, std::vector >, std::allocator > > >&); -template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, unsigned long>(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, std::vector >, std::allocator > > >&); template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, long>(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, std::vector >, std::allocator > > >&); template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, long>(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, std::vector >, std::allocator > > >&); template void igl::unique_edge_map, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, int>(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, std::vector >, std::allocator > > >&); @@ -141,7 +143,6 @@ template void igl::unique_edge_map, cl template void igl::unique_edge_map,class Eigen::Matrix,class Eigen::Matrix,class Eigen::Matrix<__int64,-1,1,0,-1,1>,__int64>(class Eigen::MatrixBase > const &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class std::vector >,class std::allocator > > > &); template void igl::unique_edge_map, class Eigen::Matrix, class Eigen::Matrix, class Eigen::Matrix, unsigned __int64>(class Eigen::MatrixBase> const &, class Eigen::PlainObjectBase> &, class Eigen::PlainObjectBase> &, class Eigen::PlainObjectBase> &, class std::vector>, class std::allocator>>> &); template void igl::unique_edge_map, class Eigen::Matrix, class Eigen::Matrix, class Eigen::Matrix, unsigned __int64>(class Eigen::MatrixBase> const &, class Eigen::PlainObjectBase> &, class Eigen::PlainObjectBase> &, class Eigen::PlainObjectBase> &, class std::vector>, class std::allocator>>> &); -template void igl::unique_edge_map,class Eigen::Matrix,class Eigen::Matrix,class Eigen::Matrix,unsigned __int64>(class Eigen::MatrixBase > const &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class std::vector >,class std::allocator > > > &); #endif #endif diff --git a/include/igl/unique_rows.cpp b/include/igl/unique_rows.cpp index 1425768c7..226c860f5 100644 --- a/include/igl/unique_rows.cpp +++ b/include/igl/unique_rows.cpp @@ -20,6 +20,11 @@ IGL_INLINE void igl::unique_rows( Eigen::PlainObjectBase& IA, Eigen::PlainObjectBase& IC) { + // IA and IC need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1 + static_assert( + (DerivedIA::RowsAtCompileTime == 1 || DerivedIA::ColsAtCompileTime == 1) && + (DerivedIC::RowsAtCompileTime == 1 || DerivedIC::ColsAtCompileTime == 1), + "IA and IC need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1"); using namespace std; using namespace Eigen; VectorXi IM; @@ -81,67 +86,45 @@ IGL_INLINE void igl::unique_rows( #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix>(Eigen::DenseBase> const&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&, Eigen::PlainObjectBase>&); // generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); // generated by autoexplicit.sh +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -// generated by autoexplicit.sh -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); -template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); -template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); -template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); -template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); -template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); -template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); template void igl::unique_rows,Eigen::Matrix,Eigen::Matrix,Eigen::Matrix >(Eigen::DenseBase > const&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&,Eigen::PlainObjectBase >&); -template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::unique_rows, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #ifdef WIN32 template void igl::unique_rows, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> >(class Eigen::DenseBase > const &, class Eigen::PlainObjectBase > &, class Eigen::PlainObjectBase > &, class Eigen::PlainObjectBase > &); template void igl::unique_rows,class Eigen::Matrix,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<__int64,-1,1,0,-1,1> >(class Eigen::DenseBase > const &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &); diff --git a/include/igl/unique_simplices.cpp b/include/igl/unique_simplices.cpp index 6f20ff227..a97865832 100644 --- a/include/igl/unique_simplices.cpp +++ b/include/igl/unique_simplices.cpp @@ -21,6 +21,11 @@ IGL_INLINE void igl::unique_simplices( Eigen::PlainObjectBase& IA, Eigen::PlainObjectBase& IC) { + // IA and IC need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1 + static_assert( + (DerivedIA::RowsAtCompileTime == 1 || DerivedIA::ColsAtCompileTime == 1) && + (DerivedIC::RowsAtCompileTime == 1 || DerivedIC::ColsAtCompileTime == 1), + "IA and IC need to have RowsAtCompileTime == 1 or ColsAtCompileTime == 1"); using namespace Eigen; using namespace std; typedef Eigen::Matrix @@ -68,8 +73,6 @@ template void igl::unique_simplices, Eigen template void igl::unique_simplices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::unique_simplices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::unique_simplices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_simplices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::unique_simplices, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #ifdef WIN32 template void igl::unique_simplices, class Eigen::Matrix, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> >(class Eigen::MatrixBase > const &, class Eigen::PlainObjectBase > &, class Eigen::PlainObjectBase > &, class Eigen::PlainObjectBase > &); #endif diff --git a/include/igl/unzip_corners.cpp b/include/igl/unzip_corners.cpp index b1e86fbc6..e23110f75 100644 --- a/include/igl/unzip_corners.cpp +++ b/include/igl/unzip_corners.cpp @@ -6,9 +6,7 @@ // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "unzip_corners.h" - #include "unique_rows.h" -#include "slice.h" template < typename DerivedA, typename DerivedU, typename DerivedG, typename DerivedJ > IGL_INLINE void igl::unzip_corners( diff --git a/tests/include/igl/copyleft/boolean/mesh_boolean.cpp b/tests/include/igl/copyleft/boolean/mesh_boolean.cpp index d130771eb..26564d1f5 100644 --- a/tests/include/igl/copyleft/boolean/mesh_boolean.cpp +++ b/tests/include/igl/copyleft/boolean/mesh_boolean.cpp @@ -41,7 +41,12 @@ namespace { typename DerivedF::Scalar, Eigen::Dynamic, Eigen::Dynamic> - E, uE, EMAP; + E, uE; + Eigen::Matrix< + typename DerivedF::Scalar, + Eigen::Dynamic, + 1> + EMAP; std::vector > uE2E; igl::unique_edge_map(F, E, uE, EMAP, uE2E); diff --git a/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp b/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp index 08309e9b8..24d851c4a 100644 --- a/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp +++ b/tests/include/igl/copyleft/cgal/order_facets_around_edges.cpp @@ -43,7 +43,8 @@ void assert_order( const Eigen::PlainObjectBase& F, size_t v0, size_t v1, std::vector expected_order, const std::string& normal="") { - Eigen::MatrixXi E, uE, EMAP; + Eigen::MatrixXi E, uE; + Eigen::VectorXi EMAP; std::vector > uE2E; igl::unique_edge_map(F, E, uE, EMAP, uE2E); diff --git a/tests/include/igl/decimate.cpp b/tests/include/igl/decimate.cpp index 8d853837a..a55f1784e 100644 --- a/tests/include/igl/decimate.cpp +++ b/tests/include/igl/decimate.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -28,8 +27,7 @@ TEST_CASE("decimate: hemisphere", "[igl]") igl::decimate(V,F,F.rows()/2,U,G,J,I); // Expect that all normals still point in same direction as original Eigen::MatrixXd NU = U.rowwise().normalized(); - Eigen::MatrixXd NVI; - igl::slice(NV,I,1,NVI); + Eigen::MatrixXd NVI = NV(I,Eigen::all); REQUIRE (NU.rows() == NVI.rows()); REQUIRE (NU.cols() == NVI.cols()); // Dot product diff --git a/tests/include/igl/ears.cpp b/tests/include/igl/ears.cpp new file mode 100644 index 000000000..4a0eba78b --- /dev/null +++ b/tests/include/igl/ears.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include + +void test_F(const Eigen::MatrixXi & F) +{ + Eigen::VectorXi ear,ear_opp; + igl::ears(F,ear,ear_opp); + + Eigen::Array B; + Eigen::MatrixXi E; + Eigen::VectorXi EMAP; + igl::is_boundary_edge(F,B,E,EMAP); + + for(int e = 0;e +#include + +TEST_CASE("edges_to_path: simple", "[igl]" ) +{ + Eigen::MatrixXi E(3,2); + E<<0,1, + 1,2, + 2,3; + Eigen::VectorXi P,J,K; + igl::edges_to_path(E,P,J,K); + Eigen::VectorXi P_expected(4); + P_expected<<0,1,2,3; + test_common::assert_eq(P,P_expected); +} diff --git a/tests/include/igl/orient_halfedges.cpp b/tests/include/igl/orient_halfedges.cpp index 2c2ebecca..a82b06e99 100644 --- a/tests/include/igl/orient_halfedges.cpp +++ b/tests/include/igl/orient_halfedges.cpp @@ -17,9 +17,8 @@ TEST_CASE("orient_halfedges: sanity checks", "[igl]") Eigen::MatrixXd V; Eigen::MatrixXi F; igl::read_triangle_mesh(test_common::data_path(mesh), V, F); - Eigen::MatrixXi I; - igl::remove_unreferenced(Eigen::MatrixXd(V), Eigen::MatrixXi(F), V, F, - I); + Eigen::VectorXi I; + igl::remove_unreferenced(Eigen::MatrixXd(V), Eigen::MatrixXi(F), V, F, I); Eigen::MatrixXi TT, TTi; igl::triangle_triangle_adjacency(F, TT, TTi); diff --git a/tests/include/igl/slice.cpp b/tests/include/igl/slice.cpp index cea4ae4e3..1d9a98a15 100644 --- a/tests/include/igl/slice.cpp +++ b/tests/include/igl/slice.cpp @@ -1,6 +1,63 @@ #include -#include #include +#include +// We don't want to include dense slices in the static library so include them +// via header only mode for these tests (which themselves will eventually be +// deprecated, too). +#ifdef IGL_STATIC_LIBRARY +# undef IGL_STATIC_LIBRARY +# include +# define IGL_STATIC_LIBRARY +#else +# include +#endif + +TEST_CASE("slice: eigen-simple", "[igl]") +{ + Eigen::MatrixXd X = Eigen::MatrixXd::Random(10,3); + Eigen::VectorXi I(2); I<<1,0; + { + Eigen::MatrixXd Yigl; + igl::slice(X,I,1,Yigl); + Eigen::MatrixXd Yeigen = X(I,Eigen::all); + test_common::assert_eq(Yigl,Yeigen); + } + { + Eigen::MatrixXd Yigl; + igl::slice(X,I,2,Yigl); + Eigen::MatrixXd Yeigen = X(Eigen::all,I); + test_common::assert_eq(Yigl,Yeigen); + } +} + +TEST_CASE("slice: eigen-random", "[igl]") +{ + const int m = 100; + const int n = 100; + Eigen::MatrixXd X = Eigen::MatrixXd::Random(m,n); + Eigen::VectorXi I; + igl::randperm(m,I); + Eigen::VectorXi J; + igl::randperm(n,J); + { + Eigen::MatrixXd Yigl; + igl::slice(X,I,J,Yigl); + Eigen::MatrixXd Yeigen = X(I,J); + test_common::assert_eq(Yigl,Yeigen); + } + { + Eigen::MatrixXd Yigl; + igl::slice(X,I,1,Yigl); + Eigen::MatrixXd Yeigen = X(I,Eigen::all); + test_common::assert_eq(Yigl,Yeigen); + } + { + Eigen::MatrixXd Yigl; + igl::slice(X,J,2,Yigl); + Eigen::MatrixXd Yeigen = X(Eigen::all,J); + test_common::assert_eq(Yigl,Yeigen); + } +} TEST_CASE("slice: dense_identity", "[igl]") { diff --git a/tests/include/igl/slice_into.cpp b/tests/include/igl/slice_into.cpp index 8feb139b2..2db4e34e5 100644 --- a/tests/include/igl/slice_into.cpp +++ b/tests/include/igl/slice_into.cpp @@ -1,6 +1,45 @@ #include #include #include +#include + +TEST_CASE("slice_into: eigen-random", "[igl]") +{ + const int m = 100; + const int n = 100; + Eigen::MatrixXd X = Eigen::MatrixXd::Random(m,n); + Eigen::VectorXi I; + igl::randperm(m,I); + I = I.head(m/2).eval(); + Eigen::VectorXi J; + igl::randperm(n,J); + J = J.head(n/2).eval(); + { + Eigen::MatrixXd Z = Eigen::MatrixXd::Random(I.size(),J.size()); + Eigen::MatrixXd Yigl = X; + igl::slice_into(Z,I,J,Yigl); + Eigen::MatrixXd Yeigen = X; + Yeigen(I,J) = Z; + test_common::assert_eq(Yigl,Yeigen); + } + { + Eigen::MatrixXd Z = Eigen::MatrixXd::Random(I.size(),X.cols()); + Eigen::MatrixXd Yigl = X; + igl::slice_into(Z,I,1,Yigl); + Eigen::MatrixXd Yeigen = X; + Yeigen(I,Eigen::all) = Z; + test_common::assert_eq(Yigl,Yeigen); + } + { + Eigen::MatrixXd Z = Eigen::MatrixXd::Random(X.rows(),J.size()); + Eigen::MatrixXd Yigl = X; + igl::slice_into(Z,J,2,Yigl); + Eigen::MatrixXd Yeigen = X; + Yeigen(Eigen::all,J) = Z; + test_common::assert_eq(Yigl,Yeigen); + } + +} TEST_CASE("slice_into: dense_identity", "[igl]") { diff --git a/tests/include/igl/slice_mask.cpp b/tests/include/igl/slice_mask.cpp new file mode 100644 index 000000000..e3023f538 --- /dev/null +++ b/tests/include/igl/slice_mask.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +TEST_CASE("slice_mask/find: random", "[igl]") +{ + const int m = 100; + const int n = 100; + Eigen::MatrixXd X = Eigen::MatrixXd::Random(m,n); + Eigen::VectorXi I; + igl::randperm(m,I); + Eigen::VectorXi J; + igl::randperm(n,J); + Eigen::Array M = + I.unaryExpr([](const int x) { return x%2 == 0; }).eval(); + Eigen::Array N = + J.unaryExpr([](const int x) { return x%2 == 0; }).eval(); + { + Eigen::MatrixXd Yigl; + igl::slice_mask(X,M,N,Yigl); + Eigen::MatrixXd Yfind = X(igl::find(M),igl::find(N)); + test_common::assert_eq(Yigl,Yfind); + } + { + Eigen::MatrixXd Yigl; + igl::slice_mask(X,M,1,Yigl); + Eigen::MatrixXd Yfind = X(igl::find(M),Eigen::all); + test_common::assert_eq(Yigl,Yfind); + } + { + Eigen::MatrixXd Yigl; + igl::slice_mask(X,N,2,Yigl); + Eigen::MatrixXd Yfind = X(Eigen::all,igl::find(N)); + test_common::assert_eq(Yigl,Yfind); + } +} + diff --git a/tutorial/301_Slice/main.cpp b/tutorial/301_Slice/main.cpp index 521ffc525..cc14770a8 100644 --- a/tutorial/301_Slice/main.cpp +++ b/tutorial/301_Slice/main.cpp @@ -1,7 +1,6 @@ #include #include -#include -#include +#include #include #include @@ -21,16 +20,21 @@ int main(int argc, char *argv[]) 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); + VectorXi K = I(J); + // igl::slice(I,J,K); no longer needed // 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); + C(K,Eigen::all) = R; + // igl::slice_into(R,K,1,C); no longer needed + + Eigen::Array W = Eigen::VectorXd::Random(F.rows()).array()>0.5; + // Set 1/4 of the colors to blue + MatrixXd B = RowVector3d(0.3,0.3,1.0).replicate(W.count(),1); + C(igl::find(W),Eigen::all) = B; // Plot the mesh with pseudocolors igl::opengl::glfw::Viewer viewer; diff --git a/tutorial/303_LaplaceEquation/main.cpp b/tutorial/303_LaplaceEquation/main.cpp index 98bee35cb..62419ba7f 100644 --- a/tutorial/303_LaplaceEquation/main.cpp +++ b/tutorial/303_LaplaceEquation/main.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -38,15 +37,13 @@ int main(int argc, char *argv[]) igl::slice(L,in,b,L_in_b); // Dirichlet boundary conditions from z-coordinate - VectorXd bc; VectorXd Z = V.col(2); - igl::slice(Z,b,bc); + VectorXd bc = Z(b); // Solve PDE SimplicialLLT > solver(-L_in_in); - VectorXd Z_in = solver.solve(L_in_b*bc); // slice into solution - igl::slice_into(Z_in,in,Z); + Z(in) = solver.solve(L_in_b*bc); // Alternative, short hand igl::min_quad_with_fixed_data mqwf; diff --git a/tutorial/406_FastAutomaticSkinningTransformations/main.cpp b/tutorial/406_FastAutomaticSkinningTransformations/main.cpp index 124912fa5..072c00f30 100644 --- a/tutorial/406_FastAutomaticSkinningTransformations/main.cpp +++ b/tutorial/406_FastAutomaticSkinningTransformations/main.cpp @@ -1,6 +1,5 @@ #include "precomputation.h" -#include #include #include #include @@ -147,7 +146,7 @@ int main(int argc, char *argv[]) // Plot the mesh with pseudocolors igl::opengl::glfw::Viewer viewer; viewer.data().set_mesh(U, F); - viewer.data().add_points(igl::slice(V,b,1),sea_green); + viewer.data().add_points(V(b,Eigen::all),sea_green); viewer.data().show_lines = false; viewer.callback_pre_draw = &pre_draw; viewer.callback_key_down = &key_down; diff --git a/tutorial/407_BiharmonicCoordinates/main.cpp b/tutorial/407_BiharmonicCoordinates/main.cpp index be57a76aa..c9355d976 100644 --- a/tutorial/407_BiharmonicCoordinates/main.cpp +++ b/tutorial/407_BiharmonicCoordinates/main.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -68,8 +67,7 @@ int main(int argc, char * argv[]) // with the vertices in high resolution. b is the list of vertices // corresponding to the indices in high resolution which has closest // distance to the points in low resolution - igl::slice(high.V,b,1,low.V); - + low.V = high.V(b,Eigen::all); // list of points --> list of singleton lists std::vector > S; @@ -92,8 +90,8 @@ int main(int argc, char * argv[]) igl::remove_unreferenced(high.V.rows(),high.F,I,J); for_each(high.F.data(),high.F.data()+high.F.size(),[&I](int & a){a=I(a);}); for_each(b.data(),b.data()+b.size(),[&I](int & a){a=I(a);}); - igl::slice(MatrixXd(high.V),J,1,high.V); - igl::slice(MatrixXd(W),J,1,W); + high.V = high.V(J,Eigen::all).eval(); + W = W(J,Eigen::all).eval(); } // Resize low res (high res will also be resized by affine precision of W) diff --git a/tutorial/507_Planarization/main.cpp b/tutorial/507_Planarization/main.cpp index c6e417498..7f9d081f4 100644 --- a/tutorial/507_Planarization/main.cpp +++ b/tutorial/507_Planarization/main.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -91,19 +90,19 @@ int main(int argc, char *argv[]) FQCtri.resize(2*FQC.rows(), 3); FQCtri << FQC.col(0),FQC.col(1),FQC.col(2), FQC.col(2),FQC.col(3),FQC.col(0); - igl::slice( VQC, FQC.col(0).eval(), 1, PQC0); - igl::slice( VQC, FQC.col(1).eval(), 1, PQC1); - igl::slice( VQC, FQC.col(2).eval(), 1, PQC2); - igl::slice( VQC, FQC.col(3).eval(), 1, PQC3); + PQC0 = VQC(FQC.col(0).eval(), Eigen::all); + PQC1 = VQC(FQC.col(1).eval(), Eigen::all); + PQC2 = VQC(FQC.col(2).eval(), Eigen::all); + PQC3 = VQC(FQC.col(3).eval(), Eigen::all); // Planarize it igl::planarize_quad_mesh(VQC, FQC, 100, 0.005, VQCplan); // Convert the planarized mesh to triangles - igl::slice( VQCplan, FQC.col(0).eval(), 1, PQC0plan); - igl::slice( VQCplan, FQC.col(1).eval(), 1, PQC1plan); - igl::slice( VQCplan, FQC.col(2).eval(), 1, PQC2plan); - igl::slice( VQCplan, FQC.col(3).eval(), 1, PQC3plan); + PQC0plan = VQCplan(FQC.col(0).eval(), Eigen::all); + PQC1plan = VQCplan(FQC.col(1).eval(), Eigen::all); + PQC2plan = VQCplan(FQC.col(2).eval(), Eigen::all); + PQC3plan = VQCplan(FQC.col(3).eval(), Eigen::all); // Launch the viewer igl::opengl::glfw::Viewer viewer; diff --git a/tutorial/702_WindingNumber/main.cpp b/tutorial/702_WindingNumber/main.cpp index a3cbe5912..acc4952fc 100644 --- a/tutorial/702_WindingNumber/main.cpp +++ b/tutorial/702_WindingNumber/main.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -41,8 +40,7 @@ void update_visualization(igl::opengl::glfw::Viewer & viewer) + plane(3); igl::marching_tets(V,T,IV,V_vis,F_vis,J,bary); } - VectorXd W_vis; - igl::slice(W,J,W_vis); + VectorXd W_vis = W(J); MatrixXd C_vis; // color without normalizing igl::parula(W_vis,false,C_vis); diff --git a/tutorial/706_FacetOrientation/main.cpp b/tutorial/706_FacetOrientation/main.cpp index f1ddb29fd..b1103be1d 100644 --- a/tutorial/706_FacetOrientation/main.cpp +++ b/tutorial/706_FacetOrientation/main.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -35,9 +34,9 @@ S,s Scramble colors { for(int pass = 0;pass<2;pass++) { - Eigen::MatrixXi R; + Eigen::VectorXi R; igl::randperm(C[pass].maxCoeff()+1,R); - C[pass] = igl::slice(R,Eigen::MatrixXi(C[pass])); + C[pass] = R(C[pass]).eval(); Eigen::MatrixXd HSV(C[pass].rows(),3); HSV.col(0) = 360.*C[pass].array().cast()/(double)C[pass].maxCoeff(); diff --git a/tutorial/803_ShapeUp/main.cpp b/tutorial/803_ShapeUp/main.cpp index 2508409ca..7b7edcf03 100644 --- a/tutorial/803_ShapeUp/main.cpp +++ b/tutorial/803_ShapeUp/main.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -111,10 +110,10 @@ int main(int argc, char *argv[]) FQCtri.resize(2*FQC.rows(), 3); FQCtri << FQC.col(0),FQC.col(1),FQC.col(2), FQC.col(2),FQC.col(3),FQC.col(0); - igl::slice( VQC, FQC.col(0).eval(), 1, PQC0); - igl::slice( VQC, FQC.col(1).eval(), 1, PQC1); - igl::slice( VQC, FQC.col(2).eval(), 1, PQC2); - igl::slice( VQC, FQC.col(3).eval(), 1, PQC3); + PQC0 = VQC(FQC.col(0).eval(), Eigen::all); + PQC1 = VQC(FQC.col(1).eval(), Eigen::all); + PQC2 = VQC(FQC.col(2).eval(), Eigen::all); + PQC3 = VQC(FQC.col(3).eval(), Eigen::all); // Create a planar version with ShapeUp //igl::planarize_quad_mesh(VQC, FQC, 100, 0.005, VQCregular); @@ -138,10 +137,10 @@ int main(int argc, char *argv[]) // Convert the planarized mesh to triangles - igl::slice( VQCregular, FQC.col(0).eval(), 1, PQC0regular); - igl::slice( VQCregular, FQC.col(1).eval(), 1, PQC1regular); - igl::slice( VQCregular, FQC.col(2).eval(), 1, PQC2regular); - igl::slice( VQCregular, FQC.col(3).eval(), 1, PQC3regular); + PQC0regular = VQCregular(FQC.col(0).eval(), Eigen::all); + PQC1regular = VQCregular(FQC.col(1).eval(), Eigen::all); + PQC2regular = VQCregular(FQC.col(2).eval(), Eigen::all); + PQC3regular = VQCregular(FQC.col(3).eval(), Eigen::all); // Launch the viewer igl::opengl::glfw::Viewer viewer; diff --git a/tutorial/805_MeshImplicitFunction/contours.cpp b/tutorial/805_MeshImplicitFunction/contours.cpp index a0674723f..28c381083 100644 --- a/tutorial/805_MeshImplicitFunction/contours.cpp +++ b/tutorial/805_MeshImplicitFunction/contours.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include void contours( @@ -195,7 +194,7 @@ void contours( Q.col(2), Q.col(3), Q.col(3), Q.col(0); igl::per_face_normals(V,I,C,N,VV,FF,J); - igl::slice(N,J,1,NN); + NN = N(J,Eigen::all); igl::per_corner_normals(V,I,C,20,N,VV,FF,J,NN); } diff --git a/tutorial/809_ExplodedView/main.cpp b/tutorial/809_ExplodedView/main.cpp index 8a00d9f4a..93554f51b 100644 --- a/tutorial/809_ExplodedView/main.cpp +++ b/tutorial/809_ExplodedView/main.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include @@ -43,8 +42,8 @@ int main(int argc, char *argv[]) Eigen::MatrixXi EF; Eigen::VectorXi I,J; igl::exploded_view(V,T,s,t,EV,EF,I,J); - Eigen::VectorXd DJ; - igl::slice(D,J,1,DJ); + Eigen::VectorXd DJ = D(J); + static bool first = true; if(first) {