[vtkusers] Contours are not being done!

david michell davidmichell at rediffmail.com
Tue Apr 20 00:22:12 EDT 2004


An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040420/6d1f9298/attachment.htm>
-------------- next part --------------
  Hi everyone,
Iam curretnly trying to figure out to use contour filters.
I have written something ,but when I execute it all i get is a popup window saying "no data to contour".
I dont know what is wrong, I have attached the code, please help me out.
What Iam trying to do is create a unstructured grid of random points and then draw a contour. I dont know what mistake I have done.
Thank you,
David Michell

main()
{
double data[1500];
for (int i=0;i<1500;i++)
{
data[i*3+0]=rand()/126345.23;
data[i*3+1]=rand()/346345.33;
data[i*3+2]=rand()/456345.34;
}

vtkIdType *type;
type=new vtkIdType[500];
for(int counter=0;counter<500;counter++)
{
type[counter]=counter;
}

vtkCellArray *cellarray=vtkCellArray::New();
cellarray->Allocate(cellarray->EstimateSize(500,1));
cellarray->InsertNextCell(500);
cellarray->ReplaceCell(0,500,type);

int celltype[500];
memset(celltype,1,sizeof(int)*500);

vtkDoubleArray *pointset=vtkDoubleArray::New();
pointset->SetNumberOfComponents(3);
pointset->SetNumberOfTuples(500);
pointset->SetArray(data,1500,1);

vtkPoints *points=vtkPoints::New();
points->Allocate(1500);
points->SetData(pointset);

vtkUnstructuredGrid *grid=vtkUnstructuredGrid::New();
grid->Allocate(1500);
grid->SetPoints(points);
grid->SetCells(celltype,cellarray);

vtkCountourFilter *contour=vtkContourFilter::New();
countour->SetInput(grid);
contour->GenerateValues(13,0.0,0.42);

//code for mapper ,actor renderer, render window and interactor goes here
}







More information about the vtkusers mailing list