[vtk-developers] 2 ways of representing lines
Dean Inglis
dean.inglis at on.aibn.com
Tue Aug 6 14:53:17 EDT 2002
Hi all,
I have a workaround for a long-standing pb with representing straight lines
in VTK. I recently added cross-hairs to vtkImagePlaneWidget wherein the
pipeline for the cross-hairs is basically:
<to store it>
vtkPoints *CursorPoints;
vtkPolyData *CursorPolyData;
vtkPolyDataMapper *CursorMapper;
vtkActor *CursorActor;
<and to generate it>
// Construct initial points
this->CursorPoints->SetNumberOfPoints(4);
this->CursorPolyData->SetPoints(this->CursorPoints);
this->CursorMapper->SetInput(this->CursorPolyData);
this->CursorMapper->SetResolveCoincidentTopologyToPolygonOffset();
this->CursorActor->SetMapper(this->CursorMapper);
this->CursorActor->PickableOff();
vtkCellArray *cells = vtkCellArray::New();
cells->Allocate(cells->EstimateSize(2,2));
vtkIdType pts[2];
pts[0] = 0; pts[1] = 1; // horizontal segment
cells->InsertNextCell(2,pts);
pts[0] = 2; pts[1] = 3; // vertical segment
cells->InsertNextCell(2,pts);
this->CursorPolyData->SetLines(cells);
this->CursorPolyData->Modified();
cells->Delete();
<snip>
Well, if one zooms in on a vtkImagePlaneWidget, the image data can still be
queried (i.e. the picking is functional) but the cross-hairs disappear. Try
/Examples/GUI/Tcl/ImagePlaneWidget.tcl without the line:
<snip>
[ren1 GetCullers] RemoveAllItems
<snip>
Hmmmmm. I am considering changing the representation of the cross-hairs to
avoid this messing about with the cullers:
<new representation>
vtkLineSource *CursorLine1;
vtkLineSource *CursorLine2;
vtkAppendPolyData *CursorPolyData;
vtkPolyDataMapper *CursorMapper;
vtkActor *CursorActor;
<snip>
I've tested and it works. Any thoughts before I make this change?
Dean
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dean Inglis, Ph.D.
Clinical Research Unit
25 Charlton Avenue East, Unit 610
Hamilton, ONT, L8N 1Y2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the vtk-developers
mailing list