<P>
Hi everyone,<BR>
I have attached a code that Iam working on to produce contours.<BR>
Somehow Iam not able to get any contours.<BR>
Please help me.<BR>
Thank you,<BR>
david michell<BR>
<BR>
<BR>
#define VTK_USE_ANSI_STDLIB <BR>
<BR>
#include &quot;vtk/vtkPolyDataMapper.h&quot;<BR>
<BR>
#include &quot;vtk/vtkActor.h&quot;<BR>
<BR>
#include &quot;vtk/vtkRenderer.h&quot;<BR>
<BR>
#include &quot;vtk/vtkRenderWindow.h&quot;<BR>
<BR>
#include &quot;vtk/vtkRenderWindowInteractor.h&quot;<BR>
<BR>
#include &quot;vtk/vtkPoints.h&quot;<BR>
<BR>
#include &quot;vtk/vtkFloatArray.h&quot;<BR>
<BR>
#include &quot;vtk/vtkPointData.h&quot;<BR>
<BR>
#include &quot;vtk/vtkDelaunay2D.h&quot;<BR>
<BR>
#include &quot;vtk/vtkPolyData.h&quot;<BR>
<BR>
#include &quot;vtk/vtkButterflySubdivisionFilter.h&quot;<BR>
<BR>
#include &quot;vtk/vtkMarchingContourFilter.h&quot;<BR>
<BR>
#include &quot;stdio.h&quot;<BR>
<BR>
int main(int argc,char* argv[])<BR>
<BR>
{<BR>
<BR>
vtkRenderer *ren=vtkRenderer::New();<BR>
<BR>
vtkRenderWindow *win=vtkRenderWindow::New();<BR>
<BR>
win-&gt;AddRenderer(ren);<BR>
<BR>
vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();<BR>
<BR>
win-&gt;SetInteractor(iren);<BR>
<BR>
iren-&gt;Initialize();<BR>
<BR>
 <BR>
<BR>
 <BR>
<BR>
vtkPoints *points=vtkPoints::New();<BR>
<BR>
<BR>
<BR>
vtkFloatArray *scalar=vtkFloatArray::New();<BR>
<BR>
<BR>
int i,counter;<BR>
<BR>
float temp;<BR>
<BR>
double *data;<BR>
<BR>
<BR>
int npts=100;<BR>
<BR>
<BR>
points-&gt;SetNumberOfPoints(npts);<BR>
<BR>
scalar-&gt;SetNumberOfTuples(npts);<BR>
<BR>
data=new double[npts*3];<BR>
<BR>
double y=0.01;<BR>
<BR>
for (i=0;i&lt;npts;i++)<BR>
<BR>
{<BR>
<BR>
data[i*3]=rand()*i;<BR>
<BR>
data[i*3+1]=rand()*i;<BR>
<BR>
data[i*3+2]=0.0;//z=0 because 2D<BR>
<BR>
points-&gt;InsertPoint(i,data[i*3],data[i*3+1],data[i*3+2]);<BR>
<BR>
float temp=1.0;<BR>
<BR>
scalar-&gt;InsertValue(i,temp);<BR>
<BR>
}<BR>
<BR>
vtkPolyData *m_spData=vtkPolyData::New();<BR>
<BR>
m_spData-&gt;Allocate(npts*3);<BR>
<BR>
m_spData-&gt;SetPoints(points);<BR>
<BR>
m_spData-&gt;GetPointData()-&gt;SetScalars(scalar);<BR>
<BR>
m_spData-&gt;Modified();<BR>
<BR>
m_spData-&gt;Update();<BR>
<BR>
 <BR>
<BR>
vtkDelaunay2D *del=vtkDelaunay2D::New();<BR>
<BR>
del-&gt;SetInput(m_spData);<BR>
<BR>
del-&gt;SetTolerance(0.00001f);<BR>
<BR>
del-&gt;Update();<BR>
<BR>
//to get smooth curved contours<BR>
<BR>
vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();<BR>
<BR>
butr-&gt;SetInput(del-&gt;GetOutput());<BR>
<BR>
butr-&gt;SetNumberOfSubdivisions(2);<BR>
<BR>
butr-&gt;Update();<BR>
<BR>
<BR>
vtkMarchingContourFilter *contour2D=vtkMarchingContourFilter::New();<BR>
<BR>
contour2D-&gt;SetInput(butr-&gt;GetOutput()); <BR>
<BR>
contour2D-&gt;SetValue(0,1.0);<BR>
<BR>
contour2D-&gt;Update();<BR>
<BR>
<BR>
vtkPolyDataMapper *mapper=vtkPolyDataMapper::New();<BR>
<BR>
mapper-&gt;SetInput(contour2D-&gt;GetOutput());<BR>
<BR>
<BR>
vtkActor *surface=vtkActor::New();<BR>
<BR>
surface-&gt;SetMapper(mapper); <BR>
<BR>
ren-&gt;AddActor(surface);<BR>
<BR>
 <BR>
<BR>
iren-&gt;Start();<BR>
<BR>
 <BR>
<BR>
points-&gt;Delete();<BR>
<BR>
scalar-&gt;Delete();<BR>
<BR>
m_spData-&gt;Delete();<BR>
<BR>
del-&gt;Delete();<BR>
<BR>
butr-&gt;Delete();<BR>
<BR>
contour2D-&gt;Delete();<BR>
<BR>
mapper-&gt;Delete();<BR>
<BR>
surface-&gt;Delete();<BR>
<BR>
delete[] data;<BR>
<BR>
ren-&gt;Delete();<BR>
<BR>
win-&gt;Delete();<BR>
<BR>
iren-&gt;Delete();<BR>
<BR>
return 1;<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>