meshmash / Plankton

A C# half-edge mesh data structure, and components for using this in Grasshopper/Rhino
http://meshmash.github.io/Plankton
GNU Lesser General Public License v3.0
216 stars 66 forks source link

Split edges not identifying as boundary (inconsistently) #37

Open camnewnham opened 8 years ago

camnewnham commented 8 years ago

Hi, Thankyou for this fantastic library - it has been a pleasure to use and appears simple but powerful.

I ran into some issue splitting boundary edges - whereas the vertices are not correctly returning whether they are boundary or not. It seems to be inconsistent (does not apply to all boundary edges on a mesh).

It seems to be that the AdjacentFace() of a split edge may be incorrectly stored after a SplitEdge() - however as I am still learning the HE structure I can not confirm. The outgoing edge structure appears correct (pictured).

Note that not all boundary vertices are marked (black dots), but the outgoing HE structure appears correct - hence the suspicion of adjacentfaces being stored incorrectly. However as SplitEdge() appears to copy the required integer with the below, I was unsure where this occurred. this[new_halfedge2].AdjacentFace = this[pair].AdjacentFace;

For my purposes I have been able to solve this by changing the VertexList.IsBoundary function to:

public bool IsBoundary(int index)
{
            int h = this[index].OutgoingHalfedge;

            int hp = _mesh.Halfedges.GetPairHalfedge(h);

            return (h <= -1 || _mesh.Halfedges[h].AdjacentFace == -1) || (hp < -1 || _mesh.Halfedges[hp].AdjacentFace == -1);
        }

This solves my immediate issue, as pictured here (note correctly identified boundary vertices:

Anyhow - just thought I would let you know - perhaps you can shed more light on this for me :)

Thanks CN