Hey all,<br><br>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.<br>
<br>I can't figure out if:<br> My vtkSelectionNode is set up incorrectly<br> I'm using vtkExtractSelection incorrectly.<br> The vtkPointPicker doesnt actually get GLOBALIDS ?<br> Missing an update somewhere?<br><br>
Here is the code:<br><br>// Set up vtkSelectionNode<br> vtkSelection* selection = vtkSelection::New();<br> vtkSelectionNode* selectionNode = vtkSelectionNode::New();<br> selectionNode->SetFieldType(<div id=":91" class="ii gt">
vtkSelectionNode::POINT);<br>
selectionNode->SetContentType(vtkSelectionNode::GLOBALIDS);<br><br>// Populate the selection node with our GLOBALIDS (obtained from vtkPointPicker)<br> vtkIntArray* intarray = vtkIntArray::New();<br> for (int a = first; a < second; a++)<br>
{<br> intarray->InsertNextValue(a);<br> }<br> selectionNode->SetSelectionList(intarray);<br> selection->AddNode(selectionNode);<br><br>// Some setup stuff, Our source data is from a multiblock data set<br>
vtkMultiBlockDataSet *extractFrom = vtkMultiBlockDataSet::SafeDownCast(<a href="http://m_v_modules.at/" target="_blank">m_v_modules.at</a>(0)->getDataObject());<br> int nblocks = extractFrom->GetNumberOfBlocks();<br>
<br> vtkGeometryFilter *filter = vtkGeometryFilter::New();<br>
vtkDataSetMapper *mapper = vtkDataSetMapper::New();<br> int counter=0;<br> vtkExtractSelection* extractSelection = vtkExtractSelection::New();<br><br>// Iterate through our datasets (structured grids) and apply vtkExtractSelection to them. Always extracts empty!<br>
vtkCompositeDataIterator *iter = extractFrom->NewIterator();<br> iter->InitTraversal();<br><br> int totalpoints = 0;<br> while (!iter->IsDoneWithTraversal())<br> {<br> vtkDataSet* ds = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());<br>
if (ds)<br> {<br> const char* name = ds->GetClassName(); /// Temp debugger<br> extractSelection->RemoveAllInputs();<br> extractSelection->SetInput(0, ds); /// Set the vtkDataSet for extraction<br>
extractSelection->SetInput(1, selection); /// Set the vtkSelection for extraction<br> vtkDataObject* extracted = extractSelection->GetOutput();<br> extractSelection->Update();<br>
const char* name2 = extracted->GetClassName(); /// Temp debugger<br> <br> vtkUnstructuredGrid* unstructGridTest = vtkUnstructuredGrid::SafeDownCast(extracted);<br> int ntemp1 = unstructGridTest->GetNumberOfPoints();<br>
totalpoints += ntemp1;<br> counter++;<br> }<br> iter->GoToNextItem();<br> }<br></div>