[vtkusers] Why doesn't the intersection of the lines of a vtkCursor2D not set at the focal point?

Xiaofeng Z xf10036 at hotmail.com
Fri Apr 9 10:44:03 EDT 2010


Hi David,

> Here is the working code:
> 
http://www.vtk.org/Wiki/VTK/Examples/Widgets/Cursor2D
> 
Not if you make the following two changes:

  sphereSource->SetRadius(1.0);

  cursor->SetModelBounds(-1,1,-1,1,0,0);

Then the cursor and the sphere will not have the same center.

Regards,
Xiaofeng





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


More information about the vtkusers mailing list