vtkGeometryFilter not passing vtkStringArray

Hi !
Correct me if I’m wrong but it seems that in the latest version of VTK the vtkGeometryFilter behavior has changed and a vtkStringArray in source is no more passed to the output. It seems that the array is well created but is empty.
For information I managed to solve my problem using PassThroughCellIdsOn and reconstructing the StringArray after filter.
Thks !

Do you happen to know if you string array had a particular attribute type in vtkDataSetAttributes? There’s no fast way to now that. You can do a for loop on the attribute types:

vtkStringArray* array = GetStringArray(); // assuming you have a pointer on you array
vtkDataSetAttributes* dsa = GetDataSetAttributes(); // can be point data or cell data
for (int attr = 0; attr < vtkDataSetAttributes::NUM_ATTRIBUTES; ++attr)
  if (array == dsa->GetAbstractAttribute(attr))
    std::cout << "I am a " << vtkDataSetAttributes::GetAttributeTypeAsString(attr) << std::endl;

If it is an attribute other than global ids, it might have vanished after the filter given its current state.

Thank you for your reply. But am not sure to understand well :sweat_smile:
I work under python so the code is slightly different but I’m quite sure that the problem was not present in previous vtk version. And I didn’t do anything special with the datasetattributes…

This filter has been touched a bit in the past year. I quickly looked through the code and it occurred that attribute types could have been an issue, hence my previous post.

Can you share you data set?

No problem, how can I share a data set?

I’m being told you should be able to share files. There’s an upload button when you write a message.

ah ok i’m afraid that it will be very complicated for me to share all the relevant code… :confused:
maybe I should try with a simple example
in fact i didn’t understand well your datasetattribute code :sweat_smile: do you know what it would be in python ?

I think you can replace all instances of vtkDataSetAttributes:: by vtkDataSetAttributes. and it should work. If your data is cell data, then replace the line GetDataSetAttributes by cellData = myDataSet.GetCellData(). And replace the arrows -> by a point ..

ok I was not aware of those “special” attributes like GlobalIds.

My celldata have no attributes:

vtkCellData (0000024E12116250)
  Debug: Off
  Modified Time: 109155
  Reference Count: 2
  Registered Events:
    Registered Observers:
      vtkObserver (0000024E12DF02A0)
        Event: 33
        EventName: ModifiedEvent
        Command: 0000024E12261B50
        Priority: 0
        Tag: 1
  Number Of Arrays: 9
  Array 0 name = ElmsID
  Array 1 name = ElmsType
  Array 2 name = ElmsPID
  Array 3 name = ElmsInclude
  Array 4 name = PIDColors
  Array 5 name = IncludeColors
  Array 6 name = ElmsMID
  Array 7 name = MIDColors
  Array 8 name = keep
  Number Of Components: 15
  Number Of Tuples: 505
  Copy Tuple Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )
  Interpolate Flags: ( 1 1 1 1 1 1 0 1 1 1 1 )
  Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )
  Scalars: (none)
  Vectors: (none)
  Normals: (none)
  TCoords: (none)
  Tensors: (none)
  GlobalIds: (none)
  PedigreeIds: (none)
  EdgeFlag: (none)
  Tangents: (none)
  RationalWeights: (none)
  HigherOrderDegrees: (none)

My string array is the “ElmsType” array. I tried to play with SetActiveGlobalIds but this doesn’t seems to work with a stringarray (or maybe with my string array because several cells have the same string value). I have been able to set the “ElmsID” array as GlobalIds but this didn’t change the behavior of the filter after.

Hi Yohann and Flagada. I had the same issue. I tracked down a bit where the copying of arrays happens in vtkGeometryFilter:

// Finally we can composite the output topology.
ArrayList cellArrays;
outCD->CopyAllocate(inCD, numCells);
cellArrays.AddArrays(numCells, inCD, outCD, 0.0, false);

This call uses the vtkArrayListTemplate.h which is adding the arrays. However, that is set up for vtkDataArray. vtkStringArray is derived directly from vtkAbstractArray and not from vtkDataArray. My guess is that that is causing the vtkStringArray to not be copied across as the vtkArrayListTemplate code for adding arrays contains this:

iArray = vtkArrayDownCast(inPD->Data[i]);
oArray = vtkArrayDownCast(outPD->Data[outPD->TargetIndices[i]]);

if (iArray && oArray && !this->IsExcluded(oArray) && !this->IsExcluded(iArray))
{  ... }

This will fail for vtkStringArray.

I’m not knowledgeable enough with the new array structures to know how to fix this and have reverted back to using the VTK8 implementation.

PS. sorry if format of copied code is not in courier style. Not sure how to do that yet.

Have you tried vtkDataSetSurfaceFilter? It is quite similar to vtkGeometryFilter… it might be better than reverting to an earlier version.

I’ll add the string array issue wrt vtkGeometryFilter on my list of things to clean up.

Hi Will,
Thanks for the suggestion. Since I’m using the vtkGeometry in various places in my software for conversion from unstructured data to PolyData I hadn’t considered the switch to vtkDataSetSurfaceFilter and have not tested it. Reverting to older version is not ideal but let’s me quickly change to the newer version once it is fixed again.