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

Bill Lorensen bill.lorensen at gmail.com
Thu Jun 22 13:01:20 EDT 2017


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.


Other cleanup's sound great. I've also started using vtkNamedColors
instead of setting float values.

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


More information about the vtk-developers mailing list