Hide cell or point in vtkunstructuredgrid

I am using vtkUnstructuredGrid to show mesh. I need to hide some cells(points) based on user input.
I do not want to delete cell. Just hide them temporary and make them visible later.
I know in vtkStructuredGrid, there is a funciton named BlankPoint/UnBlankPoint or BlankCell/UnBlankCell to show or hide the cell(points);

Any way to hide a cell in vtkUnstructuedGrid/vtkPolyData will be help a lot.


I use vtkThreshold to hide/show certain cells:


    vtkSmartPointer<vtkIntArray> visibility = vtkSmartPointer<vtkIntArray>::New();
    visibility->Allocate( nI * nJ );
    for( int j = 0; j < nJ; ++j){
        for( int i = 0; i < nI; ++i){
            // visibility flag
            if( cell_should_be_visible(i, j) )
                visibility->InsertNextValue( 1 );
                visibility->InsertNextValue( 0 );


    unstructuredGrid->GetPointData()->SetScalars( data_values ); 
    unstructuredGrid->GetPointData()->AddArray  ( visibility );


    // threshold to make vertexes with unvalued Z's invisible
    vtkSmartPointer<vtkThreshold> threshold = vtkSmartPointer<vtkThreshold>::New();
    threshold->SetInputData( unstructuredGrid );
    threshold->SetUpperThreshold(1); // Criterion is cells whose scalars are greater or equal to threshold.
    threshold->SetThresholdFunction( vtkThreshold::THRESHOLD_UPPER );
    threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Visibility");

    // Create mapper (visualization parameters)
    vtkSmartPointer<vtkDataSetMapper> mapper =
    mapper->SetInputConnection( threshold->GetOutputPort() );



To toggle visibility, just alternate the value passed to threshold->SetUpperThreshold() between 1 and, say, 10 and update the scene.