"""
Name: 'qhull mesh display'
Blender: 249
Group: 'Add'
Tooltip:'this lets you display a qhull mesh'
"""
from Blender import *
import bpy

from grid.DDD import rect_grid

def draw_file(filename):
  f = open(filename, 'r')
  print 'filename: ', filename
  print "degree:", f.readline().strip()
  print "number of points", f.readline().strip()

  verts = []
  for p in f:
    v = [float(i) for i in p.strip().split()]
    if len(v) == 2:
      v.append(0.0)
    verts.append(v)

  me = bpy.data.meshes.new('points')
  me.verts.extend(verts)
  # me.faces.extend([i.verts for i in p.faces.itervalues()])
  scn = bpy.data.scenes.active
  ob  = scn.objects.new(me, 'points_obj')

Window.FileSelector(draw_file, 'input file')
