src/Geometry/clipConvexFacetedVolumeByPlanes3d.cc
//------------------------------------------------------------------------------
// Sort a set of edges into topological loops.
//------------------------------------------------------------------------------
Sort a set of edges into topological loops.
Sort a set of edges into topological loops .
inline
void
sortInTopologicalRings(vector<int>& loops,
                       const vector<pair<int, int>>& edges) {
  const auto nedges = loops.size();
  CHECK(nedges >= 3);
  int v1, iedge, jedge;
  for (iedge = 0; iedge < nedges - 1; ++iedge) {
    v1 = endVertex(loops[iedge], edges);
    jedge = iedge + 1;
    while (jedge < nedges and v1 != startVertex(loops[jedge], edges)) ++jedge;
    if (jedge < nedges) std::swap(loops[iedge + 1], loops[jedge]);
  }
  vector<int> edges2kill;
  for (iedge = 0; iedge < nedges; ++iedge) {
    jedge = (iedge + 1) % nedges;
    if (loops[iedge] == ~loops[jedge]) {
      edges2kill.push_back(iedge);
      edges2kill.push_back(jedge);
    }
  }
  removeElements(loops, edges2kill);
}
inline void sortInTopologicalRings ( vector < int > & loops , const vector < pair < int , int > > & edges ) { const auto nedges = loops . size ( ) ; CHECK ( nedges >= 3 ) ; int v1 , iedge , jedge ; for ( iedge = 0 ; iedge < nedges - 1 ; ++ iedge ) { v1 = endVertex ( loops [ iedge ] , edges ) ; jedge = iedge + 1 ; while ( jedge < nedges and v1 != startVertex ( loops [ jedge ] , edges ) ) ++ jedge ; if ( jedge < nedges ) std :: swap ( loops [ iedge + 1 ] , loops [ jedge ] ) ; } vector < int > edges2kill ; for ( iedge = 0 ; iedge < nedges ; ++ iedge ) { jedge = ( iedge + 1 ) % nedges ; if ( loops [ iedge ] == ~ loops [ jedge ] ) { edges2kill . push_back ( iedge ) ; edges2kill . push_back ( jedge ) ; } } removeElements ( loops , edges2kill ) ; }
Sort a set of edges into topological loops.
Sort a set of edges into topological loops .
// In some degenerate cases it's possible to have an edge we walk in reverse, // essentially negating it.  Check for this and remove any instances.