clean-pslg.js
function snapRound (points, edges, useColor) {
  // 1. find edge crossings
  var edgeBounds = boundEdges(points, edges)
  var crossings = getCrossings(points, edges, edgeBounds)

  // 2. find t-junctions
  var vertBounds = boundPoints(points)
  var tjunctions = getTJunctions(points, edges, edgeBounds, vertBounds)

  // 3. cut edges, construct rational points
  var ratPoints = cutEdges(points, edges, crossings, tjunctions, useColor)

  // 4. dedupe verts
  var labels = dedupPoints(points, ratPoints, vertBounds)

  // 5. dedupe edges
  dedupEdges(edges, labels, useColor)

  // 6. check termination
  if (!labels) {
    return (crossings.length > 0 || tjunctions.length > 0)
  }

  // More iterations necessary
  return true
}
function snapRound (points, edges, useColor) {
  // 1. find edge crossings
  var edgeBounds = boundEdges(points, edges)
  var crossings = getCrossings(points, edges, edgeBounds)

  // 2. find t-junctions
  var vertBounds = boundPoints(points)
  var tjunctions = getTJunctions(points, edges, edgeBounds, vertBounds)

  // 3. cut edges, construct rational points
  var ratPoints = cutEdges(points, edges, crossings, tjunctions, useColor)

  // 4. dedupe verts
  var labels = dedupPoints(points, ratPoints, vertBounds)

  // 5. dedupe edges
  dedupEdges(edges, labels, useColor)

  // 6. check termination
  if (!labels) {
    return (crossings.length > 0 || tjunctions.length > 0)
  }

  // More iterations necessary
  return true
}
function snapRound ( points , edges , useColor ) { // 1. find edge crossings var edgeBounds = boundEdges ( points , edges ) var crossings = getCrossings ( points , edges , edgeBounds ) // 2. find t-junctions var vertBounds = boundPoints ( points ) var tjunctions = getTJunctions ( points , edges , edgeBounds , vertBounds ) // 3. cut edges, construct rational points var ratPoints = cutEdges ( points , edges , crossings , tjunctions , useColor ) // 4. dedupe verts var labels = dedupPoints ( points , ratPoints , vertBounds ) // 5. dedupe edges dedupEdges ( edges , labels , useColor ) // 6. check termination if ( ! labels ) { return ( crossings . length > 0 || tjunctions . length > 0 ) } // More iterations necessary return true }
Repeat until convergence
Repeat until convergence