plot_dims = {'xmin': 2.0, 'xmax': 6.0, 'ymin': 2.0, 'ymax': 6.0, 'zmin': 2.0, 'zmax': 6.0} res_fine = 1.0/4.0 res_coarse = 2.0 resolutions = {'fine': res_fine,'coarse': res_coarse} fine_data = sample_data(torus_f, resolutions['fine'], dimensions) else: print "Example "+__EXAMPLE__+" not known!" raise Exception("ABOTRING!") print "###Dual Contouring###" print "..." [verts_out_dc, quads_out_dc, manifolds] = tworesolution_dual_contour(fine_data, resolutions, dimensions) print "###Dual Contouring DONE###" N_quads = {'coarse': quads_out_dc['coarse'].__len__(), 'fine': quads_out_dc['fine'].__len__()} N_verts = {'coarse': verts_out_dc['coarse'].__len__(), 'fine': verts_out_dc['fine'].__len__()} quads = {'coarse': [None] * N_quads['coarse'], 'fine': [None] * N_quads['fine']} verts = {'coarse': verts_out_dc['coarse'], 'fine': verts_out_dc['fine']} # todo substitute with vertex objects for i in range(N_quads['coarse']): quads['coarse'][i]=Quad(i,quads_out_dc['coarse'],verts_out_dc['coarse']) print "###Projecting Datapoints onto coarse quads###" import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D
wfFile = open('Cantilever/Cells', 'rb') cellsDict = cPickle.load(wfFile) wfFile.close() wfFile = open('Cantilever/Dimensions', 'rb') dimensions = cPickle.load(wfFile) wfFile.close() res_fine = 1 res_coarse = res_fine * 2.0 resolutions = {'fine': res_fine,'coarse': res_coarse} data = transform_dict(cellsDict) [verts_out_dc, quads_out_dc] = tworesolution_dual_contour(data, resolutions, dimensions) dcHelpers.export_as_stl(quads_out_dc, verts_out_dc, plot_scale = 'coarse', filename = 'canti.stl') import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection fig = plt.figure() ax = Axes3D(fig) ax.set_aspect('equal') plot_scale = 'coarse' for q in quads_out_dc[plot_scale]: vtx = verts_out_dc[plot_scale][q] x = vtx[:,0].tolist()