GeoNodes MeshToCurve Index Order

Hello everyone

I got a spherical mesh with many faces and I select some of them to use a MeshToCurve node individually.
Then I use the curve frames to create faces again by using a filled curve on the same positions. (This is just an itermediate step, that contains the problem, not my full workflow, because it would make no sense to recreate faces alone.)

The problem is, that the MeshToCurve Node will give every curve a different order.
I want to make the curve order dependent on the initial face normal, so that for example every curve is ordered clockwise, seen from the face normal direction.

Is this possible? Maybe with a angle check and then use a “Reverse Curve”?

Greetings, Mech

This is no possible and you should not try to do that. At least, you can use attribute on vertices for that reason. After Mesh to Curve you can apply Sort Elements node.

can u add a sketch/image/annotions how it should look like? thx.

1 Like

Hi mechandrius,
not entirely sure what you want to do but you can calculate the Winding Number to check if a curve is reversed or not.
Assuming we have a mesh and want to extrude a profile along the edges with a Curve to Mesh node:
As you already noticed, some of the curves go in a clockwise and some in a counter clockwise direction (as can be seen by the flipped normals).

To calculate the winding direction, we first have to center the positions of our curves and then bring them onto the XY plane using the inverse of an Align Euler to Vector node.
In my example i used the captured Face Position as the Center and the captured Face Normal as the Alignment Vector:


After that, we calculate the difference of the angles from the current and the next point of the curve (Offset Point in Curve) using the Atan2 function:

After that we need to correct the values from the Atan2 function (because it goes from -180° to +180°) and make some corrections for cyclic and non cyclic curves.

Now we know the angle between the points and can sum them up using the Accumulate Field node and divide them by Tau (2 * Pi).
The resulting value will be the number of windings we made following the curve from the start to the end from our Center point and if the curve goes clockwise or counter clockwise (negative vs positive value).

The complete Winding Number nodegroup:

And this is the result:

3 Likes