[vtkusers] Cast vtkTypedDataArrayIterator to vtkArrayIterator?

David Lonie david.lonie at kitware.com
Tue Oct 28 10:30:28 EDT 2014


Hi Lars,

The vtkArrayIterator class is very different from the
vtkTypedDataArrayIterator. See the APIs in vtkTypedDataArrayIterator.h and
vtkArrayIteratorTemplate.h. The former is an STL style iterator, while the
latter uses a custom API for retrieving data.

At this point, you'd need to write a new iterator implementation that
matches the vtkArrayIterator API and somehow shoehorn some extra logic into
vtkArrayIteratorTemplateMacro in vtkSetGet.h. This would be hacky, and to
properly fix this the writer would likely need to be rewritten, since the
vtkArrayIterator plumbing seems intrinsically tied to the
vtkArrayIteratorTemplate class, which relies heavily on the horrible
vtkDataArray::GetVoidPointer method.

Is ascii mode required for your use case? If not, it would likely be much
simpler to just use binary mode.

Hope this helps,
Dave

On Tue, Oct 28, 2014 at 4:20 AM, Lars Bilke <lars.bilke at ufz.de> wrote:

> I have a similar implementation of a vtkMappedDataArray as in
>
> vtkCPExodusIIResultsArrayTemplate (
> https://github.com/Kitware/VTK/blob/master/IO/Exodus/vtkCPExodusIIResultsArrayTemplate.txx
> ).
>
> The mapped data array is part of a vtkMappedUnstructuredGrid as in
>
>
> https://github.com/gahansen/Albany/blob/master/src/disc/catalyst/Albany_Catalyst_Grid.hpp
>
> and so on. It works fine. Now I try to write the unstructured grid to a
> file which also works fine in binary mode. But when I switch the
> vtkXMLUnstructuredGridWriter to ascii mode the member vtkArrayIterator*
> NewIterator() of my vtkMappedDataArray needs to be implemented. I did not
> found an example of such an implementation. For now I came up with this:
>
> template <class Scalar> vtkArrayIterator*
> VtkMappedElementDataArrayTemplate<Scalar>::NewIterator()
> {
>         vtkTypedDataArrayIterator<Scalar> tdaBegin =
> vtkTypedDataArray<Scalar>::FastDownCast(this)->Begin();
>         return tdaBegin;
> }
>
> But compilation fails with
>
> error: no viable conversion from 'vtkTypedDataArrayIterator<unsigned int>'
> to 'vtkArrayIterator *‘
>
> If you want to have a look at my code:
>
> https://github.com/ufz/ogs/tree/master/InSituLib
>
> Thanks,
> Lars
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141028/b97196ac/attachment.html>


More information about the vtkusers mailing list