<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><span>Dear Users,</span><br><span></span><br><span>I have a problem with string field data loading from ascii vtk files in c++. The file content is loaded to a vtkPolyData object from which I try to get the array of the string field data using the following:</span><br><span></span><br><span>vtkSmartPointer<vtkStringArray> array = vtkStringArray::vtkSafeDownCast(polydata->GetFieldData()->GetAbstractArray("strname",i));</span><br><span></span><br><span>The field data in the vtk file is like:</span><br><span>FIELD FieldData 1</span><br><span>strname 1 4 string</span><br><span>a</span><br><span>b</span><br><span>c</span><br><span>d</span><br><span></span><br><span>The problem is that the size of "array" (array->GetSize()) in the case above is 7 and all the elements 4..7 are empty and cause segfault if I try to read them. </span><br><span>The size of the array depends on the actual number of string values but it is really confusing:</span><br><span></span><table cellspacing="0" border="0" style="-webkit-text-size-adjust: auto;"><colgroup width="85"></colgroup><colgroup width="114"></colgroup><tbody><tr><td height="17" align="left" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">actual size</span></td><td align="left" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">array->GetSize()</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">1</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">1</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">2</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">3</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">3</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">3</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">4</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">7</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">5</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">7</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">6</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">7</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">7</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">7</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">8</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">15</span></td></tr><tr><td height="17" align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">9</span></td><td align="right" style="border: 1px solid rgb(0, 0, 0);"><span style="-webkit-text-size-adjust: none; background-color: rgba(255, 255, 255, 0);">15</span></td></tr></tbody></table>What am I doing wrong?</div><div>I use vtk7.0.0.</div><div><br></div><div>Any help would be much appreciated.</div><div><br></div><div>Regards, Eszter</div></body></html>