<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>

<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.6944.0">
<TITLE>Re: [vtkusers] error with Cmake for configuring VTK</TITLE>
</HEAD>
<BODY>
<DIV id=idOWAReplyText1680 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2></FONT>Hi,</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>Not sure how to put this but here goes...</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>I'm trying to get get visible cell data for a series of camera 
positions and would like to do this using the Win32 offscreen rendering 
capabilities.</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>However, i discovered that the offscreen render window color buffer 
size returns all 0 values. This seems to be the reason why the visible cell 
selector fails. Is there a way to set (or force) values into it?</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>Or rather, can the new class vtkVisibilityCellSelector be used in 
Offscreen rendering mode? And if so, how can this be achieved. I've attached the 
code which i'm testing below.</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>One note: i compiled with cmake option VTK_USE_OFFSCREEN set to 
'Off' as this caused the vtkMFC examples (i.e. vtkDLG, vtkSDI, vtkMDI)&nbsp;to 
crash. It also caused the same response to my own VTK-MFC app. Not sure if this 
has anything to do with it not being able to use Offscreen. In the test code 
below, i use the vtkWindowToImageFilter to grab a snapshot of the offscreen 
render window and the results was as expected.</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>Any help would be greatly appreciated.</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>Many thanks, Theo.</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV 
dir=ltr>/**************************************************************************************************/</DIV>
<DIV dir=ltr>int main()<BR>{<BR>&nbsp;//Load 
model<BR>&nbsp;vtkSmartPointer&lt;vtkSTLReader&gt; reader = 
vtkSmartPointer&lt;vtkSTLReader&gt;::New();<BR>&nbsp;reader-&gt;SetFileName("C:/Model/Data/MillCut.stl");</DIV>
<DIV dir=ltr>&nbsp;vtkSmartPointer&lt;vtkPolyDataMapper&gt; map1 = 
vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();&nbsp;<BR>&nbsp;map1-&gt;SetInput(reader-&gt;GetOutput());</DIV>
<DIV dir=ltr><BR>&nbsp;// set up offscreen 
renderer<BR>&nbsp;vtkSmartPointer&lt;vtkRenderer&gt; ofsrenderer = 
vtkSmartPointer&lt;vtkRenderer&gt;::New();<BR>&nbsp;ofsrenderer-&gt;SetBackground(0.0,0.0,0.0); 
<BR>&nbsp;vtkSmartPointer&lt;vtkRenderWindow&gt; ofsrenWin = 
vtkSmartPointer&lt;vtkRenderWindow&gt;::New();<BR>&nbsp;ofsrenWin-&gt;AddRenderer(ofsrenderer);<BR>&nbsp;ofsrenWin-&gt;SetSize(800,800);<BR>&nbsp;ofsrenWin-&gt;SetOffScreenRendering(1);</DIV>
<DIV dir=ltr>&nbsp;// set 
interactor<BR>&nbsp;vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; iren = 
vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<BR>&nbsp;iren-&gt;SetRenderWindow(ofsrenWin);&nbsp; 
</DIV>
<DIV dir=ltr><BR>&nbsp;//set up the 
view<BR>&nbsp;renderer-&gt;GetActiveCamera()-&gt;SetViewUp(0, 1, 
0);<BR>&nbsp;renderer-&gt;SetBackground(0.0,0.0,0.0); 
<BR>&nbsp;&nbsp;<BR>&nbsp;<BR>&nbsp;// set 
actor<BR>&nbsp;vtkSmartPointer&lt;vtkActor&gt; act1 = 
vtkSmartPointer&lt;vtkActor&gt;::New();<BR>&nbsp;act1-&gt;SetMapper(map1);</DIV>
<DIV dir=ltr>&nbsp;// add actor to renderer<BR>&nbsp;double diagonal = 
act1-&gt;GetLength();<BR>&nbsp;double *center = 
act1-&gt;GetCenter();&nbsp;<BR>&nbsp;ofsrenderer-&gt;AddActor(act1);<BR>&nbsp;ofsrenderer-&gt;GetActiveCamera()-&gt;SetFocalPoint(center);<BR>&nbsp;ofsrenderer-&gt;GetActiveCamera()-&gt;SetPosition(20, 
-20, -27);<BR>&nbsp;ofsrenderer-&gt;ResetCamera();</DIV>
<DIV dir=ltr><BR>&nbsp;ofsrenWin-&gt;Render();</DIV>
<DIV dir=ltr>&nbsp;//-----------------------------------------------<BR>&nbsp;// 
check offscreen render window...<BR>&nbsp;int 
rgba[4];<BR>&nbsp;ofsrenWin-&gt;GetColorBufferSizes(rgba);</DIV>
<DIV dir=ltr>&nbsp;vtkSmartPointer&lt;vtkWindowToImageFilter&gt; wif = 
vtkSmartPointer&lt;vtkWindowToImageFilter&gt;::New();//<BR>&nbsp;wif-&gt;SetInput(ofsrenWin);<BR>&nbsp;wif-&gt;Update();&nbsp;</DIV>
<DIV dir=ltr>&nbsp;vtkSmartPointer&lt;vtkJPEGWriter&gt; jpgw = 
vtkSmartPointer&lt;vtkJPEGWriter&gt;::New();<BR>&nbsp;jpgw-&gt;SetInput(wif-&gt;GetOutput());<BR>&nbsp;jpgw-&gt;SetQuality(100);<BR>&nbsp;jpgw-&gt;SetFileName("D:/Projects/VTK/testoffscreen.jpg");<BR>&nbsp;jpgw-&gt;Write();</DIV>
<DIV dir=ltr>&nbsp;//-----------------------------------------------</DIV>
<DIV dir=ltr><BR>&nbsp;// get visible 
cells<BR>&nbsp;vtkSmartPointer&lt;vtkVisibleCellSelector&gt; sel1 = 
vtkSmartPointer&lt;vtkVisibleCellSelector&gt;::New();<BR>&nbsp;sel1-&gt;SetRenderer(ofsrenderer);</DIV>
<DIV dir=ltr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // grab everything in 
the render window viewport<BR>&nbsp;int *size = 
ofsrenderer-&gt;GetRenderWindow()-&gt;GetSize();<BR>&nbsp;sel1-&gt;SetRenderPasses(0,1,0,1,1);<BR>&nbsp;sel1-&gt;SetArea(size[0],size[1],size[2],size[3]);<BR>&nbsp;sel1-&gt;Select();<BR>&nbsp;vtkSmartPointer&lt;vtkSelection&gt; 
res1 = 
vtkSmartPointer&lt;vtkSelection&gt;::New();<BR>&nbsp;sel1-&gt;GetSelectedIds(res1);</DIV>
<DIV dir=ltr>&nbsp;vtkSmartPointer&lt;vtkSelection&gt; cellids = 
res1-&gt;GetChild(0);<BR>&nbsp;vtkSmartPointer&lt;vtkExtractSelectedPolyDataIds&gt; 
extr = 
vtkSmartPointer&lt;vtkExtractSelectedPolyDataIds&gt;::New();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if (cellids)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extr-&gt;SetInput(1, 
act1-&gt;GetMapper()-&gt;GetInput());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
extr-&gt;SetInput(0, 
cellids);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
extr-&gt;Update();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
sMap-&gt;SetInput(extr-&gt;GetOutput());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cerr &lt;&lt; "Empty 
color buffer selection -" &lt;&lt; 
endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cerr &lt;&lt; 
"Check display color depth. Must be at least 24 bit." &lt;&lt; 
endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
sMap-&gt;SetInput(emptyPD);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}</DIV>
<DIV 
dir=ltr>&nbsp;////////////////////////////////////////////////////////////</DIV>
<DIV dir=ltr>&nbsp;ofsrenWin-&gt;Render();</DIV>
<DIV dir=ltr><BR>&nbsp;// Set the user method (bound to key 
'u')<BR>&nbsp;iren-&gt;Initialize();<BR>&nbsp;iren-&gt;Start();</DIV>
<DIV dir=ltr><BR>&nbsp;return 0;<BR>}</DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr>&nbsp;</DIV></DIV>

</BODY>
</HTML>