vtkPolyData : add attribute/annotation

Hi,

I wish to record some meta data regarding the source information that goes into the creation of a given vtkPolyData (for versioning/history/tracking purpose)

Is there some way to add such sting/integer information as institution, author, date-time ?

Cheers

Hi @Nicholas_Yue

Usually, FieldData are used for that purpose.

Best,

Thank you @mwestphal, it worked.

vtkNew<vtkFieldData> source_geometry_fielddata;

vtkNew<vtkStringArray> source_geometry_filepath_array;
source_geometry_filepath_array->SetName("src_path");
source_geometry_filepath_array->SetNumberOfComponents(1);
source_geometry_filepath_array->InsertNextValue(vtk_file);
source_geometry_fielddata->AddArray(source_geometry_filepath_array);

std::string sha1;
if (computeFileSHA1(vtk_file, sha1)) {
	vtkNew<vtkStringArray> source_sha1_array;
	source_sha1_array->SetName("src_sha1");
	source_sha1_array->SetNumberOfComponents(1);
	source_sha1_array->InsertNextValue(sha1);
	source_geometry_fielddata->AddArray(source_sha1_array);
}

source->SetFieldData(source_geometry_fielddata);

and it shows up nicely in ParaView too
image

1 Like