[vtkusers] vtkDataSetSurfaceFilter - Cell Picking

David E DeMarle dave.demarle at kitware.com
Wed Mar 6 10:25:11 EST 2013


Sorry for the confusion, it has been a long time since I added that code
the DataSetSurfaceFilter. Turning PassThroughCell/PointIds in fact
generates a new Ids array, which you can retrieve after the fact to do the
lookups into the data that is input to the DSF and extract particular
cells/points by their offset (n'th cell in the cell array, n'th point in
the point array)

However I still recommend making your own ids array and using that instead
of PassThrough. vtkIdFilter will generate them for you. The array marked as
the active global ids array is treated specially by most filters in that
they try to preserve it across operations (including threshold and DSF). We
added this to VTK a few years ago specifically for this case of finding out
where particular result values come from (and in particular for surface
selection). So the Threshold and surface filter will push globalIDS forward
just fine. Once you get a result, grab the active globaIDs array, look for
the values in it, and look them up in the original data. The extract
selections filter will do the job of looking them up in the original data
and pulling them out as a new dataset.


David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Wed, Mar 6, 2013 at 10:02 AM, Bhanu Hariharan <bhanu at petrotel.com> wrote:

> David,
> Thanks for replying. However I have a doubt.
> Are you suggesting the VTKUnstructuredgrid should have an globalids array?
> Is that what the member is called - globalIds? I actually pass
> VTKUnstructuredgrid  to a VTKThreshold filter and then pass that filter to
> VTKdatasetsurfacefilter.
>
> Perhaps you can post a couple lines of code. That would be very helpful.
> Thanks,
> Bhanu
>
>
>
> On Tue, Mar 5, 2013 at 6:55 PM, David E DeMarle <dave.demarle at kitware.com>wrote:
>
>> The input data should have a globalids array containing a unique value
>> for each cell. If it does, extract will preserve it. After the extraction,
>> use that array in the polydata to do the look up to the original cell in
>> the unstructured grid.
>> On Mar 5, 2013 6:00 PM, "Bhanu Hariharan" <bhanu at petrotel.com> wrote:
>>
>>> Hi All,
>>>
>>> I need some help doing the following. Please could one of you guide me
>>> on how.
>>>
>>> I use a vtkDataSetSurfaceFilter on VTKUnstructuredGrid to render skin of
>>> that grid. That works fine and I can see the number of surfaces shown by
>>> grabbing the
>>> dataSetSurfaceFilter->GetOutput()->GetNumberOfCells().
>>>
>>>
>>> I need a way to map the surface back to the original cell id. That is if
>>> I have 2 cells and I render just skin, number of surfaces rendered are 10.
>>> I need to be able to pick on any of these 10 surfaces and map them back to
>>> either of the the 2 grid cells.
>>>
>>>
>>> http://www.vtk.org/doc says :
>>>
>>> If PassThroughCellIdsOn is 1, then the output polygonal dataset will
>>> have a celldata array that holds the cell index of the original 3D cell
>>> that produced each output cell. This is useful for cell picking.
>>> I turned the PassThroughCellIds On and I have UseStrips turned off.
>>>
>>> Then I did
>>> vtkPolyData *surfacePolyData = dataSetSurfaceFilter->GetOutput();
>>>
>>> But I do not see how I can access that celldata array that holds the
>>> original 3D cells for the surfaces.
>>>
>>> Please can anyone advise on how.
>>>
>>> Thanks in advance.
>>> Bhanu
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130306/76152ebf/attachment.htm>


More information about the vtkusers mailing list