[vtk-developers] RFC: STL algos and C++11 for-range syntax with vtkDataArrays

Elvis Stansvik elvis.stansvik at orexplore.com
Tue Nov 13 13:53:45 EST 2018


Den tis 13 nov. 2018 kl 18:25 skrev Allie Vacanti <allison.vacanti at kitware.com>:
>
> On Fri, Nov 9, 2018 at 8:45 AM David E DeMarle <dave.demarle at kitware.com> wrote:
>>
>> +1 for the idea of converting vtk collections into stl conventions.
>
>
> et voila:
>
> https://gitlab.kitware.com/vtk/vtk/commit/dd3fce7815ff2285a7b93e2ee5a642cdcd066626?merge_request_iid=4826
>
> vtkCollection *collection = ...;
> for (auto item : vtk::Range(collection))
> {
>   // item is a vtkObject*.
> }
>
> vtkRendererCollection *renCollection = ...;
> for (auto item : vtk::Range(renCollection))
> {
>   // item is a vtkRenderer*. Type deduction works for all
>   // collection types that define a GetNextItem() method
>   // with a specialized type.
> }
>
> This design leaves the door open for other usages of vtk::Range(iterable) in the future. vtkCellIterators come to mind...

Wow, all-inclusive service at this place! In the same MR even. Let me
see, what should I think up next.. :)

Elvis

>
> Allie
>
>>
>> On Fri, Nov 9, 2018, 6:49 AM Todd via vtk-developers <vtk-developers at public.kitware.com> wrote:
>>>
>>> Nice blog.
>>>
>>> On 10 Nov 2018 12:00 a.m., Allie Vacanti <allison.vacanti at kitware.com> wrote:
>>>
>>> On Fri, Nov 9, 2018, 2:07 AM Elvis Stansvik <elvis.stansvik at orexplore.com wrote:
>>>
>>> Any plans for something similar for vtkCollection*?
>>>
>>>
>>> Not currently, but that would be a very useful feature indeed. I think it'd be more than worthwhile to add a template that just translates the VTK iteration convention (InitTraversal, GoToNextItem, IsDoneWithTraversal) to a set of STL iterators/range objects. This would allow it to work with quite a few different iterables in VTK.
>>>
>>> It'd have a similarly usage as the array iterators:
>>>
>>> vtk[...]Collection *myCollection = ...;
>>> for (auto item : vtk::Range(myCollection)) { ... }
>>>
>>> I'll put this on my list to look at in my spare cycles.  Good suggestion!
>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>
>>> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> https://public.kitware.com/mailman/listinfo/vtk-developers
>>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtk-developers
>


More information about the vtk-developers mailing list