VTK  9.4.20241225
Public Member Functions | Protected Member Functions | List of all members
vtkDataObjectImplicitBackendInterface< ValueType > Struct Template Referenceabstract

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.
 
vtkDataObjectGetDataObject ()
 Get the internal dataobject.
 

Detailed Description

template<typename ValueType>
struct vtkDataObjectImplicitBackendInterface< ValueType >

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.

Inheritance

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:

class vtkNumberOfFacesBackend : public vtkDataObjectImplicitBackendInterface<vtkIdType>
{
vtkNumberOfFacesBackend(vtkDataObject* input, const std::string& name, int type)
{}
~vtkNumberOfFacesBackend() override = default;
vtkIdType GetValueFromDataObject(const vtkIdType index) const override
{
return this->DataObject->GetCell(index)->GetNumberOfFaces();
}
};
general representation of visualization data
A utility structure that can be used as a base for implicit array backend that relies on a vtkDataObj...
int vtkIdType
Definition vtkType.h:315

Definition at line 64 of file vtkDataObjectImplicitBackendInterface.h.

Constructor & Destructor Documentation

◆ vtkDataObjectImplicitBackendInterface()

template<typename ValueType >
vtkDataObjectImplicitBackendInterface< ValueType >::vtkDataObjectImplicitBackendInterface ( vtkDataObject dataobject,
const std::string &  arrayName,
int  attributeType 
)

◆ ~vtkDataObjectImplicitBackendInterface()

template<typename ValueType >
virtual vtkDataObjectImplicitBackendInterface< ValueType >::~vtkDataObjectImplicitBackendInterface ( )
virtual

Member Function Documentation

◆ operator()()

template<typename ValueType >
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.

◆ OnDataObjectDeleted()

template<typename ValueType >
void vtkDataObjectImplicitBackendInterface< ValueType >::OnDataObjectDeleted ( vtkObject caller,
unsigned long  eventId,
void *  calldata 
)
protected

Callback to call when DataObject is destroyed.

Internally call InitializeCache.

◆ GetValueFromDataObject()

template<typename ValueType >
virtual ValueType vtkDataObjectImplicitBackendInterface< ValueType >::GetValueFromDataObject ( vtkIdType  idx) const
protectedpure virtual

Return the actual value for given index.

Should be reimplemented by any subclass.

◆ GetDataObject()

template<typename ValueType >
vtkDataObject * vtkDataObjectImplicitBackendInterface< ValueType >::GetDataObject ( )
inlineprotected

Get the internal dataobject.

Definition at line 96 of file vtkDataObjectImplicitBackendInterface.h.


The documentation for this struct was generated from the following file: