https://github.com/HTDerekLiu/surface_multigrid_code
Revision 2a5ce10bcc87d1ae648b298a39eec2f368b24b24 authored by HTDerekLiu on 24 May 2021, 13:03:36 UTC, committed by HTDerekLiu on 24 May 2021, 13:03:36 UTC
1 parent 5d998ed
Raw File
Tip revision: 2a5ce10bcc87d1ae648b298a39eec2f368b24b24 authored by HTDerekLiu on 24 May 2021, 13:03:36 UTC
add balloon
Tip revision: 2a5ce10
intersect_ordered.cpp
#include "intersect_ordered.h"

void intersect_ordered(
  const Eigen::VectorXi & A,
  const Eigen::VectorXi & B,
  Eigen::VectorXi & C,
  Eigen::VectorXi & AinB)
  {
    using namespace Eigen;
    VectorXi tmpC(A.size() > B.size() ? A.size() : B.size());
    VectorXi tmpAinB(A.size() > B.size() ? A.size() : B.size());

    // count of intersects
    int c = 0;

    // Loop over A
    for(int i = 0;i<A.size();i++)
    {
      // Loop over B
      for(int j = 0;j<B.size();j++)
      {
        if(A(i) == B(j))
        {
          tmpC(c) = A(i);
          tmpAinB(c) = j;
          c++;
        }
      }
    }

    // resize output
    C.resize(c);
    AinB.resize(c);

    // Loop over intersects
    for(int i = 0;i<c;i++)
    {
      C(i) = tmpC(i);
      AinB(i) = tmpAinB(i);
    }

  }
back to top