dmytromishkin commited on
Commit
da4ae8f
1 Parent(s): 420d591

add vertex visualization option

Browse files
Files changed (1) hide show
  1. hoho/vis.py +8 -4
hoho/vis.py CHANGED
@@ -41,7 +41,7 @@ def line(p1, p2, c=(255,0,0), resolution=10, radius=0.05):
41
 
42
  return mesh
43
 
44
- def show_wf(row, radius=10):
45
  EDGE_CLASSES = ['eave',
46
  'ridge',
47
  'step_flashing',
@@ -51,14 +51,18 @@ def show_wf(row, radius=10):
51
  'valley',
52
  'hip',
53
  'transition_line']
 
 
 
54
  if 'edge_semantics' not in row:
55
  print ("Warning: edge semantics is not here, skipping")
56
- return [line(a,b, radius=radius, c=(214, 251, 248)) for a,b in np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])]]
57
  elif len(np.stack(row['wf_edges'])) == len(row['edge_semantics']):
58
- return [line(a,b, radius=radius, c=color_mappings.gestalt_color_mapping[EDGE_CLASSES[cls_id]]) for (a,b), cls_id in zip(np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])], row['edge_semantics'])]
59
  else:
60
  print ("Warning: edge semantics has different length compared to edges, skipping semantics")
61
- return [line(a,b, radius=radius, c=(214, 251, 248)) for a,b in np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])]]
 
62
  # return [line(a,b, radius=radius, c=color_mappings.edge_colors[cls_id]) for (a,b), cls_id in zip(np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])], row['edge_semantics'])]
63
 
64
 
 
41
 
42
  return mesh
43
 
44
+ def show_wf(row, radius=10, show_vertices=False):
45
  EDGE_CLASSES = ['eave',
46
  'ridge',
47
  'step_flashing',
 
51
  'valley',
52
  'hip',
53
  'transition_line']
54
+ out_meshes = []
55
+ if show_vertices:
56
+ out_meshes.extend([trimesh.primitives.Sphere(radius=radius+5, center = center, color=(255,0,0)) for center in row['wf_vertices']])
57
  if 'edge_semantics' not in row:
58
  print ("Warning: edge semantics is not here, skipping")
59
+ out_meshes.extend([line(a,b, radius=radius, c=(214, 251, 248)) for a,b in np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])]])
60
  elif len(np.stack(row['wf_edges'])) == len(row['edge_semantics']):
61
+ out_meshes.extend([line(a,b, radius=radius, c=color_mappings.gestalt_color_mapping[EDGE_CLASSES[cls_id]]) for (a,b), cls_id in zip(np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])], row['edge_semantics'])])
62
  else:
63
  print ("Warning: edge semantics has different length compared to edges, skipping semantics")
64
+ out_meshes.extend([line(a,b, radius=radius, c=(214, 251, 248)) for a,b in np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])]])
65
+ return out_meshes
66
  # return [line(a,b, radius=radius, c=color_mappings.edge_colors[cls_id]) for (a,b), cls_id in zip(np.stack([*row['wf_vertices']])[np.stack(row['wf_edges'])], row['edge_semantics'])]
67
 
68