<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> </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>
</BODY>
</HTML>