Thank you so much for working on this, Paul, I truly appreciate your support!
I was able to run your code and get some results. I noted that the final mask output varies based on the order of the coordinates.
Specifically, I tested it on a case where my points were laying on a Z plane (so the Z coordinate is fixed for all the points).
I tried three different scenarios:
1) CASE 1: the coordinates in the input file were exactly as I was given (i.e., in the order that the drawer traced them on ImageJ, in this case it was clockwise. In my project, the tracer will trace the coordinates either clockwise or counterclockwise). I just copied the coordinates of the first point at the end of the file as you suggested for your code.
292 297 80
294 298 80
296 297 80
298 294 80
297 292 80
297 292 80
294 292 80
292 292 80
292 294 80
292 297 80
2) CASE 2: the X coordinates were sorted from low to high, and for each X, the Y coordinates were sorted from low to high.
292 297 80
292 292 80
292 294 80
294 292 80
294 298 80
297 292 80
297 292 80
296 297 80
298 294 80
292 297 80
3) CASE 3: the Y coordinates were sorted from low to high, and for each Y, the X coordinates were sorted from low to high.
292 292 80
294 292 80
297 292 80
297 292 80
292 294 80
298 294 80
292 297 80
296 297 80
294 298 80
292 292 80
The results from the 3 cases are attached. To "fill" a convex polygon your program should have the X coordinates sorted from low to high, and, for each X coordinate, the Y coordinates should also be sorted.
The result from case n.2 was indeed the one that fitted my goal the best, although not exactly. As you can see in the attached file "goal", I would like to have segmented also the voxels reported in green.
Anyway, thank you so much for making this program. I will try to work on it to achieve my final goal. Thank you for your help on this, really appreciate it.
Please let me know if you further update your program or if you have any suggestion. Thank you!
Giuseppe