[vtkusers] In vtkCellPicker assertion from GetCellType fails
David E DeMarle
dave.demarle at kitware.com
Wed Sep 19 14:53:34 EDT 2018
You might try and bypass the problem by setting the actor for the point
cloud to be non pickable.
David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
On Mon, Sep 17, 2018 at 4:38 PM Jaspar Löchte <jstach at uni-osnabrueck.de>
wrote:
> Hello there!
>
> I use VTK 6.3 in a project for my thesis in an Qt desktop application.
>
> I am storing Pointclouds and do some manipulation, calculating hulls, etc.
> For the hulls I display some vtkLines in an extra vtkActor and wanted to
> create a possiblity to modify the polygon.
>
> Therfore i want to be able to move points AND want to pick lines and
> create a new Point on the line to be able to move that one to.
>
> So I wanted to use the vtkCellPicker to pick the lines (which works quite
> well so far …).
>
> Since I needed a ContextMenu in Qt I manipulated the MouseEvents and use
> them allready in the Qt MainWindow. Like this:
> https://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/EventQtSlotConnect
>
> In my Code I want to detect a vtkLine with this vtkCellPicker, like this:
>
> m_picker->Pick(x, y, 0, m_mainStyle->GetDefaultRenderer());
> long l = m_cicker->GetCellId();
> if(l > 0)
> {
> vtkSmartPointer<vtkActor> actor = m_picker->GetActor();
> long O = actor->GetMapper()->GetInput()->GetCellType(l);
>
> if(O == 3)
> {
> vtkSmartPointer<vtkLine> line =
> vtkLine::SafeDownCast(actor->GetMapper()->GetInput()->GetCell(l));
> vtkSmartPointer<vtkPoints> points = line->GetPoints();
> double p[3];
> if(points->GetNumberOfPoints() > 0)
> {
> for(int i = 0; i < points->GetNumberOfPoints(); i++)
> {
> points->GetPoint(i, p);
> std::cout << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")" <<
> std::endl;
> }
> }
> }
> }
>
> As I said … this works pretty well, except for any random points, the
> CellPicker also picks vertices from the Pointcloud (CellType == 1) and on
> random points my program crashes, because of an assertion fail …
>
> I found out that the call to vtkCellPicker::Pick() calls superclass vtkPicker::Pick()
> and there is a call to IntersectWithLine() from the CellPicker, in this
> function the call to IntersectActorWithLine() calls in line 414 this one
> int cellType = data->GetCellType(cellId); … and here I get the assertion
> fail:
>
> viewer:
> /build/vtk6-YpT4yb/vtk6-6.2.0+dfsg1/Common/Core/vtkDataArrayTemplate.h:191:
> T vtkDataArrayTemplate<T>::GetValue(vtkIdType) [with T = unsigned char;
> vtkIdType = long long int]: Assertion `id >= 0 && id < this->Size' failed.
>
> Refered to
> https://github.com/Kitware/VTK/blob/release-6.3/Rendering/Core/vtkCellPicker.cxx#L414
>
> I really don’t know how to debug this, and why this happens.
>
> Any Ideas for me?
>
> If there is anything not clear - ask me, I can try to go more into detail,
> give more Code, or something like that.
>
> Thank you!
>
> Jaspar
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180919/3b1c0a17/attachment.html>
More information about the vtkusers
mailing list