triangle icon indicating copy to clipboard operation
triangle copied to clipboard

How to use the 'regions' argument in the 'triangulate()' function?

Open QuentinRoyerDev opened this issue 4 years ago • 5 comments

In order to pass original attribute data of initals polygons to each generated triangle, i would like to know how to use the 'regions' argument in the 'triangulate()' function ? I haven't found any tips or examples.

QuentinRoyerDev avatar Mar 11 '20 15:03 QuentinRoyerDev

I figured out how to do this for a project of my own today. See https://gist.github.com/mzucker/b0846f304b48702ff2530294134ae879

Interestingly, I needed to monkey-patch the triangle Python library, otherwise I got a KeyError at https://github.com/drufat/triangle/blob/master/triangle/tri.py#L67

Adding the extra key/value pair ('triangleattributelist', 'triangle_attributes') to the terms at https://github.com/drufat/triangle/blob/master/triangle/tri.py#L3 would fix this – @drufat would you consider adding it?

Example input and output images attached.

tri_input

tri_output

mzucker avatar Mar 15 '20 23:03 mzucker

@mzucker Thanks for the contribution. I would be happy to merge it. Could you add your example to the documentation as well?

drufat avatar Mar 16 '20 00:03 drufat

Created a pull request, let me know if it passes muster. This was my first time editing Sphinx and my first pull request on github in a very long time, if not ever.

mzucker avatar Mar 16 '20 15:03 mzucker

That's exactly what I was hoping for. Thank you very much for your responses.

QuentinRoyerDev avatar Mar 19 '20 09:03 QuentinRoyerDev

Glad to help!

mzucker avatar Mar 19 '20 12:03 mzucker