[vtkusers] Can't use vtkCellDataToPointData

Johnny Norris jnorris at mcs.anl.gov
Mon Jul 9 16:55:37 EDT 2001


Hi,

I'm using a nightly release that I downloaded and compiled this morning
(July 9, 2001), and I'm having trouble with vtkCellDataToPointData.  The
problem is that the output's point data doesn't have anything.

I wrote a small example to try to illustrate the problem.  I create a
vtkPolyData object with four points and two cells (triangles).  The
triangles share one edge.  I set the scalars of the cell data so that cell
0 has a value of 0 and cell 1 has a value of 2.  Then I pass this through
a vtkCellDataToPointData object.  After calling update, the output's point
data doesn't have any scalars.  If I set the PassCellData flag, then the
output's cell data has the correct scalars, but the point data is still
empty.

Any ideas on what I'm doing wrong?

Thanks,
John
-- 
John Norris
Research Programmer
Center for Simulation of Advanced Rockets
http://www.uiuc.edu/ph/www/jnorris
-------------- next part --------------
#include <vtkPolyData.h>
// #include <vtkUnstructuredGrid.h>
#include <vtkPoints.h>
#include <vtkScalars.h>
#include <vtkCellDataToPointData.h>

int main()
{
   vtkPoints *pPoints = vtkPoints::New();
   pPoints->SetNumberOfPoints(4);
   pPoints->SetPoint(0, 0.f, 0.f, 0.f);
   pPoints->SetPoint(1, 1.f, 0.f, 0.f);
   pPoints->SetPoint(2, 1.f, 1.f, 0.f);
   pPoints->SetPoint(3, 0.f, 1.f, 0.f);

   vtkScalars *pScalars = vtkScalars::New();
   pScalars->SetNumberOfScalars(2);
   pScalars->SetScalar(0, 0.f);
   pScalars->SetScalar(1, 2.f);

   vtkIdType ids[3] = { 0, 1, 3 };
   vtkPolyData *pData = vtkPolyData::New();
   // vtkUnstructuredGrid *pData = vtkUnstructuredGrid::New();
   pData->Allocate(2);
   pData->InsertNextCell(VTK_TRIANGLE, 3, ids);
   ids[0] = 3;  ids[1] = 1;  ids[2] = 2;
   pData->InsertNextCell(VTK_TRIANGLE, 3, ids);

   pData->SetPoints(pPoints);
   pPoints->Delete();
   pData->GetCellData()->SetScalars(pScalars);
   pScalars->Delete();

   vtkCellDataToPointData *pCD2PD = vtkCellDataToPointData::New();
   pCD2PD->PassCellDataOn();
   pCD2PD->SetInput(pData);
   pCD2PD->GetOutput()->Update();

   vtkIndent indent;
   pCD2PD->GetOutput()->PrintSelf(cout, indent);

   pCD2PD->Delete();
   pData->Delete();

   return 0;
}


More information about the vtkusers mailing list