Exemple #1
0
        y = [s[1] for s in side]
        ax1.plot(x, y, color=colors[index])
    piece_data['sides'] = [s.tolist() for s in piece.sides]
  except:
    print 'could not find sides for "%s"' % filepath

  # Get length of each side and label.
  try:
    piece.find_side_lengths()
    piece_data['side_lengths'] = piece.side_lengths
  except:
    print 'could not find side lengths for "%s"' % filepath

  # Classify each side's type and label.
  try:
    piece.find_side_types()
    if args['--plot']:
      directions = ('N', 'E', 'S', 'W')
      for index, side in enumerate(piece.sides):
        length = piece.side_lengths[index]
        side_type = piece.side_types[index]
        x, y = piece.mean_side_points[index]
        label = '%s: %0.0f (%s)' % (directions[index], length, side_type)
        ax1.text(x, y, label, horizontalalignment='center',
                 verticalalignment='center')
    piece_data['side_types'] = piece.side_types
  except:
    print 'could not find side types for "%s"' % filepath

  # Define the bounding box around each non-flat side.
  try: