[vtk-developers] maybe can add a function about vtkSmartPointer New

天亮damody t1238142000 at gmail.com
Sat Dec 25 04:49:23 EST 2010


this mail only about my customs use vtkSmartPointer

I think many people declare vtkSmartPointer<vtkXXX> like this

vtkSmartPointer<vtkPoints>   m_points;
vtkSmartPointer<vtkFloatArray>        m_volcolors;
vtkSmartPointer<vtkUnsignedCharArray>        m_colors;
vtkSmartPointer<vtkPolyData>    m_polydata;
vtkSmartPointer<vtkOrientationMarkerWidget>    m_AxesWidget;

"new" vtkobject like this

m_points = vtkSmartPointer<vtkPoints>::New();
m_volcolors = vtkSmartPointer<vtkFloatArray>::New();
m_colors = vtkSmartPointer<vtkUnsignedCharArray>::New();
m_polydata = vtkSmartPointer<vtkPolyData>::New();
m_AxesWidget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();

but I often use template function like this
to "new" vtkobject

template <class T>
void vtkSmartNew(vtkSmartPointer<T>& Ptr)
    Ptr = vtkSmartPointer<T>::New();
    assert(Ptr.GetPointer() != 0);

vtkSmartPointer<vtkPoints>   m_points;

because I think vtkSmartPointer<vtkOrientationMarkerWidget>
is so long, I use ctrl+c ctrl+v so many times to copy type

I think maybe vtk can provide some function like this on "vtkSmartPointer.h"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20101225/1498bfef/attachment.html>

More information about the vtk-developers mailing list