[Paraview] Structured grid point blanking

George Zagaris george.zagaris at kitware.com
Fri Feb 10 18:16:50 EST 2012


Hi David,

The issue is that the mapper ( i.e., vtkPVGeometryFilter which invokes
vtkDataSetSurfaceFilter ) does not take into account blanking.

I have a patch for vtkDataSetSurfaceFilter that adds such a check. In
vtkDataSetSurfaceFilter::ExecuteFaceQuads you can add the
following if-statement:

void vtkDataSetSurfaceFilter::ExecuteFaceQuads(...)
{

....

 // Old method for creating quads (needed for cell data.).
  for (ic = ext[cA2]; ic < ext[cA2+1]; ++ic)
    {
    for (ib = ext[bA2]; ib < ext[bA2+1]; ++ib)
      {
      outPtId = outStartPtId + (ib-ext[bA2]) + (ic-ext[cA2])*cOutInc;
      inId = inStartCellId + (ib-ext[bA2])*qInc[bAxis] +
(ic-ext[cA2])*qInc[cAxis];

      if( grid->IsCellVisible(inId) ) // This is the If-statement to
check for blanking
        {
        outId = outPolys->InsertNextCell(4);
        outPolys->InsertCellPoint(outPtId);
        outPolys->InsertCellPoint(outPtId+cOutInc);
        outPolys->InsertCellPoint(outPtId+cOutInc+1);
        outPolys->InsertCellPoint(outPtId+1);
        // Copy cell data.
        outCD->CopyData(inCD,inId,outId);
        this->RecordOrigCellId(outId, inId);
        }

      }
    }

...

}

Alternatively, the out-of-the-box approach is to add a flags array to
the point data of the vtkStructuredGrid instance and use vtkThreshold
to display the corresponding subset.

Hope this helps.

Best,
George


On Fri, Feb 10, 2012 at 4:34 PM, David Doria <daviddoria at gmail.com> wrote:
> 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


More information about the ParaView mailing list