Generate array with partial pixel information from shapes

Can I create a polygon or shape of some sort in VTK and then get access to the raw data such that I can convert it to a 2D or 3D array of type float or double?
When I do this I would like to also save partial pixel information. I would like to store the objects as a mask where 1 is inside and 0 is outside. If the shape covers half a cell at the edge it would be 0.5 in that cell.
I can do this with basic shapes in regular C++, but I would like to see if it can be done with more complex shapes like what VTK can create or for example CAD models read into VTK.
A more concrete example would be as follows:

  1. Create a circle storing center and radius.
  2. Create a VTK circle using that data.
  3. Convert the VTK circle to a 2D array with 1 where the circle covers and partial values around the edge.
  4. Do things with that array which will then modify the radius.
  5. Rinse and repeat.

Convert the VTK circle to a 2D array with 1 where the circle covers and partial values around the edge.

This is basically a screenspace projection, could be done with a dedicated shader unless something already exists out of the box for that.

maybe @Timothee_Chabat or @ken-martin knows more.

So you could do it using some sort of rendering approach as @mwestphal mentioned. It would take a few steps but could be done. But you may be thinking of VTK’s implicit modelling classes that allow you to define implicit functions and then sample them onto geometry (such as an 2d array). See vtkImplicitFunction and vtkImplicitModeller There are some examples here https://kitware.github.io/vtk-examples/site/Cxx/#implicit-functions-and-iso-surfaces