<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi David,<br><br>> Here is the working code:<br>>
http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D<br>> <br>Not if you make the following two changes:<br><br> sphereSource->SetRadius(1.0);<br><br> cursor->SetModelBounds(-1,1,-1,1,0,0);<br><br>Then the cursor and the sphere will not have the same center.<br><br>Regards,<br>Xiaofeng<br>
<a href="http://www.xzing.org"></a><br><br><br><br>> Date: Fri, 9 Apr 2010 08:42:09 -0400<br>> Subject: Re: [vtkusers] Why doesn't the intersection of the lines of a         vtkCursor2D not set at the focal point?<br>> From: daviddoria+vtk@gmail.com<br>> To: xf10036@hotmail.com<br>> CC: vtkusers@vtk.org<br>> <br>> On Thu, Apr 8, 2010 at 9:52 PM, Xiaofeng Z <xf10036@hotmail.com> wrote:<br>> > Hi vtkUsers,<br>> ><br>> > The following is a program that place a vtkSphere and a vtkCursor2D in a<br>> > rendering window. My question is why the cursor 2d does not pass the center<br>> > of the sphere, see attached image.<br>> ><br>> > int _tmain(int argc, _TCHAR* argv[])<br>> > {<br>> > // create sphere geometry<br>> > vtkSphereSource *sphere = vtkSphereSource::New();<br>> > sphere->SetCenter(0.0, 0.0, 0.0);<br>> > sphere->SetRadius(1.0);<br>> > sphere->SetThetaResolution(18);<br>> > sphere->SetPhiResolution(18);<br>> ><br>> > // map to graphics library<br>> > vtkPolyDataMapper *map = vtkPolyDataMapper::New();<br>> > map->SetInput(sphere->GetOutput());<br>> ><br>> > // actor coordinates geometry, properties, transformation<br>> > vtkActor *actor = vtkActor::New();<br>> > actor->SetMapper(map);<br>> > actor->GetProperty()->SetColor(0,0,1); // sphere color blue<br>> ><br>> > // renderers and render window<br>> > vtkRenderer *renA = vtkRenderer::New();<br>> > renA->SetViewport(0.0, 0.0, 1.0, 1.0);<br>> > vtkRenderWindow* win = vtkRenderWindow::New();<br>> > win->SetSize(300,300);<br>> > win->AddRenderer(renA);<br>> ><br>> > // an interactor<br>> > vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>> > iren->SetRenderWindow(win);<br>> ><br>> > renA->SetBackground(1,1,1); // Background color white<br>> ><br>> > renA->AddActor(actor);<br>> ><br>> > // add a 2D cursor to each Renderer<br>> > vtkCursor2D* cursor = vtkCursor2D::New();<br>> > cursor->SetTranslationMode(1);<br>> > cursor->SetWrap(1);<br>> > cursor->SetModelBounds(-0.5, 0.5, -0.5, 0.5, 0.0, 0.0);<br>> > cursor->SetFocalPoint(0.0, 0.0, 0.0);<br>> > cursor->AllOff();<br>> > cursor->AxesOn();<br>> ><br>> > vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>> > mapper->SetInput(cursor->GetOutput());<br>> > actor = vtkActor::New();<br>> > actor->SetMapper(mapper);<br>> > actor->GetProperty()->SetColor(1.0, 0.0, 0.0);<br>> ><br>> > renA->AddActor(actor);<br>> ><br>> > // render an image (lights and cameras are created automatically)<br>> > win->Render();<br>> ><br>> > iren->Start();<br>> ><br>> > return 0;<br>> > }<br>> ><br>> ><br>> > Xiaofeng Z<br>> <br>> Hi Xiaofeng,<br>> <br>> You need to create a new actor for the cursor:<br>> <br>> i.e. replace this:<br>> <br>> vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>> mapper->SetInput(cursor->GetOutput());<br>> actor = vtkActor::New();<br>> actor->SetMapper(mapper);<br>> <br>> with this:<br>> <br>> vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();<br>> mapper->SetInput(cursor->GetOutput());<br>> vtkActor* cursorActor = vtkActor::New();<br>> cursorActor->SetMapper(mapper);<br>> <br>> and then it works.<br>> <br>> Here is the working code:<br>> http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D<br>> <br>> Thanks,<br>> <br>> David<br>                                            <br /><hr />Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. <a href='http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2' target='_new'>See how.</a></body>
</html>