<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=unicode">
<META content="MSHTML 6.00.2800.1589" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText82902 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>David,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Many thanks. I'll try it out and let the
list know.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Cheers, Theo.</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> David E DeMarle
[mailto:dave.demarle@kitware.com]<BR><B>Sent:</B> Thu 22/03/2007
19:12<BR><B>To:</B> Lim, Theodore <BR><B>Cc:</B> vtk-users<BR><B>Subject:</B>
Re: [vtkusers] Win32 OffScreen Rendering and Visibility cell
selector<BR></FONT><BR></DIV>
<DIV>I've just committed a change to vtkOpenGLRenderWindow which appears to fix
it. The change is to return default values if the window isn't mapped like
getColorDepth does.<BR><BR>cheers<BR>Dave DeMarle<BR><BR>
<DIV><SPAN class=gmail_quote>On 3/22/07, <B class=gmail_sendername>David E
DeMarle</B> <<A
href="mailto:dave.demarle@kitware.com">dave.demarle@kitware.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Hmmm,
the program looks ok to me, with the exception of two calls to a "render"
instead of "ofsrender".<BR>I will try cell selection with offscreen rendering
on windows and see if I can reproduce the problem. <BR><BR>cheers<BR>Dave
DeMarle<BR><BR><BR>
<DIV>
<DIV><SPAN class=e id=q_1117ab08c5aaa456_1><SPAN class=gmail_quote>On 3/20/07,
<B class=gmail_sendername>Lim, Theodore</B> <<A
href="mailto:T.Lim@hw.ac.uk" target=_blank> T.Lim@hw.ac.uk</A>>
wrote:</SPAN></SPAN></DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV><SPAN class=e id=q_1117ab08c5aaa456_3>
<DIV dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2></FONT>Hi,</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>Not sure how to put this but here goes...</DIV>
<DIV dir=ltr> </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> </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> </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> </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) 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> </DIV>
<DIV dir=ltr>Any help would be greatly appreciated.</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>Many thanks, Theo.</DIV>
<DIV dir=ltr> </DIV>
<DIV
dir=ltr>/**************************************************************************************************/</DIV>
<DIV dir=ltr>int main()<BR>{<BR> //Load
model<BR> vtkSmartPointer<vtkSTLReader> reader =
vtkSmartPointer<vtkSTLReader>::New();<BR> reader->SetFileName("C:/Model/Data/MillCut.stl");</DIV>
<DIV dir=ltr> vtkSmartPointer<vtkPolyDataMapper> map1 =
vtkSmartPointer<vtkPolyDataMapper>::New(); <BR> map1->SetInput(reader->GetOutput());</DIV>
<DIV dir=ltr><BR> // set up offscreen
renderer<BR> vtkSmartPointer<vtkRenderer> ofsrenderer =
vtkSmartPointer<vtkRenderer>::New();<BR> ofsrenderer->SetBackground(0.0,0.0,0.0);
<BR> vtkSmartPointer<vtkRenderWindow> ofsrenWin =
vtkSmartPointer<vtkRenderWindow>::New();<BR> ofsrenWin->AddRenderer(ofsrenderer);<BR> ofsrenWin->SetSize(800,800);<BR> ofsrenWin->SetOffScreenRendering(1);</DIV>
<DIV dir=ltr> // set
interactor<BR> vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();<BR> iren->SetRenderWindow(ofsrenWin);
</DIV>
<DIV dir=ltr><BR> //set up the
view<BR> renderer->GetActiveCamera()->SetViewUp(0, 1,
0);<BR> renderer->SetBackground(0.0,0.0,0.0);
<BR> <BR> <BR> // set
actor<BR> vtkSmartPointer<vtkActor> act1 =
vtkSmartPointer<vtkActor>::New();<BR> act1->SetMapper(map1);</DIV>
<DIV dir=ltr> // add actor to renderer<BR> double diagonal =
act1->GetLength();<BR> double *center =
act1->GetCenter(); <BR> ofsrenderer->AddActor(act1);<BR> ofsrenderer->GetActiveCamera()->SetFocalPoint(center);<BR> ofsrenderer->GetActiveCamera()->SetPosition(20,
-20, -27);<BR> ofsrenderer->ResetCamera();</DIV>
<DIV dir=ltr><BR> ofsrenWin->Render();</DIV>
<DIV
dir=ltr> //-----------------------------------------------<BR> //
check offscreen render window...<BR> int
rgba[4];<BR> ofsrenWin->GetColorBufferSizes(rgba);</DIV>
<DIV dir=ltr> vtkSmartPointer<vtkWindowToImageFilter> wif =
vtkSmartPointer<vtkWindowToImageFilter>::New();//<BR> wif->SetInput(ofsrenWin);<BR> wif->Update(); </DIV>
<DIV dir=ltr> vtkSmartPointer<vtkJPEGWriter> jpgw =
vtkSmartPointer<vtkJPEGWriter>::New();<BR> jpgw->SetInput(wif->GetOutput());<BR> jpgw->SetQuality(100);<BR> jpgw->SetFileName("D:/Projects/VTK/testoffscreen.jpg");<BR> jpgw->Write();</DIV>
<DIV dir=ltr> //-----------------------------------------------</DIV>
<DIV dir=ltr><BR> // get visible
cells<BR> vtkSmartPointer<vtkVisibleCellSelector> sel1 =
vtkSmartPointer<vtkVisibleCellSelector>::New();<BR> sel1->SetRenderer(ofsrenderer);</DIV>
<DIV dir=ltr> // grab everything
in the render window viewport<BR> int *size =
ofsrenderer->GetRenderWindow()->GetSize();<BR> sel1->SetRenderPasses(0,1,0,1,1);<BR> sel1->SetArea(size[0],size[1],size[2],size[3]);<BR> sel1->Select();<BR> vtkSmartPointer<vtkSelection>
res1 =
vtkSmartPointer<vtkSelection>::New();<BR> sel1->GetSelectedIds(res1);</DIV>
<DIV dir=ltr> vtkSmartPointer<vtkSelection> cellids =
res1->GetChild(0);<BR> vtkSmartPointer<vtkExtractSelectedPolyDataIds>
extr =
vtkSmartPointer<vtkExtractSelectedPolyDataIds>::New();<BR>
if (cellids)<BR>
{<BR>
extr->SetInput(1,
act1->GetMapper()->GetInput());<BR>
extr->SetInput(0,
cellids);<BR>
extr->Update();<BR>
sMap->SetInput(extr->GetOutput());<BR>
}<BR>
else<BR>
{<BR> cerr <<
"Empty color buffer selection -" <<
endl;<BR> cerr
<< "Check display color depth. Must be at least 24 bit." <<
endl;<BR>
sMap->SetInput(emptyPD);<BR>
}</DIV>
<DIV
dir=ltr> ////////////////////////////////////////////////////////////</DIV>
<DIV dir=ltr> ofsrenWin->Render();</DIV>
<DIV dir=ltr><BR> // Set the user method (bound to key
'u')<BR> iren->Initialize();<BR> iren->Start();</DIV>
<DIV dir=ltr><BR> return 0;<BR>}</DIV>
<DIV dir=ltr> </DIV>
<DIV
dir=ltr> </DIV></DIV></SPAN></DIV></DIV><BR>_______________________________________________<BR>This
is the private VTK discussion list.<BR>Please keep messages on-topic. Check
the FAQ at: <A href="http://www.vtk.org/Wiki/VTK_FAQ"
target=_blank>http://www.vtk.org/Wiki/VTK_FAQ</A><BR>Follow this link to
subscribe/unsubscribe:<BR><A
href="http://www.vtk.org/mailman/listinfo/vtkusers"
target=_blank>http://www.vtk.org/mailman/listinfo/vtkusers
</A><BR><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>