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

Remove Face - Attempted divide by 0 #42

Open petrasvestartas opened 7 years ago

petrasvestartas commented 7 years ago

Hi,

I would like to ask how to properly delete face from planktonMesh.

When I do it like this I get error for division by zero. I just want to remove one first face from planktonMesh.

question

pearswj commented 7 years ago

I managed to reproduce the "divide by zero" error, so it looks like there's a bug...! As a workaround, if you compact the mesh after removing the face, the "divide by zero" error disappears.

Note: compacting the data structure might change all the indexing! For example, if by removing the face there are now vertices that aren't connected to anything, they will be removed and the list of vertices will shrink, changing all the vertex indices. All the other faces/halfedges will be updated to reflect the new indexing, but you might have some external code that relies on the original indexing...

PlanktonMesh pm = x.ToPlanktonMesh();
pm.Faces.RemoveFace(0);
pm.Compact(); // purges any unreferenced vertices, faces and halfedges
A = pm;

Note to self: this grasshopper definition reproduces the bug... remove_face_bug.gh.zip

planUnd commented 6 years ago

Same happens when mergin Faces...