__author__ = 'benjamin' from dc2D import tworesolution_dual_contour from dcSample import sample_data, sphere_f, doubletorus_f, torus_f import numpy as np dimensions = {'xmin': 0.0, 'xmax': 6.0, 'ymin': 2.0, 'ymax': 6.0} res_fine = 1.0/16.0 res_coarse = res_fine * 8.0 resolutions = {'fine': res_fine,'coarse': res_coarse} fine_data = sample_data(doubletorus_f, resolutions['fine'], dimensions) [verts_out_dc, quads_out_dc] = tworesolution_dual_contour(fine_data, resolutions, dimensions) import matplotlib.pyplot as plt fig = plt.figure() for q in quads_out_dc['fine']: vtx = verts_out_dc['fine'][q] x = vtx[:,0] y = vtx[:,1] #plt.plot(x, y, 'b') #plt.plot(x, y, 'bo') for q in quads_out_dc['coarse']: vtx = verts_out_dc['coarse'][q] x = vtx[:,0] y = vtx[:,1]
d_sq = _edgelist[i].measure_centroid_distance_squared(_point) # distance to centroid d_sq_list[i] = d_sq idx_list = sorted(range(len(d_sq_list)), key=lambda k: d_sq_list[k]) n_closest_idx = idx_list[:_n_closest] return n_closest_idx dimensions = {'xmin': 0.0, 'xmax': 6.0, 'ymin': 2.0, 'ymax': 6.0} res_fine = 1.0/8.0 res_coarse = res_fine * 4.0 resolutions = {'fine': res_fine,'coarse': res_coarse} fine_data = sample_data(doubletorus_f, resolutions['fine'], dimensions) [verts_out_dc, edges_out_dc, verts_pseudo_out_dc] = tworesolution_dual_contour(fine_data, resolutions, dimensions) N_edges = {'coarse': edges_out_dc['coarse'].shape[0], 'fine': edges_out_dc['fine'].shape[0]} N_verts = {'coarse': verts_out_dc['coarse'].shape[0], 'fine': verts_out_dc['fine'].shape[0]} edges = {'coarse': [None] * N_edges['coarse'], 'fine': [None] * N_edges['fine']} verts = {'coarse': verts_out_dc['coarse'], 'fine': verts_out_dc['fine']} # todo substitute with vertex objects for i in range(N_edges['coarse']): edges['coarse'][i]=Edge(i,edges_out_dc['coarse'],verts_out_dc['coarse']) import matplotlib.pyplot as plt fig = plt.figure() for q in edges_out_dc['fine']: