|
@@ -12,7 +12,6 @@
|
|
#include "sortrows.h"
|
|
#include "sortrows.h"
|
|
#include "list_to_matrix.h"
|
|
#include "list_to_matrix.h"
|
|
#include "matrix_to_list.h"
|
|
#include "matrix_to_list.h"
|
|
-#include "get_seconds.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <iostream>
|
|
@@ -213,21 +212,32 @@ IGL_INLINE void igl::unique_rows(
|
|
sortrows(A,true,sortA,IM);
|
|
sortrows(A,true,sortA,IM);
|
|
|
|
|
|
|
|
|
|
- vector<int> vIA(sortA.rows());
|
|
|
|
- for(int i=0;i<(int)sortA.rows();i++)
|
|
|
|
|
|
+ const int num_rows = sortA.rows();
|
|
|
|
+ const int num_cols = sortA.cols();
|
|
|
|
+ vector<int> vIA(num_rows);
|
|
|
|
+ for(int i=0;i<num_rows;i++)
|
|
{
|
|
{
|
|
vIA[i] = i;
|
|
vIA[i] = i;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ auto index_equal = [&sortA, &num_cols](const size_t i, const size_t j) {
|
|
|
|
+ for (size_t c=0; c<num_cols; c++) {
|
|
|
|
+ if (sortA.coeff(i,c) != sortA.coeff(j,c))
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ };
|
|
vIA.erase(
|
|
vIA.erase(
|
|
std::unique(
|
|
std::unique(
|
|
vIA.begin(),
|
|
vIA.begin(),
|
|
vIA.end(),
|
|
vIA.end(),
|
|
- igl::IndexRowEquals<const Eigen::PlainObjectBase<DerivedA> &>(sortA)),vIA.end());
|
|
|
|
|
|
+ index_equal
|
|
|
|
+ ),vIA.end());
|
|
|
|
|
|
IC.resize(A.rows(),1);
|
|
IC.resize(A.rows(),1);
|
|
{
|
|
{
|
|
int j = 0;
|
|
int j = 0;
|
|
- for(int i = 0;i<(int)sortA.rows();i++)
|
|
|
|
|
|
+ for(int i = 0;i<num_rows;i++)
|
|
{
|
|
{
|
|
if(sortA.row(vIA[j]) != sortA.row(i))
|
|
if(sortA.row(vIA[j]) != sortA.row(i))
|
|
{
|
|
{
|
|
@@ -236,10 +246,11 @@ IGL_INLINE void igl::unique_rows(
|
|
IC(IM(i,0),0) = j;
|
|
IC(IM(i,0),0) = j;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- C.resize(vIA.size(),A.cols());
|
|
|
|
- IA.resize(vIA.size(),1);
|
|
|
|
|
|
+ const int unique_rows = vIA.size();
|
|
|
|
+ C.resize(unique_rows,A.cols());
|
|
|
|
+ IA.resize(unique_rows,1);
|
|
// Reindex IA according to IM
|
|
// Reindex IA according to IM
|
|
- for(int i = 0;i<(int)vIA.size();i++)
|
|
|
|
|
|
+ for(int i = 0;i<unique_rows;i++)
|
|
{
|
|
{
|
|
IA(i,0) = IM(vIA[i],0);
|
|
IA(i,0) = IM(vIA[i],0);
|
|
C.row(i) = A.row(IA(i,0));
|
|
C.row(i) = A.row(IA(i,0));
|