Quantcast

Re-using smart pointers as both input and output

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re-using smart pointers as both input and output

zmurphy
I'm in a situation where I would like to do something like this:

vtkSmartPointer<vtkAlgorithmOutput> output = SomeFunctionThatCreatesTheSmartPointer()

output = SomeFunctionThatTakesAndCreatesASmartPointer(output)

where the second function is something along the lines of this:

vtkSmartPointer<vtkAlgorithmOutput> SomeFunctionThatCreatesASmartPointer( vtkSmartPointer<vtkAlgorithmOutput> input)
{
    vtkSmartPointer<vtkDelaunay3D> delaunay = vtkSmartPointer<vtkDelaunay3D>::New();
    delaunay->SetInputConnection(input);

    //Do other things here...

    return delaunay->GetOutputPort();
}

Is it okay to reassign a smart pointer like that after using it as the input to an algorithm?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re-using smart pointers as both input and output

Utkarsh Ayachit

Is it okay to reassign a smart pointer like that after using it as the input
to an algorithm?

Yes. Except you can't do `delaunay->SetInputConnection(input)`, you'll need to use `delaunay->SetInputDataObject(input);`.

Utkarsh
 

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Loading...