[vtk-developers] Generic method for getting a sub-cell

David Gobbi david.gobbi at gmail.com
Fri Apr 2 11:28:22 EDT 2010


Yes, I agree, precision is good.

I noticed the problem when I changed vtkCellPicker to go through the
data subcell-by-subcell instead of cell-by-cell.  One of the widget
tests started failed because IntersectWithLine gives different results
if CellPicker calls it on a polyline vs. if it breaks the polyline
into segments first.

   David


On Fri, Apr 2, 2010 at 9:10 AM, Will Schroeder
<will.schroeder at kitware.com> wrote:
> I've seen this problem too (and fixed it in my versions of VTK). I
> think in the initial implementation the developers were more
> interested in knowing whether there was a hit, and getting that
> information as quickly as possible (hence bailing out of the loop). In
> recent times, users have started depending on VTK to provide precise
> information....I think it's time to change this.
>
> On Fri, Apr 2, 2010 at 10:33 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>> Speaking of subcells, I've identified a problem with the way that
>> IntersectWithLine is implemented in vtkTriangleStrip et al.  The
>> way IntersectWithLine is implemented in these classes is:
>>
>> for triangle in strip:
>>  if triangle->IntersectWithLine(tol)
>>     return
>>
>> In other words, the loop alway stops at first hit, but due to
>> tolerance there might be more than one potential hit.  It
>> could, instead, look for all potential hits and then use
>> ParametricDistance() as a tiebreaker.
>>
>>  - David
>>
>>
>> On Thu, Apr 1, 2010 at 2:38 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>> Hi Will,
>>>
>>> Yes, all the efficient (npts, pts) API styles would also have to be
>>> supported.  Ideally every GetCell method signature would need an
>>> equivalent GetSubCell method.  The following classes would need to be
>>> changed:
>>>
>>> vtkDataSet
>>> vtkCell (the base class)
>>> vtkGenericCell
>>> vtkTriangleStrip et all
>>>
>>> You are correct that most of the cell classes would be unaffected.
>>> Only vtkTriangleStrip and similar classes would have to be modified.
>>>
>>>  David
>>>
>>>
>>> On Thu, Apr 1, 2010 at 2:17 PM, Will Schroeder
>>> <will.schroeder at kitware.com> wrote:
>>>> David in the long term I don't see why we couldn't easily add
>>>> something like this to both the cell and dataset APIs. To minimize the
>>>> initial effort (i.e., so you don't have to do it to all the datasets)
>>>> I'd initially just add it to the affected cell types (e.g., triangle
>>>> strip, polyline, polyvert, etc.) Also, if I understand correctly you
>>>> are returning a new cell (or a pointer to an internal cell instance),
>>>> have you looked at alternative APIs to return the information faster,
>>>> and more compactly? I'm thinking of something akin to
>>>> vtkCellArray::GetNextCell(npts,pts)...just curious.
>>>>
>>>>
>>>> On Thu, Apr 1, 2010 at 1:40 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>> Hi All,
>>>>>
>>>>> Would it be possible to add a generic method for getting a sub-cell from a cell?
>>>>>
>>>>> vtkCell *cell->GetSubCell(int subId);
>>>>> void cell->GetSubCell(int subId, vtkGenericCell *subCell);
>>>>>
>>>>> Even better would be an easy way of iterating through the sub-cells in
>>>>> a vtkDataSet directly:
>>>>>
>>>>> data->GetNumberOfSubCells(vtkIdType cellId);
>>>>> data->GetSubCell(vtkIdType cellId, int subId, vtkGenericCell *subCell);
>>>>>
>>>>> There are several times when I've had to add special cases to my code
>>>>> to handle triangle strips, and if there was a generic method for
>>>>> getting sub-cells, my code could be a lot simpler.
>>>>>
>>>>>   David
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> William J. Schroeder, PhD
>>>> Kitware, Inc.
>>>> 28 Corporate Drive
>>>> Clifton Park, NY 12065
>>>> will.schroeder at kitware.com
>>>> http://www.kitware.com
>>>> (518) 881-4902
>>>>
>>>
>>
>
>
>
> --
> William J. Schroeder, PhD
> Kitware, Inc.
> 28 Corporate Drive
> Clifton Park, NY 12065
> will.schroeder at kitware.com
> http://www.kitware.com
> (518) 881-4902
>



More information about the vtk-developers mailing list