Sizes that VTK_SIZEHINT cannot hint
The new vtkCell3D API has methods which cannot be used from the wrappers, because VTK_SIZEHINT
cannot hint the number of faceIds
, edgeIds
, or pts
that the methods return:
vtkIdType GetFaceToAdjacentFaces(vtkIdType faceId, const vtkIdType*& faceIds);
vtkIdType GetPointToIncidentEdges(vtkIdType pointId, const vtkIdType*& edgeIds);
vtkIdType GetPointToIncidentFaces(vtkIdType pointId, const vtkIdType*& faceIds);
vtkIdType GetPointToOneRingPoints(vtkIdType pointId, const vtkIdType*& pts);
The only new method that can accept a hint is GetEdgeToAdjacentFaces()
, since the number of faceIds is always '2'
void GetEdgeToAdjacentFaces(vtkIdType edgeId, const vtkIdType*& faceIds)
+ VTK_SIZEHINT(faceIds, 2);
To fix this issue, VTK_SIZEHINT
could be modified so that it accepts a keyword to indicate that the method's return value is to be used as the size:
vtkIdType GetFaceToAdjacentFaces(vtkIdType faceId, const vtkIdType*& faceIds)
+ VTK_SIZEHINT(faceIds, RETURN_VALUE);
Alternatively, in order to avoid potential name conflicts, some kind of punctuation could be used instead:
vtkIdType GetFaceToAdjacentFaces(vtkIdType faceId, const vtkIdType*& faceIds)
+ VTK_SIZEHINT(faceIds, -);
though I don't know what punctuation best signifies "use the return value".
Edit: I definitely can't use -
to signify 'return value', since it cannot be used as an identifier in a mathematical expression. But I can use '_', which is a valid identifier. E.g. VTK_SIZEHINT(x, _)
or VTK_SIZEHINT(x, 2*_)
. Assuming that nobody uses '_' as a parameter name...
Edit 2: With the hints in place, the wrapper's "reference" type can be used to call these methods from Python:
from vtkmodules.vtkCommonCore import reference
faceIds = reference(()) # create an empty tuple reference
cell.GetPointToIncidentFaces(pointId, faceIds);
print(faceIds)
(1, 2, 3)
which is equivalent to this C++ code:
const vtkIdType* faceIds = nullptr;
vtkIdType n = cell->GetPointToIncidentFaces(pointId, faceIds);