Convert poly tubes to NURBS curves


#1

I have modeled fabric and i need to replace polygon tubes with NURBS curves.
The smallest peace left, model in general right.

I can imagine how to build a script if i were able to select each closed edge loop of tube: find world coordinates of loop and add CV, so at the and i will get the curve in the center of a tube. But i have no idea how to find these loops, especially in right order.

Any thoughts about this task?


#2

An idea:

  1. Convert the mesh into a graph.
  2. Define a function to trace a loop given a vertex and an incident edge. When arriving at a new vertex, you continue with the edge that creates a 180 degrees angle with the previous edge on the surface.
  3. Detect all the loops for one of the tubes given a source vertex v on it:
    3.1. Select the first incident edge to v and trace a loop l_u from it (using the function from 2).
    3.2. Select the second incident edge to v and trace a loop l_v from it.
    3.3. For each of the two loops l_u, l_v:
    3.3.1. For each vertex in a loop:
    3.1.1.1. Trace a loop that is perpendicular to the source loop.

You’ll end up with two sets of loops, one set for each l_u and l_v.