[vtkusers] Cell ID (and vtkCellData)

Gerrick Bivins Gerrick.Bivins at halliburton.com
Tue Apr 9 10:04:12 EDT 2013


Hi,
Yes, indexOfCell == nTuple.
Also, where you have nComponent, that is the index into the array so in your case sounds like that should be zero since your data is a single value per cell.
If it were a vector, for example, you could get back a specific component of the vector using GetComponent. I tend to use
GetTuple(). This gives the data back as an array and you can then decide what to do with the components.

double[] cellTupleValue = pCellData->GetArray(nArray)->GetTuple(indexOfCell);

If you the specific "typed" data returned, you'll need to use the more specific "typed" data arrays (vtkIntArray,vtkFloatArray etc).
They have methods to get the data as it's "typed" (GetValue()).
Hope that's useful
Gerrick

-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Michal Szostakiewicz
Sent: Tuesday, April 09, 2013 5:54 AM
To: Alex Malyushytskyy
Cc: VTK
Subject: Re: [vtkusers] Cell ID (and vtkCellData)

Thanks for the answer, I'll try to make myself clear this time.
(by the way I think I figured out one of the answers but I want to double
check)

Maybe it's best to illustrate my questions with a samples of code.
So what I do:

1. load some VTK file with vtkGenericDataObjectReader. Let's suppose I get a vtkUnstructuredGrid* pGrid with that.
2. in this pGrid I call GetCellData() and that's where I get vtkCellData (lets call it pCellData) from.
3. now there comes a tricky part. I use GetComponent() method to access the data, so I would call it like this:
pCellData->GetArray(nArray)->GetComponent(nTuple, nComponent)

Piece of cake, but the problem is: what should be passed as a nTuple?
I believe it's the index of the cell, the same which is passed to:
pGrid->GetCell(nTuple)

Am I right?

And another question is: what is the proper way to access data from vtkDataArray? GetComponent() works just fine, but it always converts to double and I believe there should be some faster (and "native") method.


BTW is it just me, or did some pictures in the documentation broke?
(eg. http://www.vtk.org/doc/nightly/html/classvtkCellData.html)

Best regards,
Michał

> As for me there is no enough details to provide you with helpful advice.
> I am not sure I can follow what you said either.
> If you want just to be able to read some of the vtk file formats, 
> start with file format (extension) you want to read.
> Google vtk file format. For example some details on forma can be found at:
> http://www.cacr.caltech.edu/~slombey/asci/vtk/vtk_formats.simple.html
>
>
> But in this case why would you ask questions about vtkCellData or 
> other VTK classes?
> If you are going to use vtk classes give details on the dataset you 
> are trying to work with.
>
> Regards,
>     Alex
>
>
>
>
>
> On Mon, Apr 8, 2013 at 10:30 AM, Michal Szostakiewicz
> <creed at icm.edu.pl>wrote:
>
>> Dear all!
>>
>> I'm not really a VTK user, but I just want to load a VTK file into my 
>> software. I have a problem with reading cell data. As I couldn't find 
>> a documentation on that, I thought it would be good idea to ask here, 
>> but if the answer to my question is written somewhere, please just 
>> give me the link.
>>
>> If I understand correctly, the cell data is described in vtkCellData 
>> class, which is collection of vtkDataArray-s. I currently access this 
>> data array with GetComponent method (I believe there is a better way, 
>> but I don't know it) but for that I need to specify the cell's ID or 
>> the cell's index in the tuple.
>>
>> Is this the same ID I give in vtkPointSet's GetCell(int id) method?
>>
>> Because it sometimes works well, but other times produces some 
>> strange results... And vtkCell does not have any GetID() method (and 
>> it looks like
>> GetVTKid() is not the one I'm looking for)
>>
>>
>> Best regards,
>> Michał
>>
>> _______________________________________________
>> 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
>>
>

_______________________________________________
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

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.



More information about the vtkusers mailing list