[vtkusers] vtkStringArray with heterogeneous number of components?

David Thompson david.thompson at kitware.com
Tue Nov 4 12:32:53 EST 2014


Hi Simon,

You might use a pair of arrays: a StringArray (with NumberOfComponents=1) and an IntArray that stores offsets to the start of each tuple. This is efficient as long as you will not be changing the length of  entries or adding/removing entries.

	David

> You can do this with a vtkVariantArray, because a vtkVariantArray is
> an array of "anything" so it allows you to store a vtkStringArray for
> each of your points. It wouldn't be very efficient, however.
> 
> My recommendation would be to just use a vtkStringArray and then
> use some kind of string delimiter like ";" or ",", for example if the string
> is "one;two" you would write your own code to interpret that as multiple
> values.
> 
>  - David  
> 
> 
> On Tue, Nov 4, 2014 at 9:12 AM, Tanaka Simon <tanakas at gmx.ch> wrote:
> Dear VTK users,
> 
> I want to have a vtkStringArray, but the number of components shall NOT be the same for all points.
> 
> Example (a sample code is attached):
> -> for point 1, the string attribute should be "one"
> -> for point2, the string attributes should be "one" and "two"
> -> etc.
> 
> That is like std::vector< std::vector<...> > where the inner vectors may have different length.
> 
> 
> What would be the approach:
> -> heterogeneous number of components?
> -> heterogeneous number of tuples?
> -> not vtkStringArray, but some other vtkXXXArray containing another container with variable length?
> 
> 
> Thanks for any suggestions
> Simon
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers



More information about the vtkusers mailing list