How to find a loop that include a vertex

Dear Friend,

loops = gface.loops.reject { |l| l == gface.outer_loop }

This code find several loops for me. I wish to find a loop that include a especial vertex (my_vertex). Can you help me for it?

Is the same as …

inner_loops = gface.loops - [ gface.outer_loop ]
found_loop = inner_loops.find { |loop| loop.vertices.include?(my_vertex) }

Enumerable#find will return nil if the loop is not found.
So always check that the result is not nil afterward …

if found_loop
   # use found_loop
  # do something else


1 Like

The way that you write codes help us to understand it. Thank you.