[vtkusers] problem with vtkPicker(vtkCellPicker, vtkPointPicker)

Shady Shidfar shady_shidfar at yahoo.com
Sat Sep 27 09:14:36 EDT 2008


Hi Sercani, 
I just changed vtkCellPicker to vtkPropPicker and everything's fixed. Thanks very much.

Shaadi



----- Original Message ----
From: Sercani <sercanimailgroups at gmail.com>
To: Shady Shidfar <shady_shidfar at yahoo.com>
Cc: VTKUsers <vtkusers at vtk.org>
Sent: Friday, 26 September, 2008 20:24:55
Subject: RE: [vtkusers] problem with vtkPicker(vtkCellPicker, vtkPointPicker)


Hi Shady; 
You must use vtkPropPicker, and when setting picking point you must also transform the display point with the inverse transform of the image’s transform(rotate, scaling etc.)...
 
***Sercani***
 
From:vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Sarah Macumber
Sent: Friday, September 26, 2008 8:01 PM
To: Shady Shidfar
Cc: VTKUsers
Subject: Re: [vtkusers] problem with vtkPicker(vtkCellPicker, vtkPointPicker)
 
Hi Shaadi,
 
You are working image data so you probably don’t have cells or points, have you tried vtkPropPicker?  I don’t work with images but you want a picker that will select a point confined to the image plane.  Try reading the helps on the pickers.
 
Best of luck,
Sarah
 
From:Shady Shidfar [mailto:shady_shidfar at yahoo.com] 
Sent: Friday, September 26, 2008 5:25 AM
To: Sarah Macumber; VTKUsers
Subject: Re: [vtkusers] problem with vtkPicker(vtkCellPicker, vtkPointPicker)
 
Hi Sarah,
I've tried it with both vtkCellPicker and vtkPointPicker, but the problem is still there. Can someone please help me.
 
Shaadi

 
----- Original Message ----
From: Sarah Macumber <S.Macumber at QuestReliability.com>
To: Shady Shidfar <shady_shidfar at yahoo.com>; VTKUsers <vtkusers at vtk.org>
Sent: Thursday, 25 September, 2008 21:02:36
Subject: RE: [vtkusers] problem with vtkPicker(vtkCellPicker, vtkPointPicker)
Hi Shaadi,
 
vtkPicker will pick 3D world coordinates which may not have a z value of 0.  You will want to use a picker which will return you points confined to your image plane.  You could try using vtkCellPicker or vtkPropPicker.
 
All the best,
Sarah Macumber
 
From:vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Shady Shidfar
Sent: Thursday, September 25, 2008 4:48 AM
To: VTKUsers
Subject: [vtkusers] problem with vtkPicker(vtkCellPicker, vtkPointPicker)
 
Hi Everyone,
I sent this yesterday but I don't know why it didn't apear in the forum. I'm sending it again, please can someone help me with it.
I'm using vtkPicker to pick cells on an image and draw on the image. I've copied a short version of my program. I'm using vtkDotNet and managedItk. I want to draw lines through the picked points on a 2d tif image. Key 'p' is used to pick a point. The lines need to remain in the same place they've been drawn no matter zooming or rotating. The problem is :
1- When I zoom the image and get the picked cell dimension, Z would be a value rather than 0 which I don't understand why.
2- When I rotate the image and pick the points and draw lines. It seems they are in the right place but when I rotate the image the lines would be somewhere outside the image. 
 
I'm using picker.GetPickPosition() to get the dimension of the picked point. I'd probably need to change this. Does anyone know how I can fix the problem? Any suggestions would be a great help
 
Thanks
Shaadi
 
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Collections;
usingvtk;
usingitk;
namespaceInteractiveHierarchicalSegmentationDotNet.Test
{
publicpartial class testPicking : Form
{
vtkCellPickerpicker;
vtkRendererrenderer = new vtkRenderer();
publictestPicking()
{
InitializeComponent();
vtkFormsWindowControl1.GetRenderWindow().AddRenderer(renderer);
viewImage();
picker = new vtkCellPicker();
picker.PickFromListOn(); // to make sure picker won't pick props instead of cells
picker.AddObserver((uint)vtk.EventIds.EndPickEvent, new vtk.vtkDotNetCallback(annotatePick));
vtkFormsWindowControl1.GetInteractor().SetPicker(picker);
}
privatevoid annotatePick(vtk.vtkObject caller, uint eventId,
objectclientData, IntPtr callData)
{
vtkActor2DtextActor = new vtkActor2D();
{
double[] selPt = picker.GetSelectionPoint();
doublex = selPt[0];
doubley = selPt[1];
double[] pickPos = picker.GetPickPosition();
doublexp = pickPos[0];
doubleyp = pickPos[1];
doublezp = pickPos[2];
pointsDataGridView.Rows.Add();
pointsDataGridView.Rows[pointsDataGridView.RowCount - 1].Cells[0].Value = xp;
pointsDataGridView.Rows[pointsDataGridView.RowCount - 1].Cells[1].Value = yp;
pointsDataGridView.Rows[pointsDataGridView.RowCount - 1].Cells[2].Value = zp;
double[] newPoint = new double[] { xp, yp, zp };
double[] previousPoint = new double[3];
if(pointsDataGridView.Rows.Count == 1)
{
previousPoint = newPoint;
}
else
{
// retrieve the previous row
doublepxp = Convert.ToDouble(pointsDataGridView.Rows[pointsDataGridView.Rows.Count - 2].Cells[0].Value);
doublepyp = Convert.ToDouble(pointsDataGridView.Rows[pointsDataGridView.Rows.Count - 2].Cells[1].Value);
doublepzp = Convert.ToDouble(pointsDataGridView.Rows[pointsDataGridView.Rows.Count - 2].Cells[2].Value);
previousPoint[0] = pxp;
previousPoint[1] = pyp;
previousPoint[2] = pzp;
}
intr = 1, g = 0, b = 0;
createLine(previousPoint, newPoint);
vtkFormsWindowControl1.Refresh();
}
}
privatevoid createLine(double[] startPoint, double[] endPoint)
{
vtkPointsVTKpoints = new vtkPoints();
VTKpoints.SetNumberOfPoints(2);
VTKpoints.InsertPoint(0, startPoint[0], startPoint[1], startPoint[2]);
VTKpoints.InsertPoint(1, endPoint[0], endPoint[1], endPoint[2]);
 
vtkLineline = new vtkLine();
line.GetPointIds().SetId(0, 0);
line.GetPointIds().SetId(1, 1);
vtkUnstructuredGridgrid = new vtkUnstructuredGrid();
grid.Allocate(1, 1);
grid.InsertNextCell(line.GetCellType(), line.GetPointIds());
grid.SetPoints(VTKpoints);
vtkDataSetMapperaLineMapper = new vtkDataSetMapper();
aLineMapper.SetInput(grid);
vtkActoraLineActor = new vtkActor();
aLineActor.SetMapper(aLineMapper);
aLineActor.AddPosition(0, 0, 0);
aLineActor.GetProperty().SetDiffuseColor(1, 0, 0);
renderer.AddActor(aLineActor);
vtkFormsWindowControl1.GetRenderWindow().AddRenderer(renderer);
}
privatevoid viewImage()
{
try
{
itkImage_UC3input = itkImage_UC3.New();
input.Read("C:/brain.tif");
// Import ITK image to VTK
itkImageToVTKImageFilter_IUC3itk2vtk =
itkImageToVTKImageFilter_IUC3.New();
itk2vtk.SetInput(input);
itk2vtk.Update();
vtkImageDatadata = itk2vtk.GetOutput();
vtkImageFlipimageFlip = new vtkImageFlip();
imageFlip.SetFilteredAxis(1);
imageFlip.SetInput(data);
vtk.vtkImageActor imageActor = new vtkImageActor();
imageActor.SetInput(imageFlip.GetOutput());
renderer.AddActor(imageActor);
vtkFormsWindowControl1.Update();
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}
}
}


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080927/c9b9408c/attachment.htm>


More information about the vtkusers mailing list