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

Elvis Stansvik elvis.stansvik at orexplore.com
Thu Jun 22 12:57:24 EDT 2017


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


More information about the vtk-developers mailing list