// provide seed points in ancillary port: 1
float search_dist = chf("search_distance");
int near_pts[] = nearpoints(1, v@P, search_dist);//from @P
int near_a = near_pts[0];
int near_b = near_pts[1];
vector a = point(1, "P", near_a); //closest cell
vector b = point(1, "P", near_b);
vector ab = normalize(b-a);
vector m = (a + b) * 0.5;
near_pts = nearpoints(1, a, search_dist);//from closest cell
foreach (int i; near_pts){
if (i == near_b || i == near_a) continue;
vector c = point(1, "P", i);
vector ac = normalize(c-a);
float dst_c = dot(mcx, ac);
min_dst = min(dst_c, min_dst);
i@facet_id = closest_c != -1 ? closest_c : near_b;