Final orientation of an edge

Hi,

I have a Shell. From the Shell I get a Face with normal Zpos or Zneg. From the Face I get its Wire. From the Wire I explore its Edges. For each edge I want to know where the Face is.

As far as I've read, Orientation is the answer. However, I'm finding it quite difficult to analyse when the REVERSED orientation comes into play, and even more when the normal of the Face is Zneg.

Seeing the Face from the top view, it seems that taking the Orientation of the Edge and Reversing it if the Face's Orientation is Zneg gives me a coherent result... most of the time. With coherent result I mean: left side of natural direction of the edge if FORWARD, right side if REVERSED, always from top view.

If I got it right, the Face's orientation means if the normal of the face is the same as the surface (FORWARD) or opposite (REVERSED).

Should I also take care of the Shell's and Wire's Orientations somehow?

Before you ask, this is what I'm trying to do:

I have a face from a closed wire. I want to add another wire to it, where the first and last vertices of this new wire are also in the face's wire. I want to close this new wire using edges from the face's wire. There are two different paths I can take here. In the common situation, one of the paths will give me a wire that encloses the other, the other path just two wires that share some of their edges. The latter is the one I need, so if I create a face from this new wire, it won't overlap the previous one.

My approach is to find the first two candidate edges that I could append to the new wire. I also close a copy of the new wire temporarily and make a face from it to know at which side of the edges the face would be created. Then I analyse both candidates and decide which one doesn't have a face at the side I need. I take that one and go through connecting edges till closing the new wire.

That approach, after a lot of trial and error, seems to work fine most of the time. However, it should also detect situations where none of the candidate edges can be used (the new wire is inside the closed one), but it finds a usable one anyway producing overlapped faces at the end.

It's the second day trying to get that right, but it's not working in all cases.

Maybe some of you have a nicer way to achieve what I want, or could at least shed some light on me about this whole thing.

Thanks in advance.

Paul Jimenez's picture

Nevermind. That approach had serious flaws. I tried another one more like 'brute force', and it seems to work as expected every time.

Thanks anyway for those who took the time to read this.