<DIV>Hi everyone,</DIV>
<DIV> </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> </DIV>
<DIV> // Create DateSet<BR> static float x[POINTS_DIM]={1,2,3,4,5,6,7,8,9,10};<BR> static float y[POINTS_DIM]={1,2,3,4,5,6,7,8,9,10};<BR> static float z[POINTS_DIM]={1,2,3,4,5,6,7,8,9,10};</DIV>
<DIV><BR> vtkUnstructuredGrid *dataSet = vtkUnstructuredGrid::New();<BR> vtkPoints *newPts = vtkPoints::New();<BR> vtkFloatArray *newScalars = vtkFloatArray::New();</DIV>
<DIV> </DIV>
<DIV> int index = 0;</DIV>
<DIV> for(int i=0; i<POINTS_DIM; i++){<BR> for(int j=0; j<POINTS_DIM; j++){<BR> for(int k=0; k<POINTS_DIM; k++){<BR> newPts->InsertPoint(index++, x[i], y[j], z[k]);<BR> newScalars->InsertValue(index, pow(x[i],2));<BR> }<BR> }<BR> }</DIV>
<DIV> dataSet->SetPoints(newPts);<BR> dataSet->GetPointData()->SetScalars(newScalars);</DIV>
<DIV> newPts->Delete(); //reference counted - it's okay<BR> newScalars->Delete();</DIV>
<DIV> </DIV>
<DIV> // Construct pipeline<BR> vtkContourFilter *popSurface = vtkContourFilter::New();<BR> popSurface->SetInput(dataSet);<BR> popSurface->GenerateValues(5,1,100);<BR> vtkPolyDataMapper *popMapper = vtkPolyDataMapper::New();<BR> popMapper->SetInputConnection(popSurface->GetOutputPort());<BR> popMapper->ScalarVisibilityOff();<BR> vtkActor *popActor = vtkActor::New();<BR> popActor->SetMapper(popMapper);<BR> popActor->GetProperty()->SetOpacity(0.3);<BR> popActor->GetProperty()->SetColor(.9,.9,.9);</DIV>
<DIV> </DIV>
<DIV> // Create an instance of vtkRenderer<BR> vtkRenderer *ren1= vtkRenderer::New();<BR> ren1->SetBackground( 1, 1, 1 );<BR> ren1->AddActor(popActor);</DIV>
<DIV> // Create an instance of vtkRenderWindow<BR> vtkRenderWindow *renWin = vtkRenderWindow::New();<BR> renWin->AddRenderer( ren1 );<BR> renWin->SetSize( 300, 300 );</DIV>
<DIV> // Create an instance of vtkRenderWindowInteractor<BR> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<BR> iren->SetRenderWindow(renWin);</DIV>
<DIV> iren->Initialize();</DIV>
<DIV> renWin->Render();<BR> iren->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>