[vtkusers] vtkSelection with GLOBALIDS, vtkExtractSelection returns empty
da xu
remywendy at gmail.com
Wed Jul 8 03:12:07 EDT 2009
Hey all,
I am trying to extract a section of my datasets using vtkSelection. I
currently have a GUI that the user clicks on to select a start and end point
using vtkPointPicker, returning the PointID. With a starting POINTID and
ending POINTID, i then use a vtkSelection with field type POINT, ContentType
GLOBALIDS to extract a dataset containing the points (with
vtkSelectionNode's SetSelectionList correctly set I believe). However, I
always end up extracting an empty grid.
I can't figure out if:
My vtkSelectionNode is set up incorrectly
I'm using vtkExtractSelection incorrectly.
The vtkPointPicker doesnt actually get GLOBALIDS ?
Missing an update somewhere?
Here is the code:
// Set up vtkSelectionNode
vtkSelection* selection = vtkSelection::New();
vtkSelectionNode* selectionNode = vtkSelectionNode::New();
selectionNode->SetFieldType(vtkSelectionNode::POINT);
selectionNode->SetContentType(vtkSelectionNode::GLOBALIDS);
// Populate the selection node with our GLOBALIDS (obtained from
vtkPointPicker)
vtkIntArray* intarray = vtkIntArray::New();
for (int a = first; a < second; a++)
{
intarray->InsertNextValue(a);
}
selectionNode->SetSelectionList(intarray);
selection->AddNode(selectionNode);
// Some setup stuff, Our source data is from a multiblock data set
vtkMultiBlockDataSet *extractFrom = vtkMultiBlockDataSet::SafeDownCast(
m_v_modules.at(0)->getDataObject());
int nblocks = extractFrom->GetNumberOfBlocks();
vtkGeometryFilter *filter = vtkGeometryFilter::New();
vtkDataSetMapper *mapper = vtkDataSetMapper::New();
int counter=0;
vtkExtractSelection* extractSelection = vtkExtractSelection::New();
// Iterate through our datasets (structured grids) and apply
vtkExtractSelection to them. Always extracts empty!
vtkCompositeDataIterator *iter = extractFrom->NewIterator();
iter->InitTraversal();
int totalpoints = 0;
while (!iter->IsDoneWithTraversal())
{
vtkDataSet* ds =
vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
if (ds)
{
const char* name = ds->GetClassName(); /// Temp debugger
extractSelection->RemoveAllInputs();
extractSelection->SetInput(0, ds); /// Set the vtkDataSet for
extraction
extractSelection->SetInput(1, selection); /// Set the
vtkSelection for extraction
vtkDataObject* extracted = extractSelection->GetOutput();
extractSelection->Update();
const char* name2 = extracted->GetClassName(); /// Temp
debugger
vtkUnstructuredGrid* unstructGridTest =
vtkUnstructuredGrid::SafeDownCast(extracted);
int ntemp1 = unstructGridTest->GetNumberOfPoints();
totalpoints += ntemp1;
counter++;
}
iter->GoToNextItem();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090708/81b3206c/attachment.htm>
More information about the vtkusers
mailing list