VTK
9.4.20241225
|
A utility structure that can be used as a base for implicit array backend that relies on a vtkDataObject. More...
#include <vtkDataObjectImplicitBackendInterface.h>
Public Member Functions | |
vtkDataObjectImplicitBackendInterface (vtkDataObject *dataobject, const std::string &arrayName, int attributeType) | |
virtual | ~vtkDataObjectImplicitBackendInterface () |
ValueType | operator() (vtkIdType idx) const |
Get the value at given index. | |
Protected Member Functions | |
void | OnDataObjectDeleted (vtkObject *caller, unsigned long eventId, void *calldata) |
Callback to call when DataObject is destroyed. | |
virtual ValueType | GetValueFromDataObject (vtkIdType idx) const =0 |
Return the actual value for given index. | |
vtkDataObject * | GetDataObject () |
Get the internal dataobject. | |
A utility structure that can be used as a base for implicit array backend that relies on a vtkDataObject.
Some backend need to use the vtkDataObject itself to compute the array value. This leads to a circular dependency, as the array is itself contained inside the vtkDataObject. To break this dependency and to avoid issues with memory management, those backends may inherits from this vtkDataObjectImplicitBackendInterface.
vtkDataObjectImplicitBackendInterface observes the DeleteEvent of the vtkDataObject. When raised, the backend instantiates the whole array in memory before the actual dataobject deletion.
The constructor requires an ArrayName and its Association in order to retrieve the whole array to initialize the cache.
When inheriting from vtkDataObjectImplicitBackendInterface, operator()
should not be defined by the child class. Only GetValueFromDataObject()
should be overriden to return the expected value.
Once the vtkDataObject is deleted, the parent class handle the memory allocation and initialization. Then operator()
uses the allocated memory instead of calling the custom GetValueFromDataObject().
Example of usage from vtkCountFaces:
Definition at line 64 of file vtkDataObjectImplicitBackendInterface.h.
vtkDataObjectImplicitBackendInterface< ValueType >::vtkDataObjectImplicitBackendInterface | ( | vtkDataObject * | dataobject, |
const std::string & | arrayName, | ||
int | attributeType | ||
) |
|
virtual |
ValueType vtkDataObjectImplicitBackendInterface< ValueType >::operator() | ( | vtkIdType | idx | ) | const |
Get the value at given index.
Entry point for vtkImplicitArray to uses the backend.
This delegates to GetValueFromDataObject when DataObject is not nullptr, and uses a local Cache otherwise. Should not be reimplemented by subclasses.
|
protected |
Callback to call when DataObject is destroyed.
Internally call InitializeCache.
|
protectedpure virtual |
Return the actual value for given index.
Should be reimplemented by any subclass.
|
inlineprotected |
Get the internal dataobject.
Definition at line 96 of file vtkDataObjectImplicitBackendInterface.h.