[vtk-developers] vtkNew in examples (or auto?)

Bill Lorensen bill.lorensen at gmail.com
Thu Jun 22 13:09:07 EDT 2017


I'm not sure what you mean by auto-fying



On Thu, Jun 22, 2017 at 1:07 PM, Elvis Stansvik
<elvis.stansvik at orexplore.com> wrote:
> 2017-06-22 19:01 GMT+02:00 Bill Lorensen <bill.lorensen at gmail.com>:
>> I prefer vtkSmartPointer because it can be used like any other vtk
>> pointer. No need for a GetPointer() is some cases. The example writer
>> is free to use vtkSmartPointer or vtkNew. But I would leave them as
>> there are.
>
> Right, that's a valid point. But how about auto-fying the
> declarations? (but keep using vtkSmartPointer)
>
> My motivation is that when reading an example, I'm often squinting to
> find the variable names in the declarations, wedged in there somewhere
> between all those type names and angle brackets. Especially as the
> lines are often broken due to running long.
>
>>
>>
>> Other cleanup's sound great. I've also started using vtkNamedColors
>> instead of setting float values.
>
> Great.
>
> Elvis
>
>>
>> On Thu, Jun 22, 2017 at 12:57 PM, Elvis Stansvik
>> <elvis.stansvik at orexplore.com> wrote:
>>> Hi all,
>>>
>>> How about a refactor of the examples to use vtkNew instead of
>>> vtkSmartPointer (where it makes sense)?
>>>
>>> E.g.
>>>
>>>   vtkNew<vtkActor> actor;
>>>   actor->SetMapper(mapper);
>>>
>>>   vtkNew<vtkRenderer> renderer;
>>>   renderer->AddActor(actor);
>>>
>>> instead of
>>>
>>>   vtkSmartPointer<vtkActor> actor =
>>>     vtkSmartPointer<vtkActor>::New();
>>>   actor->SetMapper(mapper);
>>>
>>>   vtkSmartPointer<vtkRenderer> renderer =
>>>     vtkSmartPointer<vtkRenderer>::New();
>>>   renderer->AddActor(actor);
>>>
>>> I think it would help with the readability of the examples. Or are
>>> there other reasons for the prevalent use of vtkSmartPointer?
>>>
>>> Another option would be to use auto, e.g.
>>>
>>>   auto actor = vtkSmartPointer<vtkActor>::New();
>>>
>>> Also, would anyone mind if I did a little naming cleanup, mostly
>>> things like "renwin" -> "window" and "iren" -> "interactor"? Those
>>> abbreviations are not that bad, but I think it's better in examples to
>>> spell out the variables in proper English.
>>>
>>> If there are no objections, I could try to prepare an MR when time
>>> permits. If so, vtkNew, or auto?
>>>
>>> Elvis
>>> _______________________________________________
>>> 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:
>>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>>
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com



-- 
Unpaid intern in BillsBasement at noware dot com


More information about the vtk-developers mailing list