[vtkusers] vtk can render 3d image realtime?
LuanKuan
luankuan at hotmail.com
Mon Nov 8 06:06:47 EST 2010
Hi, David
Sorry, I can not comprehend the work mechanism of vtk. I modified my code as you mentioned in reply, but it doesn't work.
My code is as fellows:
vtkRenderer *aRenderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRenderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkContourFilter *contours = vtkContourFilter::New();
vtkPolyDataMapper *contmap = vtkPolyDataMapper::New();
vtkActor *contact = vtkActor::New();
vtkCamera *aCamera = vtkCamera::New();
aCamera->ParallelProjectionOn();
aRenderer->SetActiveCamera(aCamera);
aRenderer->ResetCamera();
aRenderer->SetBackground(0.725,0.725,1);
renWin->SetSize(1024, 768);
aRenderer->ResetCameraClippingRange ();
iren->Initialize();
// loop
for (int i=iFirstFrame; i<iNumFrames; i++)
{
......
interpolate bmpimage into volumeimage;
......
volumeimage->update();
contours->SetInput(volumeimage);
contours->SetValue(0,gval);
contmap->SetInput(contours->GetOutput());
contmap->SetScalarRange(100,220);
contact->SetMapper(contmap);
aRenderer->AddActor(contact);
aRenderer->Render();
iren->Render();
}
iren->Start();
thank you.
> Date: Fri, 5 Nov 2010 07:48:09 -0400
> From: daviddoria at gmail.com
> To: luannauk at gmail.com
> CC: vtkusers at vtk.org
> Subject: Re: [vtkusers] vtk can render 3d image realtime?
>
> On Fri, Nov 5, 2010 at 6:33 AM, kuan luan <luannauk at gmail.com> wrote:
> > Dear all,
> > I am a vtk beginner. I am trying to reconstruct a 3d medical image from 2d
> > images with spacial coordinates. I use vtk for reconstructing and surface
> > rendering.
> > now, I have a program for 3d reconstruction from 2d images offline.
> > My method is
> > acquire a new 2d image with spacial coordiante,
> > interpolate it into 3d vtkimage.
> > render the 3d vtkimage with new 2d image added,
> > a new vtkRenderWindow is created.
> > all procedure run in a while loop.
> >
> > But, I want to implement it in realtime.
> > My problem is I can not render 3d reconstructed image with vtk in realtime.
> > How can the 3d vtkimage be rendered again in the same vtkRenderWindow
> > without creating a new one? Is this possible using VTK? If so please tell
> > me how to do it.
> >
> > I'm using VTK5.4 and Microsoft Visual C++ 2008.
> > Any advice is appreciated ;)
> > Thank you in advance.
>
> Sure, just create the vtkRenderWindow and vtkRenderer outside (before)
> the loop. Then inside the loop just add your new data to the renderer
> and call Render() on the renderer and renderWindow.
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101108/58c55c24/attachment.htm>
More information about the vtkusers
mailing list