src/Mesh/findMatchingVertex.cc
//------------------------------------------------------------------------------
// The the matching vertex between two lists (assumed to be in opposite order.)
//------------------------------------------------------------------------------
The the matching vertex between two lists (assumed to be in opposite order.)
The the matching vertex between two lists ( assumed to be in opposite order . )
unsigned
findMatchingVertex(const unsigned i, 
                   const vector<Dim<2>::Vector>& verticesi,
                   const vector<Dim<2>::Vector>& verticesj) {
  REQUIRE(i < verticesi.size());
  const unsigned ni = verticesi.size(), nj = verticesj.size();
  const unsigned ii = (i + 1) % ni;
  vector<double> chi2;
  chi2.reserve(nj);
  unsigned j, jj;
  for (j = 0; j != nj; ++j) {
    jj = (j == 0 ? (nj - 1) : (j - 1));
    chi2.push_back((verticesi[i] - verticesj[j]).magnitude2() +
                   (verticesi[ii] - verticesj[jj]).magnitude2());
  }
  j = distance(chi2.begin(), min_element(chi2.begin(), chi2.end()));
  ENSURE2(j < nj, "Unable to find matching vertex");
  return j;
}
unsigned findMatchingVertex ( const unsigned i , const vector < Dim < 2 > :: Vector > & verticesi , const vector < Dim < 2 > :: Vector > & verticesj ) { REQUIRE ( i < verticesi . size ( ) ) ; const unsigned ni = verticesi . size ( ) , nj = verticesj . size ( ) ; const unsigned ii = ( i + 1 ) % ni ; vector < double > chi2 ; chi2 . reserve ( nj ) ; unsigned j , jj ; for ( j = 0 ; j != nj ; ++ j ) { jj = ( j == 0 ? ( nj - 1 ) : ( j - 1 ) ) ; chi2 . push_back ( ( verticesi [ i ] - verticesj [ j ] ) . magnitude2 ( ) + ( verticesi [ ii ] - verticesj [ jj ] ) . magnitude2 ( ) ) ; } j = distance ( chi2 . begin ( ) , min_element ( chi2 . begin ( ) , chi2 . end ( ) ) ) ; ENSURE2 ( j < nj , " " ) ; return j ; }
The the matching vertex between two lists (assumed to be in opposite order.)
The the matching vertex between two lists ( assumed to be in opposite order . )
//   if (!(j < nj)) { //     cerr << i << endl; //     for (jj = 0; jj != ni; ++jj) cerr << " " << verticesi[jj]; //     cerr << endl; //     for (jj = 0; jj != nj; ++jj) cerr << " " << verticesj[jj]; //     cerr << endl; //   }