[vtkusers] Cannot contour even with vtkDelaunay2D ????????????

qin zeng qin_in_usa at hotmail.com
Tue Dec 2 21:49:14 EST 2003


Hi, all

Following is my pipeline:
(1) But I cannot get the contour.

(2) for vtkDelaunay2D, if I don't apply vtkDelaunay2D::update()
    The output polydata from vtkDelaunay2D will be with 0 cell.

///////////////////////////////////////////////////////////////////////////////////

int i;
vtkFloatArray* pcoords = vtkFloatArray::New();
pcoords->SetNumberOfComponents(3);
pcoords->SetNumberOfTuples(10512);

float pts[10512][3];
float * temdata = new float[10512]; 
/////////////////////////////////////////////////////////////////////////////////////
nc_reader myreader("test.dat");
if (!(myreader.get_float_2d(temdata,2000))) return false;

// This is my function to read data from file, it is OK.
// The grid is global meteorological data 2.5x2.5 
//////////////////////////////////////////////////////////////////////////////////////
int indexs= 0;
float ii,jj;
for (ii =90;ii>=-90 ;ii = ii-2.5)
{
    for (jj = 0 ;jj<=357.5;jj =jj+2.5)
    {
        indexs =(int)((90-ii)/2.5) * 144 + (int)(jj/2.5);
        pts[indexs][0] = jj;pts[indexs][1] = ii; pts[indexs][2] = 0;
    }
  
}

for (i=0; i<10512; i++)
    pcoords->SetTuple(i, pts[i]);

vtkPoints* points = vtkPoints::New();
points->SetData(pcoords);

  
vtkIntArray* temperature = vtkIntArray::New();
temperature->SetName("Temperature");
for (i=0; i<10512; i++)
{
    temperature->InsertNextValue(temdata[i]);
}

vtkPolyData* polydata = vtkPolyData::New();

polydata->SetPoints(points);

polydata->GetPointData()->SetScalars(temperature);

vtkDelaunay2D* del2 = vtkDelaunay2D::New();
vtkContourFilter * cf =vtkContourFilter::New();

 
del2->SetInput(polydata);

del2->Update();  // if no update GetNumberOfCells() ==0 , why??
std::cout<<"cell size:"<< del2->GetOutput()->GetNumberOfCells()<<std::endl; 

cf->SetInput(del2->GetOutput());

vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
mapper->SetInput(cf->GetOutput());


vtkActor* actor = vtkActor::New();
actor->SetMapper(mapper);
vtkRenderer* ren = vtkRenderer::New();
ren->AddActor(actor);
ren->SetBackground(0.2,0.2,0.4); 
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
iren->Initialize();
iren->Start();

pcoords->Delete();
points->Delete();
cells->Delete();
temperature->Delete();
polydata->Delete();
mapper->Delete();
actor->Delete();
ren->Delete();
renWin->Delete();
iren->Delete();
delete []temdata;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20031202/7be82044/attachment.htm>


More information about the vtkusers mailing list