@@ -1392,32 +1392,33 @@ def compute_topomesh_vertex_property_from_faces(topomesh,property_name,weighting
13921392 * *area*: the weight on the faces is equal to their area
13931393 * *angle*: the weight of the faces is equal to the incidence angle at the considered vertex (neighborhood=1)
13941394 * *cotangent*: the weight of the faces is equal to the sum of cotangent of opposite angles (neighborhood=1)
1395- neighborhood (int):
1395+ * *angular sector*: the weight of the faces is computed as the angular sector intersecting face barycenter (neighborhood=1)
1396+ neighborhood (int):
13961397 The ring-distance of faces considered around each vertex (1-ring is immediate neighbor faces).
1397- adjacency_sigma (float):
1398+ adjacency_sigma (float):
13981399 The standard deviation of the gaussian weighting using the ring-distance.
13991400
14001401 Returns:
14011402 None
1402-
1403+
14031404 Note:
14041405 The PropertyTopomesh passed as argument is updated.
14051406
1406- Example:
1407+ Example:
14071408 >>> from openalea.cellcomplex.property_topomesh.example_topomesh import square_topomesh
14081409 >>> from openalea.cellcomplex.property_topomesh.property_topomesh_analysis import compute_topomesh_property
14091410 >>> from openalea.cellcomplex.property_topomesh.property_topomesh_analysis import compute_topomesh_vertex_property_from_faces
14101411 >>> topomesh = square_topomesh(side_length=1)
14111412 >>> compute_topomesh_property(topomesh,'normal',2,normal_method='orientation')
1412- >>> compute_topomesh_vertex_property_from_faces(topomesh,'normal',weighting='area',neighborhood=3,adjacency_sigma=1.2)
1413+ >>> compute_topomesh_vertex_property_from_faces(topomesh,'normal',weighting='area',neighborhood=3,adjacency_sigma=1.2)
14131414
14141415 """
14151416
14161417 start_time = time ()
14171418 print "--> Computing vertex property from faces"
14181419
14191420 assert topomesh .has_wisp_property (property_name ,2 ,is_computed = True )
1420- assert weighting in ['uniform' ,'area' ,'angle' ,'cotangent' ]
1421+ assert weighting in ['uniform' ,'area' ,'angle' ,'cotangent' , 'angular sector' ]
14211422 if neighborhood > 1 :
14221423 try :
14231424 assert weighting in ['uniform' ,'area' ]
@@ -1436,7 +1437,7 @@ def compute_topomesh_vertex_property_from_faces(topomesh,property_name,weighting
14361437
14371438 vertex_faces = np .concatenate ([list (topomesh .regions (0 ,v ,2 )) for v in topomesh .wisps (0 )]).astype (np .uint32 )
14381439 vertex_face_vertices = np .concatenate ([v * np .ones_like (list (topomesh .regions (0 ,v ,2 ))) for v in topomesh .wisps (0 )]).astype (np .uint32 )
1439-
1440+
14401441 compute_topomesh_property (topomesh ,'border_neighbors' ,2 )
14411442
14421443 vertex_face_adjacency_matrix [(vertex_face_vertices ,vertex_faces )] = 0
@@ -1469,9 +1470,10 @@ def compute_topomesh_vertex_property_from_faces(topomesh,property_name,weighting
14691470 compute_topomesh_property (topomesh ,'vertices' ,2 )
14701471 compute_topomesh_property (topomesh ,'angles' ,2 )
14711472 vertex_face_face_vertices = topomesh .wisp_property ('vertices' ,2 ).values (vertex_faces )
1472-
1473+
14731474 vertex_face_face_angles = topomesh .wisp_property ('angles' ,2 ).values (vertex_faces )
14741475 vertex_face_vertex_angles = np .array ([angles [vertices == v ] for v ,vertices ,angles in zip (vertex_face_vertices ,vertex_face_face_vertices ,vertex_face_face_angles )])
1476+ print vertex_face_vertex_angles
14751477 vertex_face_weight = vertex_face_vertex_angles [:,0 ]
14761478 elif weighting == 'cotangent' :
14771479 compute_topomesh_property (topomesh ,'vertices' ,2 )
@@ -1482,6 +1484,24 @@ def compute_topomesh_vertex_property_from_faces(topomesh,property_name,weighting
14821484 vertex_face_opposite_angles = np .array ([angles [vertices != v ] for v ,vertices ,angles in zip (vertex_face_vertices ,vertex_face_face_vertices ,vertex_face_face_angles )])
14831485 vertex_face_cotangents = 1. / np .tan (vertex_face_opposite_angles )
14841486 vertex_face_weight = vertex_face_cotangents .sum (axis = 1 )
1487+ elif weighting == 'angular sector' :
1488+ compute_topomesh_property (topomesh ,'vertices' ,2 )
1489+ compute_topomesh_property (topomesh ,'angles' ,2 )
1490+ compute_topomesh_property (topomesh ,'barycenter' ,2 )
1491+
1492+ vertex_face_face_vertices = topomesh .wisp_property ('vertices' ,2 ).values (vertex_faces )
1493+ vertex_face_face_angles = topomesh .wisp_property ('angles' ,2 ).values (vertex_faces )
1494+ vertex_face_barycenter = topomesh .wisp_property ('barycenter' ,2 ).values (vertex_faces )
1495+ #vertex_positions = topomesh.wisp_property('barycenter',0).values(vertex_face_vertices)
1496+
1497+ face_vertex_positions = topomesh .wisp_property ('barycenter' ,0 ).values (vertex_face_face_vertices )
1498+ # face_vertex_barycenter_radii = np.linalg.norm(np.array([[vertex_face_barycenter[f] - v for v in face_vertex_positions[f]] for f in vertex_faces]), axis=1)
1499+ face_vertex_barycenter_radii = np .linalg .norm (face_vertex_positions - vertex_face_barycenter [:,np .newaxis ],axis = 1 )
1500+
1501+ vertex_face_weight = np .array (
1502+ [r [vertices == v ] * angles [vertices == v ] for v , vertices , r , angles
1503+ in zip (vertex_face_vertices , vertex_face_face_vertices ,
1504+ face_vertex_barycenter_radii , vertex_face_face_angles )])[:,0 ]
14851505
14861506 if neighborhood > 1 :
14871507 vertex_face_weight = vertex_face_weight * vertex_adjacency_gaussian_weight
0 commit comments