[vtkusers] problem with CellPicker

nmitreski nimitreski at gmail.com
Mon Mar 10 03:25:08 EDT 2008


I think that I have a solution to my problem. My only problem now is how to
tell to system that vtkCellArray that I' m using must be of type
VTK_TRIANGLE or VTK_POLYGON. I made it with InsertNextCell(VTK_TRIANGLE,
ptsid) method from vtkPolyData. That was not my intention. When I'm using
InsertNextCell( ) from vtkPolyData everything is fine, except that I' m
getting only one cell selected. When I was working with vtkCellArray at
every different click I get different cell, but cells that have been picked
previously still were in red color that indicated that they were picked. Now
there just only one cell with red color. Problem was in my previous program
that when clikking several times on one cell, sometimes program just
crashes. When entering debugging about error, I realize that internal method
GetCell was entering in case VTK_TRIANGLESTRIP. I think that this was only
problem. How to tell to vtkCellArray when forming cells which type of cell
to use.

thanks


Philipp Hartl wrote:
> 
> 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
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 

-- 
View this message in context: http://www.nabble.com/problem-with-CellPicker-tp15891092p15950582.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list