I am trying to blank a point in a vtkStructuredGrid. Using the below code, I write out some points to a vts file. All of the points are on a plane except for one. With or without manually creating a visibility array, Paraview seems to display all of the points, including the one that is supposedly blanked.
The goal in both examples below is to ignore the point that is off of the plane, but in both cases it is displayed anyway. Can anyone explain this or point out where I'm going wrong? Without a manual visibility array: #include <vtkSmartPointer.h> #include <vtkIdList.h> #include <vtkProperty.h> #include <vtkStructuredGrid.h> #include <vtkXMLStructuredGridWriter.h> #include <vtkMath.h> int main(int, char *[]) { // Create a grid vtkSmartPointer<vtkStructuredGrid> structuredGrid = vtkSmartPointer<vtkStructuredGrid>::New(); vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); unsigned int gridSize = 8; unsigned int counter = 0; // Create a 5x5 grid of points for(unsigned int j = 0; j < gridSize; j++) { for(unsigned int i = 0; i < gridSize; i++) { if(i == 3 && j == 3) // Make one point higher than the rest { points->InsertNextPoint(i, j, 2); std::cout << "The different point is number " << counter << std::endl; } else { points->InsertNextPoint(i, j, 0); // Make most of the points the same height } counter++; } } bool blanking = structuredGrid->GetPointBlanking(); std::cout << "blanking: " << blanking << std::endl; std::cout << "blanking: " << structuredGrid->GetPointBlanking() << std::endl; // Specify the dimensions of the grid structuredGrid->SetDimensions(gridSize,gridSize,1); structuredGrid->SetPoints(points); structuredGrid->BlankPoint(27); structuredGrid->Modified(); // Create a mapper and actor vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New(); writer->SetInputConnection(structuredGrid->GetProducerPort()); writer->SetFileName("test.vts"); writer->Write(); return EXIT_SUCCESS; } With a manual visibility array: #include <vtkSmartPointer.h> #include <vtkUnsignedCharArray.h> #include <vtkIdList.h> #include <vtkProperty.h> #include <vtkStructuredGrid.h> #include <vtkXMLStructuredGridWriter.h> #include <vtkMath.h> int main(int, char *[]) { // Create a grid vtkSmartPointer<vtkStructuredGrid> structuredGrid = vtkSmartPointer<vtkStructuredGrid>::New(); vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New(); unsigned int gridSize = 8; unsigned int counter = 0; // Create a 5x5 grid of points for(unsigned int j = 0; j < gridSize; j++) { for(unsigned int i = 0; i < gridSize; i++) { if(i == 3 && j == 3) // Make one point higher than the rest { points->InsertNextPoint(i, j, 2); std::cout << "The different point is number " << counter << std::endl; } else { points->InsertNextPoint(i, j, 0); // Make most of the points the same height } counter++; } } bool blanking = structuredGrid->GetPointBlanking(); std::cout << "blanking: " << blanking << std::endl; vtkSmartPointer<vtkUnsignedCharArray> visibilityArray = vtkSmartPointer<vtkUnsignedCharArray>::New(); visibilityArray->SetNumberOfTuples(points->GetNumberOfPoints()); structuredGrid->SetPointVisibilityArray(visibilityArray); for(vtkIdType pointId = 0; pointId < points->GetNumberOfPoints(); ++pointId) { visibilityArray->SetValue(pointId, 0); } visibilityArray->SetValue(27, 1); std::cout << "blanking: " << structuredGrid->GetPointBlanking() << std::endl; // Specify the dimensions of the grid structuredGrid->SetDimensions(gridSize,gridSize,1); structuredGrid->SetPoints(points); structuredGrid->BlankPoint(27); structuredGrid->Modified(); // Create a mapper and actor vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New(); writer->SetInputConnection(structuredGrid->GetProducerPort()); writer->SetFileName("test2.vts"); writer->Write(); return EXIT_SUCCESS; } Thanks, David _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview