def getIndexedCellLoopsFromIndexedGrid(grid):
 indexedCellLoops = []
 for rowIndex in xrange((len(grid) - 1)):
  rowBottom = grid[rowIndex]
  rowTop = grid[(rowIndex + 1)]
  for columnIndex in xrange((len(rowBottom) - 1)):
   columnIndexEnd = (columnIndex + 1)
   indexedConvex = []
   indexedConvex.append(rowBottom[columnIndex])
   indexedConvex.append(rowBottom[(columnIndex + 1)])
   indexedConvex.append(rowTop[(columnIndex + 1)])
   indexedConvex.append(rowTop[columnIndex])
   indexedCellLoops.append(indexedConvex)
 return indexedCellLoops

def getIndexedCellLoopsFromIndexedGrid ( grid ) : indexedCellLoops = [ ] for rowIndex in xrange ( ( len ( grid ) - 1 ) ) : rowBottom = grid [ rowIndex ] rowTop = grid [ ( rowIndex + 1 ) ] for columnIndex in xrange ( ( len ( rowBottom ) - 1 ) ) : columnIndexEnd = ( columnIndex + 1 ) indexedConvex = [ ] indexedConvex . append ( rowBottom [ columnIndex ] ) indexedConvex . append ( rowBottom [ ( columnIndex + 1 ) ] ) indexedConvex . append ( rowTop [ ( columnIndex + 1 ) ] ) indexedConvex . append ( rowTop [ columnIndex ] ) indexedCellLoops . append ( indexedConvex ) return indexedCellLoops
get indexed cell loops from an indexed grid .