[vtk-developers] vtkFileOutputWindow syntax
David Cole
david.cole at kitware.com
Tue Jun 12 13:23:02 EDT 2012
On Tue, Jun 12, 2012 at 7:20 AM, David Doria <daviddoria at gmail.com> wrote:
> The documentation for this class says:
> http://www.vtk.org/doc/nightly/html/classvtkFileOutputWindow.html#details
>
> "To use this class, instantiate it and then call SetInstance(this)."
>
> It seems like you have to do this:
>
> vtkSmartPointer<vtkFileOutputWindow> fileOutputWindow =
> vtkSmartPointer<vtkFileOutputWindow>::New();
> fileOutputWindow->SetFileName( "output2.txt" );
> fileOutputWindow->SetInstance( fileOutputWindow );
>
> If you are supposed to call SetInstance(this), why not just set that
> internally and not require a SetInstance call at all?
>
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>
SetInstance is a *static* method. It keeps track of a single instance of
(possibly many) vtkOutputWindow objects.
You do not necessarily want to call SetInstance every time you create a
vtkOutputWindow, therefore you have to call it manually/intentionally when
you actually do want to record a specific instance as "*the* output
window"...
This is a very common occurrence when following the Singleton pattern.
HTH,
David C.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20120612/13bda521/attachment.html>
More information about the vtk-developers
mailing list