[vtkusers] problem with CellPicker
nmitreski
nimitreski at gmail.com
Fri Mar 7 03:36:45 EST 2008
I have a little problem with my application. Here is part of the code
class vtkMyCallback : public vtkCommand
{
public:
static vtkMyCallback *New()
{
return new vtkMyCallback;
}
void Delete()
{
delete this;
}
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
if (cell_picker->GetCellId() == -1)
{
contour->Reset();
lines->Reset();
modified_actor->VisibilityOff();
littleactor->VisibilityOff();
}
else
{
cell_id = cell_picker->GetCellId();
cout<<"cell id = "<<cell_id<<endl;
vtkIdType npts, *pts;
mesh->GetCellPoints(cell_id, npts, pts);
lines->Allocate(1, 1000);
lines->InsertNextCell(npts, pts);
//lines->InsertCellPoint(pts[0]);
//lines->InsertCellPoint(pts[1]);
//lines->InsertCellPoint(pts[2]);
contour->SetPolys(lines); //here we are making new polydata
modified_mapper = vtkPolyDataMapper::New();
modified_mapper->SetInput(contour);
modified_actor->SetMapper(modified_mapper);
modified_actor->VisibilityOn();
//
double selPt[3];
cell_picker->GetSelectionPoint(selPt);
double pickcoords[3];
cell_picker->GetPickPosition(pickcoords);
cout<<"x = "<<pickcoords[0]<<endl;
cout<<"y = "<<pickcoords[1]<<endl;
cout<<"z = "<<pickcoords[2]<<endl;
cout<<endl;
//littlemapper = vtkPolyDataMapper::New();
littlemapper->SetInput(littleSphere->GetOutput() );
littleactor->SetMapper(littlemapper);
littleactor->SetPosition(pickcoords);
littleactor->VisibilityOn();
}
renWin->Render();
}
};
this is my class which I'm using in
picker->AddObserver(vtkCommand::EndPickEvent, pickObserver);
pickObserver is instance of my class. My problem is: when I'm clicking
several times fast on same point, my application crashes.. I can't find what
is the problem? Any help?
thanks
--
View this message in context: http://www.nabble.com/problem-with-CellPicker-tp15891092p15891092.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list