<P>
Hi Everyone,<BR>
I have taken all your reply and used them to make the 2D contour plot.<BR>
Thanks a lot for the help.<BR>
<BR>
The contour plots are now 2D, they are just lines.<BR>
What should I do to make them 3D ie to show surfaces?<BR>
Also tell me if i can improve this code anyway?<BR>
I have put the code that I did for 2D Contour plot.<BR>
<BR>
Please help me.<BR>
Thank you,<BR>
David Michell<BR>
<BR>
void main()<BR>
{<BR>
int npts=100;<BR>
<BR>
vtkPoints * points=vtkPoints::New();<BR>
points->SetNumberOfPoints(npts);<BR>
<BR>
vtkPolyVertex *pv=vtkPolyVertex::New();<BR>
pv->GetPointIds()->SetNumberOfIds(npts);<BR>
<BR>
vtkDoubleArray *scalar=vtkDoubleArray::New();<BR>
scalar->SetNumberOfTuples(npts);<BR>
<BR>
double *data=new double[npts];<BR>
for (int i=0;i<npts;i++)<BR>
{<BR>
data[i*3+0]=sin((double)i);<BR>
data[i*3+0]=cos((double)i);<BR>
data[i*3+0]=0.0;//(double)i/npts;<BR>
<BR>
if (i<25) scalar->InsertValue(i,0.0);<BR>
if ((i>=25)&&(i<50)) scalar->InsertValue(i,1.0);<BR>
if ((i>=50)&&(i<75)) scalar->InsertValue(i,2.0);<BR>
if ((i>=75)&&(i<100)) scalar->InsertValue(i,3.0);<BR>
}<BR>
<BR>
vtkUnstructuredGrid *grid=vtkUnstructuredGrid::New();<BR>
grid->Allocate(npts*3);<BR>
grid->SetPoints(points);<BR>
grid->InsertNextCell(pv->GetCellType(),pv->GetPointIds);<BR>
grid->GetPointData()->SetScalars(scalar);<BR>
grid->Modified();<BR>
grid->Update();<BR>
<BR>
vtkDelaunay2D *del=vtkDelaunay2D::New();<BR>
del->SetInput(grid);<BR>
del->SetTolerance(0.00001);<BR>
<BR>
/*********TO MAKE THE CONTOUR LINES WITH SMOOTH CURVES************/<BR>
vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();<BR>
butr->SetInput(del->GetOutput());<BR>
butr->SetNumberOfSubdivisions(3);<BR>
<BR>
vtkReverseSense *rev=vtkReverseSense::New();<BR>
rev->SetInput(rev->GetOutput());<BR>
rev->ReverseCellsOn();<BR>
rev->ReverseNormalsOn();<BR>
/*************************OK DONE! CURVES***************************/<BR>
<BR>
vtkMarchingContourFilter *contour2D=vtkMarchingContourFilter::New();<BR>
contour2D->SetInput(rev->GetOutput());<BR>
contour2D->GenerateValues(4,0.0,3.0);<BR>
contour2D->Update();<BR>
<BR>
vtkLookupTable *lut=vtkLookupTable::New();<BR>
lut->SetHueRange(0.6,0);<BR>
lut->SetSaturationRange(1.0,0);<BR>
lut->SetValueRange(0.5,1.0);<BR>
<BR>
/*<BR>
The rest of the code PolyDataMapper, Actor, Renderer, RenderWindow and RenderWindowInteractor go here!<BR>
*/<BR>
<BR>
} <BR>
<BR>
<BR>
<BR>
<BR>
</P>
<br><br>
<A target="_blank" HREF="http://clients.rediff.com/signature/track_sig.asp"><IMG SRC="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com/inbox.htm@Bottom" BORDER=0 VSPACE=0 HSPACE=0></a>