pyvista / fast-simplification

Fast Quadratic Mesh Simplification
https://pyvista.github.io/fast-simplification/
MIT License
110 stars 15 forks source link

Keeping track of the history of edge's collapses #6

Closed Louis-Pujol closed 1 year ago

Louis-Pujol commented 1 year ago

I open this PR to propose a new feature for fast-simplification: the ability to track the history of successive collapses that occur during the decimation process, as mentioned here

The collapses history is encoded as a (n_collapses, 2) integer array. If collapses[j] = [i0, i1], it indicates that the (j+1)th collapsed edge was (i0, i1), with the convention that the index of the point resulting from the collapse is i0.

In the Python interface within simplify.py, I have made modifications to facilitate access to collapses. In the simplify() function, I have added an argument called return_collapses (defaulting to False). When return_collapses is set to True, the output of simplify will be (points, triangles, collapses)instead of just (points, triangles). Additionally, in simplify_mesh(), collapses are integrated into the output mesh as a field_data.

I have also included tests in test_simplify.py to ensure the correctness of this feature. Specifically, we are verifying that the number of points before decimation equals the number of points after decimation plus the number of collapses.