[vtkusers] 3D Contours?
Malcolm Drummond
malcolm at geovision.co.za
Sat Apr 24 06:41:14 EDT 2004
Hi David
Have a look at vtkWarpScalar.
HTH
Malcolm
----- Original Message -----
From: david michell
To: vtkusers at vtk.org
Sent: Saturday, April 24, 2004 6:18 AM
Subject: [vtkusers] 3D Contours?
Hi Everyone,
I have taken all your reply and used them to make the 2D contour plot.
Thanks a lot for the help.
The contour plots are now 2D, they are just lines.
What should I do to make them 3D ie to show surfaces?
Also tell me if i can improve this code anyway?
I have put the code that I did for 2D Contour plot.
Please help me.
Thank you,
David Michell
void main()
{
int npts=100;
vtkPoints * points=vtkPoints::New();
points->SetNumberOfPoints(npts);
vtkPolyVertex *pv=vtkPolyVertex::New();
pv->GetPointIds()->SetNumberOfIds(npts);
vtkDoubleArray *scalar=vtkDoubleArray::New();
scalar->SetNumberOfTuples(npts);
double *data=new double[npts];
for (int i=0;i<npts;i++)
{
data[i*3+0]=sin((double)i);
data[i*3+0]=cos((double)i);
data[i*3+0]=0.0;//(double)i/npts;
if (i<25) scalar->InsertValue(i,0.0);
if ((i>=25)&&(i<50)) scalar->InsertValue(i,1.0);
if ((i>=50)&&(i<75)) scalar->InsertValue(i,2.0);
if ((i>=75)&&(i<100)) scalar->InsertValue(i,3.0);
}
vtkUnstructuredGrid *grid=vtkUnstructuredGrid::New();
grid->Allocate(npts*3);
grid->SetPoints(points);
grid->InsertNextCell(pv->GetCellType(),pv->GetPointIds);
grid->GetPointData()->SetScalars(scalar);
grid->Modified();
grid->Update();
vtkDelaunay2D *del=vtkDelaunay2D::New();
del->SetInput(grid);
del->SetTolerance(0.00001);
/*********TO MAKE THE CONTOUR LINES WITH SMOOTH CURVES************/
vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();
butr->SetInput(del->GetOutput());
butr->SetNumberOfSubdivisions(3);
vtkReverseSense *rev=vtkReverseSense::New();
rev->SetInput(rev->GetOutput());
rev->ReverseCellsOn();
rev->ReverseNormalsOn();
/*************************OK DONE! CURVES***************************/
vtkMarchingContourFilter *contour2D=vtkMarchingContourFilter::New();
contour2D->SetInput(rev->GetOutput());
contour2D->GenerateValues(4,0.0,3.0);
contour2D->Update();
vtkLookupTable *lut=vtkLookupTable::New();
lut->SetHueRange(0.6,0);
lut->SetSaturationRange(1.0,0);
lut->SetValueRange(0.5,1.0);
/*
The rest of the code PolyDataMapper, Actor, Renderer, RenderWindow and RenderWindowInteractor go here!
*/
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040424/064d442f/attachment.htm>
More information about the vtkusers
mailing list