mmorse1217 / lean-vtk

A minimal VTK file writer for triangle, quad, hex and tet meshes in 2D and 3D. Only C++ standard lib as dependencies.
MIT License
47 stars 14 forks source link

Add ability to write integer cell data #3

Open nDimensionalSpace opened 2 years ago

nDimensionalSpace commented 2 years ago

I think I will just extrapolate the definition of the active array in a completely consistent manner with what currently exists, with the exception that I will add an "define_active_scalar_array" (and its analogues), so that the user doesn't need to just settle for the most recently defined scalar/vector/tensor/* array being the active one (which will be the default behavior), or to be forced to add the cell data in a particular order.

mmorse1217 commented 2 years ago

I think it is cleaner to template the add_xxx_field functions on the data type, and instantiate add_xxx_field<int> and add_xxx_field<double> in the cpp. I'll try to add this when I can.

What do you mean by "active" array? current_vector_point_data_, etc? Do you think this extra functionality is needed? Changing this variable will probably break the current behavior.

nDimensionalSpace commented 2 years ago

Meh, no worries, I can do the templating.

Yes, current_scalar/vector_pointdata. Its not totally clear what active arrays are used for, but I did find this at https://kitware.github.io/vtk-js/api/Common_DataModel_DataSetAttributes.html:

"This adds to vtkFieldData the ability to pick one of the arrays from the field as the currently active array for each attribute type. In other words, you pick one array to be called “THE” Scalars, and then filters down the pipeline will treat that array specially. For example vtkContourFilter will contour “THE” Scalar array unless a different array is asked for.",

as well as some other discussions, like https://discourse.paraview.org/t/have-paraview-use-the-active-scalars-as-the-display-coloring/1037. So it seems like the active array will be the default array for a given data array type, in at least some contexts. As such, I think yes, it makes sense to allow users to define the default scalars/tensors/whatever.