Possibly a dumb question, but...
Matthew Hall
mahall at math.uiuc.edu
Wed Sep 29 00:46:39 EDT 1999
>From owner-vtkusers at gsao.med.ge.com Tue Sep 28 20:01:25 1999
>X-Authentication-Warning: gsao.med.ge.com: mjordomo set sender to owner-vtkusers at gsao.med.ge.com using -f
>From: Lawrence Werner <rendawg at plinet.com>
>To: "'VTK Mailing list'" <vtkusers at gsao.med.ge.com>
>Subject: Possibly a dumb question, but...
>Date: Tue, 28 Sep 1999 19:04:10 -0600
>MIME-Version: 1.0
>Content-Transfer-Encoding: 8bit
>X-MIME-Autoconverted: from quoted-printable to 8bit by gsao.gso.med.ge.com id TAA21289
>
>Is there any way to get the output of a filter and copy it to a separate object so you can then delete the filter and use the newly created object instead?
>
>Like for example...
>
>vtkPolyData* pSourceData = vtkPolyData::New();
>vtkTriangleFilter* pTriFilter = vtkTriangleFilter::New();
>vtkPolyData* pOutData = vtkPolyData::New();
>vtkPolyDataMapper* pMapper = vtkPolyDataMapper::New();
>vtkActor* pActor = vtkActor::New();
>
>pTriFilter->SetInput( pSourceData );
>////////////////////////////////////////////////////////////////////////
>// Below does not seem to work
>//I've tried both
> pOutData = pTriFilter->GetOutput();
>// and
> pOutData->CopyStructure(pTriFilter->GetOutput());
>// and then put it in the mapper
> pTriFilter->Delete();
> pMapper->SetInput( pOutData );
> pActor->SetMapper( pMapper );
>// but when the view is rendered, no data is displayed
>//////////////////////////////////////////////////////////////////////////
>// The following does work
> pMapper->SetInput( pTriFilter->GetOutput() );
> pActor->SetMapper( pMapper );
>// but now I need to keep the vtkTriangleFilter around in order to render the data
>/////////////////////////////////////////////////////////////////////////
>
>What I'd like to be able to do is use a filter to get a vtkPolyData object and then be able to delete the filter to free up memory.
>
>
>Lawrence "Renny" Werner
>20324 North Turkey Creek Rd, Morrison, CO 80465
>voice : (303) 697-7656
>email : rendawg at plinet.com
>
>
>
>
>-----------------------------------------------------------------------------
>This is the private VTK discussion list. Please keep messages on-topic.
>Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
>To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
><majordomo at gsao.med.ge.com>. For help, send message body containing
>"info vtkusers" to the same address. Live long and prosper.
>-----------------------------------------------------------------------------
>
There are a couple of ways to do this - one of which was mentioned by
Lisa, and requires a slight extension of one of your solutions above.
What you really need to do is call:
TriFilter->Update() //Sorry if the names are wrong. I'm writing this on
// an ancient machine with no scrollback!
PolyOutput=TriFilter->GetOutput()->MakeObject(); //Just to be safe
TriFilter->CopyStructure(PolyOutput); //like you had
//This next bit I am doing without reference, so bear with me and check
// the man pages!
p
PolyOutput->GetPointData()->PassData(TriFIlter->GetOutput()->GetPointData())
(ibid for CellData - similar for FieldData if you need it
At this point, you have only increased the ref.count to the Cell, Point, and
Field data (no expensive memcpy's), so you can freely delete the TriFilter
(you may need to call PolyOutput->SetSource(NULL))
However, it is a little unclear why you need to destroy the TriFilter.
The actual filters take up relatively little memory themselves. What might
be of more benefit would be to use the SetDataReleased flag
(or SetGlobalDataReleased flag) which will delete the _output_ of filters
after that output has been used. SInce the output takes up orders of magnitude
more memory than the filter itself (in some cases, _several_ orders of magnitude)
it seems to be the wiser choice. But if you must seperate the output and the
filter (to delete or change the filter), the above method is the best way
(at least for VTK<=2.3. 2.4 may have a better way)
By the way, since this type of wuestion arises so often (in many different g
guises to be sure!) mightn't it be best to implement this kind of
shallow copy method as a DataSet m,ethod itself? It wouldn't take but a few
minutes to add this to vtkDataSet, and a few more to document it. Just a
thought.
-matt hall
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list