[vtkusers] Selecting/Extracting cells using points

andyjk andrewkeeling at hotmail.com
Tue Oct 9 10:04:11 EDT 2018


Resurrecting this - I cannot even get it to work in inverse mode, it only
keeps the points, not the cells. I have tried using vtkExtractSelection and
vtkExtractSelectedIds, but neither will extract the cells. Any idea what I
am missing here?

                        std::cout << "Removing " <<
ids_for_removal->GetNumberOfTuples() << " points on boundary" << std::endl;
			// Run the extraction filter (inverted)
			vtkSmartPointer<vtkSelectionNode> selectionNode =
vtkSmartPointer<vtkSelectionNode>::New();
			selectionNode->SetFieldType(vtkSelectionNode::POINT);
			selectionNode->SetContentType(vtkSelectionNode::INDICES);
			selectionNode->SetSelectionList(ids_for_removal);
			selectionNode->GetProperties()->Set(vtkSelectionNode::INVERSE(), 1);
//invert the selection so we extract everything NOT labelled
			selectionNode->GetProperties()->Set(vtkSelectionNode::CONTAINING_CELLS(),
1);
			
			vtkSmartPointer<vtkSelection> selection =
vtkSmartPointer<vtkSelection>::New();
			selection->AddNode(selectionNode);

			vtkSmartPointer<vtkExtractSelectedIds> extractSelectedIds =
vtkSmartPointer<vtkExtractSelectedIds>::New();
			extractSelectedIds->SetInputData(0, mesh_in_out);
			extractSelectedIds->SetInputData(1, selection);
			extractSelectedIds->Update();

			// Back up the data
			vtkSmartPointer<vtkPolyData> temp2 = vtkSmartPointer<vtkPolyData>::New();
			temp2->DeepCopy(extractSelectedIds->GetOutput());
			std::cout << "Before mesh has : " << mesh_in_out->GetNumberOfCells() << "
cells and " << mesh_in_out->GetNumberOfPoints() << " points" << std::endl;

			std::cout << "Extracted mesh has : " << temp2->GetNumberOfCells() << "
cells and " << temp2->GetNumberOfPoints() << " points" << std::endl;


My output is :

Removing 216 points on boundary
Before mesh has : 125688 cells and 62941 points
Extracted mesh has : 0 cells and 62725 points






--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list