nmwsharp / geometry-central

Applied 3D geometry in C++, with a focus on surface meshes.
https://geometry-central.net
MIT License
1.01k stars 141 forks source link

quadric error simplification should avoid creating triangular ravioli #131

Open lfyMeta opened 1 year ago

lfyMeta commented 1 year ago

Hi, I was running the quadric error simplification on meshes with multiple connected components and it aborts because it encounters degree 2 vertices in the interior (the face indexing { 0, 1, 2, 0, 2, 1 } situation). Should it just avoid getting into that situation in the first place, especially if we started with something that didn't have those?

nmwsharp commented 1 year ago

Are you saying that it throws an exception or something? Or just that the algorithm stops processing?

My initial instinct is that a {(0,1,2),(0,2,1)} mesh is an okay configuration. It's the smallest closed, manifold mesh. Generally geometry-central follows the policies of allowing these configurations even if they are slightly weird. If it's a big practical issue for you, I'd be happy to accept a PR with a flag to disallow such configurations.

lfyMeta commented 1 year ago

Probably both, but my main issue is that the quadric error simplification algorithm currently throws an exception in that case (because a vertex has degree 2); it’s in collapseEdgeTriangular()

I would actually be fine with processing the simplest closed manifold in my application but I’m not sure if that was also the intent of collapseEdgeTriangular()