<DIV>Hi everyone,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I want to visualize a this function: F(x,y,z)=x^2 using the vtkContourFilter, but there is no output in my renderwindow. I am novice to the VTK, I don't know what's wrong with my c++ code. Would you please help me? Thank you very much!</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;// Create DateSet<BR>&nbsp;static float x[POINTS_DIM]={1,2,3,4,5,6,7,8,9,10};<BR>&nbsp;static float y[POINTS_DIM]={1,2,3,4,5,6,7,8,9,10};<BR>&nbsp;static float z[POINTS_DIM]={1,2,3,4,5,6,7,8,9,10};</DIV>
<DIV><BR>&nbsp; vtkUnstructuredGrid *dataSet = vtkUnstructuredGrid::New();<BR>&nbsp; vtkPoints *newPts = vtkPoints::New();<BR>&nbsp; vtkFloatArray *newScalars = vtkFloatArray::New();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;int index = 0;</DIV>
<DIV>&nbsp;for(int i=0; i&lt;POINTS_DIM; i++){<BR>&nbsp;&nbsp;for(int j=0; j&lt;POINTS_DIM; j++){<BR>&nbsp;&nbsp;&nbsp;for(int k=0; k&lt;POINTS_DIM; k++){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newPts-&gt;InsertPoint(index++, x[i], y[j], z[k]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newScalars-&gt;InsertValue(index, pow(x[i],2));<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;}</DIV>
<DIV>&nbsp; dataSet-&gt;SetPoints(newPts);<BR>&nbsp; dataSet-&gt;GetPointData()-&gt;SetScalars(newScalars);</DIV>
<DIV>&nbsp; newPts-&gt;Delete(); //reference counted - it's okay<BR>&nbsp; newScalars-&gt;Delete();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // Construct pipeline<BR>&nbsp; vtkContourFilter *popSurface = vtkContourFilter::New();<BR>&nbsp;&nbsp;&nbsp; popSurface-&gt;SetInput(dataSet);<BR>&nbsp;&nbsp;&nbsp; popSurface-&gt;GenerateValues(5,1,100);<BR>&nbsp; vtkPolyDataMapper *popMapper = vtkPolyDataMapper::New();<BR>&nbsp;&nbsp;&nbsp; popMapper-&gt;SetInputConnection(popSurface-&gt;GetOutputPort());<BR>&nbsp;&nbsp;&nbsp; popMapper-&gt;ScalarVisibilityOff();<BR>&nbsp; vtkActor *popActor = vtkActor::New();<BR>&nbsp;&nbsp;&nbsp; popActor-&gt;SetMapper(popMapper);<BR>&nbsp;&nbsp;&nbsp; popActor-&gt;GetProperty()-&gt;SetOpacity(0.3);<BR>&nbsp;&nbsp;&nbsp; popActor-&gt;GetProperty()-&gt;SetColor(.9,.9,.9);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;// Create an instance of vtkRenderer<BR>&nbsp;vtkRenderer *ren1= vtkRenderer::New();<BR>&nbsp;ren1-&gt;SetBackground( 1, 1, 1 );<BR>&nbsp;ren1-&gt;AddActor(popActor);</DIV>
<DIV>&nbsp;// Create an instance of vtkRenderWindow<BR>&nbsp;vtkRenderWindow *renWin = vtkRenderWindow::New();<BR>&nbsp;renWin-&gt;AddRenderer( ren1 );<BR>&nbsp;renWin-&gt;SetSize( 300, 300 );</DIV>
<DIV>&nbsp;// Create an instance of vtkRenderWindowInteractor<BR>&nbsp;vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<BR>&nbsp;&nbsp;&nbsp; &nbsp;iren-&gt;SetRenderWindow(renWin);</DIV>
<DIV>&nbsp;iren-&gt;Initialize();</DIV>
<DIV>&nbsp;renWin-&gt;Render();<BR>&nbsp;iren-&gt;Start();<BR></DIV><br><!-- footer --><br>
<hr>
<table width="100%%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="50" height="50"><img src="http://mimg.163.com/hd/163/163footer/163footer_50.jpg" alt="LOGO" width="50" height="50"></td>
    <td style="padding:5px;"><a style="font-size:12px;color:black; line-height:20px;text-decoration:none;" href="http://popme.163.com/link/003515_0929_938.html">把爱心注入牛奶,共同凝聚这份力量</a><br /><a style="font-size:12px;line-height:20px; color:black; text-decoration:none;" href="http://popme163.com/link/003515_0929_938.html">快来参加蒙牛免费赠奶爱心行动 </a></td>
  </tr>
</table>