This sounds quite similar to what is going on in the vtkThreshold filter. You'll probably want to look at that implementation.<br><br>Andy<br><br><div class="gmail_quote">On Tue, Sep 13, 2011 at 5:59 PM, <span dir="ltr"><<a href="mailto:FISSELL@pitt.edu">FISSELL@pitt.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
I am writing a custom filter that takes polydata as input and outputs<br>
polydata<br>
that contains a subset of the cells in the input polydata.<br>
I would like the output polydata to include all the vector/scalar etc arrays<br>
associated with the input, appropriately subsetted.<br>
I think I have working code, but I think it only grabs e.g. 1 scalar array<br>
associated with point data (via input->GetPointData()->GetScalars();)<br>
How would I access multiple associated scalar arrays ?<br>
<br>
The only way I found to implement getting even just the single scalar array<br>
is a sort of brute force loop that saves point/cell ids I want to keep<br>
(code snippet below).<br>
Is this the best way to implement this ?<br>
<br>
thanks<br>
kate<br>
<br>
<br>
=========================================================<br>
// code snippet for filter to take polydata as input and output polydata<br>
// with a subset of input polydata cells<br>
<br>
int vtkMyFilter::RequestData(vtkInformation *vtkNotUsed(request),<br>
vtkInformationVector **inputVector,<br>
vtkInformationVector *outputVector)<br>
{<br>
<br>
// allocate vectors to store vtk ids of cells and points I want to keep<br>
vtkIdList *outcellids = vtkIdList::New ();<br>
outcellids->Allocate(num_cells_in,0);<br>
<br>
vtkIdList *outptids = vtkIdList::New ();<br>
outptids->Allocate(num_points_in,0);<br>
<br>
<br>
// loop over input lines, decide what to keep<br>
for(lines->InitTraversal(); lines->GetNextCell(npts,pts); num_poly++) {<br>
<br>
if (I want this cell) {<br>
<br>
out_line_cnt++;<br>
out_tot_pt_ctr = out_tot_pt_ctr + npts;<br>
<br>
// collect pt ids for output vectors<br>
for (k=0; k < npts; k++) {<br>
outptids->InsertNextId ((const vtkIdType) in_tot_pt_ctr++);<br>
}<br>
<br>
// collect cell ids for output<br>
outcellids->InsertNextId ((const vtkIdType) num_poly);<br>
<br>
}<br>
// not adding this line, just update points counter for input points array<br>
else {<br>
in_tot_pt_ctr = in_tot_pt_ctr + npts;<br>
}<br>
}<br>
<br>
<br>
// copy line/point data to output<br>
outcellids->Squeeze();<br>
outptids->Squeeze();<br>
output->Allocate(input,num_cells_in,0);<br>
output->CopyCells(input, outcellids, NULL);<br>
output->Squeeze();<br>
<br>
/////// copy point data active??? vectors<br>
invec = input->GetPointData()->GetVectors();<br>
if (invec != NULL) {<br>
num_comp = invec->GetNumberOfComponents();<br>
<br>
outvec = invec->NewInstance();<br>
outvec->SetNumberOfComponents(num_comp);<br>
outvec->SetNumberOfTuples(out_tot_pt_ctr);<br>
outvec->SetName(invec->GetName());<br>
for (i=0; i<out_tot_pt_ctr; i++) {<br>
outvec->InsertTuple(i,invec->GetTuple(outptids->GetId(i)));<br>
}<br>
output->GetPointData()->SetVectors(outvec);<br>
}<br>
<br>
// repeat for<br>
// input->GetPointData()->GetScalars();<br>
// input->GetCellData()->GetVectors();<br>
// input->GetCellData()->GetScalars();<br>
// etc<br>
<br>
}<br>
<br>
<br>
<br>
==========================================================<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
</blockquote></div><br>