import numpy as np
np.random.seed(583)

import matplotlib.pyplot as plt

from cellcomplex.property_topomesh.example_topomesh import circle_voronoi_topomesh
from cellcomplex.property_topomesh.analysis import compute_topomesh_property, compute_topomesh_vertex_property_from_edges
from cellcomplex.property_topomesh.utils.matplotlib_tools import mpl_draw_topomesh, mpl_draw_incidence_graph

topomesh = circle_voronoi_topomesh(3)
compute_topomesh_property(topomesh,'valency',0)
compute_topomesh_property(topomesh,'normal',1)
compute_topomesh_vertex_property_from_edges(topomesh,'normal')
compute_topomesh_property(topomesh,'inertia_tensor',2)

figure = plt.figure(0)
figure.clf()
figure.gca().axis('equal')

mpl_draw_topomesh(topomesh,figure,2,property_name='inertia_tensor',color='b',coef=1,linewidth=2)
mpl_draw_topomesh(topomesh,figure,1,color='k',linewidth=0.5)
mpl_draw_topomesh(topomesh,figure,1,property_name='normal',color='r',coef=0.5)
col = mpl_draw_topomesh(topomesh,figure,0,property_name='valency',colormap='jet',color='k',size=40,linewidth=0.5,intensity_range=(0,4))

cbar = figure.colorbar(col)
cbar.set_label('Vertex Valency')

figure.gca().axis('off')
figure.tight_layout()