<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
for the records:<br>
<br>
i found a way to extract the data from a vtkVariantArray:<br>
<br>
#include <vtkSmartPointer.h><br>
#include <vtkPolyData.h><br>
#include <vtkStringArray.h><br>
#include <vtkVariantArray.h><br>
#include <string><br>
<br>
int main(int, char *[])<br>
{<br>
unsigned int N = 10;<br>
<br>
vtkSmartPointer<vtkPoints> points =<br>
vtkSmartPointer<vtkPoints>::New();<br>
vtkSmartPointer<vtkStringArray> stringAttribute_extract =<br>
vtkSmartPointer<vtkStringArray>::New();<br>
vtkSmartPointer<vtkVariantArray> variantArray =<br>
vtkSmartPointer<vtkVariantArray>::New();<br>
<br>
variantArray->SetNumberOfComponents(1);<br>
variantArray->SetName("my_variant_array");<br>
<br>
// create some points:<br>
for (unsigned int k=0; k<N; ++k) {<br>
points->InsertNextPoint((double)k, 0.0, 0.0);<br>
}<br>
<br>
// create vtkStringArray's of different size for each point:<br>
for (unsigned int k=0; k<N; ++k) {<br>
vtkSmartPointer<vtkStringArray> stringAttribute =<br>
vtkSmartPointer<vtkStringArray>::New();<br>
for (unsigned int i=0; i<k+1; ++i) {<br>
std::string s1;<br>
s1 = (char)(97+i);<br>
stringAttribute->InsertNextValue(s1.c_str());<br>
}<br>
variantArray->InsertNextValue(vtkVariant(stringAttribute));<br>
}<br>
<br>
// show content:<br>
for (int i=0; i<variantArray->GetNumberOfValues(); ++i) {<br>
stringAttribute_extract =
(vtkStringArray*)variantArray->GetValue(i).ToArray();<br>
<br>
for (int j=0;
j<stringAttribute_extract->GetNumberOfValues(); ++j) {<br>
std::cout<<stringAttribute_extract->GetValue(j)<<" ";<br>
}<br>
std::cout<<"\n";<br>
}<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
best wishes<br>
simon<br>
<br>
<div class="moz-cite-prefix">On 05.11.2014 00:48, Tanaka Simon
wrote:<br>
</div>
<blockquote cite="mid:545965B8.7080603@gmx.ch" type="cite">Dear VTK
users,
<br>
<br>
I have:
<br>
<br>
myVtkVariantArray->InsertNextValue(
vtkVariant(myVtkStringArray) );
<br>
<br>
how can i get back the myVtkStringArray? something like this does
not work:
<br>
<br>
myVtkStringArray_extract = myVtkVariantArray->getValue(...)
<br>
<br>
<br>
<br>
please have a look at the short example (attached).
<br>
<br>
thanks!
<br>
simon
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the VTK FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
<br>
</body>
</html>