[vtkusers] problem with CellPicker
Philipp Hartl
philipp.hartl at bkf.at
Fri Mar 7 12:45:46 EST 2008
Hello,
Do you get an Null-Pointer Exception or what? I think you should not
allocate every pick event space of 1000 lines. Have you attached your
picker to your interactor? Maybe you can post some failure messages?
Cheers,
Philipp
nmitreski schrieb:
> 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
More information about the vtkusers
mailing list