overlay-pslg.js
function markCells(cells, adj, edges) {

  //Initialize active/next queues and flags
  var flags = new Array(cells.length)
  var constraint = new Array(3*cells.length)
  for(var i=0; i<3*cells.length; ++i) {
    constraint[i] = false
  }
  var active = []
  var next   = []
  for(var i=0; i<cells.length; ++i) {
    var c = cells[i]
    flags[i] = 0
    for(var j=0; j<3; ++j) {
      var a = c[(j+1)%3]
      var b = c[(j+2)%3]
      var constr = constraint[3*i+j] = isConstraint(edges, a, b)
      if(adj[3*i+j] >= 0) {
        continue
      }
      if(constr) {
        next.push(i)
      } else {
        flags[i] = 1
        active.push(i)
      }
    }
  }

  //Mark flags
  var side = 1
  while(active.length > 0 || next.length > 0) {
    while(active.length > 0) {
      var t = active.pop()
      if(flags[t] === -side) {
        continue
      }
      flags[t] = side
      var c = cells[t]
      for(var j=0; j<3; ++j) {
        var f = adj[3*t+j]
        if(f >= 0 && flags[f] === 0) {
          if(constraint[3*t+j]) {
            next.push(f)
          } else {
            active.push(f)
            flags[f] = side
          }
        }
      }
    }

    //Swap arrays and loop
    var tmp = next
    next = active
    active = tmp
    next.length = 0
    side = -side
  }

  return flags
}
function markCells(cells, adj, edges) {

  //Initialize active/next queues and flags
  var flags = new Array(cells.length)
  var constraint = new Array(3*cells.length)
  for(var i=0; i<3*cells.length; ++i) {
    constraint[i] = false
  }
  var active = []
  var next   = []
  for(var i=0; i<cells.length; ++i) {
    var c = cells[i]
    flags[i] = 0
    for(var j=0; j<3; ++j) {
      var a = c[(j+1)%3]
      var b = c[(j+2)%3]
      var constr = constraint[3*i+j] = isConstraint(edges, a, b)
      if(adj[3*i+j] >= 0) {
        continue
      }
      if(constr) {
        next.push(i)
      } else {
        flags[i] = 1
        active.push(i)
      }
    }
  }

  //Mark flags
  var side = 1
  while(active.length > 0 || next.length > 0) {
    while(active.length > 0) {
      var t = active.pop()
      if(flags[t] === -side) {
        continue
      }
      flags[t] = side
      var c = cells[t]
      for(var j=0; j<3; ++j) {
        var f = adj[3*t+j]
        if(f >= 0 && flags[f] === 0) {
          if(constraint[3*t+j]) {
            next.push(f)
          } else {
            active.push(f)
            flags[f] = side
          }
        }
      }
    }

    //Swap arrays and loop
    var tmp = next
    next = active
    active = tmp
    next.length = 0
    side = -side
  }

  return flags
}
function markCells ( cells , adj , edges ) { //Initialize active/next queues and flags var flags = new Array ( cells . length ) var constraint = new Array ( 3 * cells . length ) for ( var i = 0 ; i < 3 * cells . length ; ++ i ) { constraint [ i ] = false } var active = [ ] var next = [ ] for ( var i = 0 ; i < cells . length ; ++ i ) { var c = cells [ i ] flags [ i ] = 0 for ( var j = 0 ; j < 3 ; ++ j ) { var a = c [ ( j + 1 ) % 3 ] var b = c [ ( j + 2 ) % 3 ] var constr = constraint [ 3 * i + j ] = isConstraint ( edges , a , b ) if ( adj [ 3 * i + j ] >= 0 ) { continue } if ( constr ) { next . push ( i ) } else { flags [ i ] = 1 active . push ( i ) } } } //Mark flags var side = 1 while ( active . length > 0 || next . length > 0 ) { while ( active . length > 0 ) { var t = active . pop ( ) if ( flags [ t ] === - side ) { continue } flags [ t ] = side var c = cells [ t ] for ( var j = 0 ; j < 3 ; ++ j ) { var f = adj [ 3 * t + j ] if ( f >= 0 && flags [ f ] === 0 ) { if ( constraint [ 3 * t + j ] ) { next . push ( f ) } else { active . push ( f ) flags [ f ] = side } } } } //Swap arrays and loop var tmp = next next = active active = tmp next . length = 0 side = - side } return flags }
Classify all cells within boundary
Classify all cells within boundary