<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Try using the InsertNextValue(), GetValue() and SetValue() methods:<div class=""><br class=""></div><div class="">
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><!--StartFragment--><span style=" color:#808000;" class="">int</span><span style=" color:#c0c0c0;" class=""> </span>main()<span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkFloatArray</span>><span style=" color:#c0c0c0;" class=""> </span>flame<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkSmartPointer</span><<span style=" color:#800080;" class="">vtkFloatArray</span>>::New();</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>flame-><span style="font-style: italic;" class="">SetNumberOfComponents</span>(<span style=" color:#000080;" class="">1</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">for</span><span style=" color:#c0c0c0;" class=""> </span>(<span style=" color:#808000;" class="">int</span><span style=" color:#c0c0c0;" class=""> </span>i<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#000080;" class="">0</span>;<span style=" color:#c0c0c0;" class=""> </span>i<span style=" color:#c0c0c0;" class=""> </span><<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#000080;" class="">10</span>;<span style=" color:#c0c0c0;" class=""> </span>i++)<span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>flame->InsertNextValue(i);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkIdType</span><span style=" color:#c0c0c0;" class=""> </span>id<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span>i;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>cout<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>flame->GetValue(id)<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">",</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>flame->GetValue(id-<span style=" color:#000080;" class="">1</span>)<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>endl;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>cout<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"nTuples</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>flame->GetNumberOfTuples()<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>endl;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>cout<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"Contents</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">of</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">flame:</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>endl;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">for</span><span style=" color:#c0c0c0;" class=""> </span>(<span style=" color:#808000;" class="">int</span><span style=" color:#c0c0c0;" class=""> </span>i<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#000080;" class="">0</span>;<span style=" color:#c0c0c0;" class=""> </span>i<span style=" color:#c0c0c0;" class=""> </span><<span style=" color:#c0c0c0;" class=""> </span>flame->GetNumberOfTuples();<span style=" color:#c0c0c0;" class=""> </span>i++)<span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkIdType</span><span style=" color:#c0c0c0;" class=""> </span>id<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span>i;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>cout<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"i</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>i<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">",</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">flame["</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>i<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"]</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span><<</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>flame->GetValue(id)<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>endl;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">//Okay,</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">maybe</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">if</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">we</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">use</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">SetNumberOfTuples</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">and</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">SetTuple1</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">it</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">will</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">work.</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">//</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">Nope!</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">vtkIdType</span><span style=" color:#c0c0c0;" class=""> </span>id<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#000080;" class="">0</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>flame->SetValue(id,<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#000080;" class="">99</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">float</span><span style=" color:#c0c0c0;" class=""> </span>retrieved<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span>flame->GetValue(id);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>cout<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"retrieved</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>retrieved<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>endl;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>retrieved<span style=" color:#c0c0c0;" class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span>flame->GetValue(-<span style=" color:#000080;" class="">1</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span>cout<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"retrieved</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">=</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>retrieved<span style=" color:#c0c0c0;" class=""> </span><<<span style=" color:#c0c0c0;" class=""> </span>endl;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">return</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#000080;" class="">0</span>;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class="">}<!--EndFragment--></pre><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 19 May 2016, at 18:26, jbouffar <<a href="mailto:julian.m.bouffard@erdc.dren.mil" class="">julian.m.bouffard@erdc.dren.mil</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello,<br class=""><br class="">I have a strange question. It seems the first element I put into a<br class="">vtkFloatArray is missing, so that if I construct a new floatArray element by<br class="">element from some other arrays, they are out of sync by one element. I have<br class="">written some code in c++ to illustrate this (below). Even weirder (to me)<br class="">it seems I can access the [-1] component, and it works! What is going on<br class="">here? I have tried also using SetNumberOfTuples and SetTuple, but this<br class="">doesn't even work. This is VTK 6.3.<br class=""><br class="">int main(int argc, char** argv){<br class=""><br class=""> vtkSmartPointer<vtkFloatArray> flame =<br class="">vtkSmartPointer<vtkFloatArray>::New();<br class=""> flame->SetNumberOfComponents(1);<br class=""><br class=""> for(int i = 0; i < 10; i++){<br class=""> flame->InsertNextTuple1(i);<br class=""> vtkIdType id = i;<br class=""> cout << flame->GetComponent(id,1) << ", " << flame->GetComponent(id-1,1)<br class=""><< endl;<br class=""> }<br class=""><br class=""> cout << "nTuples = " << flame->GetNumberOfTuples() << endl;<br class=""><br class=""> cout << "Contents of flame: " << endl;<br class=""> for(int i = 0; i < flame->GetNumberOfTuples(); i++){<br class=""> vtkIdType id = i;<br class=""> cout << "i = " << i << ", flame[" << i << "] = " << <br class="">flame->GetComponent(id,1) << endl;<br class=""> }<br class=""><br class=""> //Okay, maybe if we use SetNumberOfTuples and SetTuple1 it will work.<br class="">Nope!<br class=""> vtkIdType id = 0;<br class=""> flame->SetTuple1(id, 99);<br class=""> float retrieved = flame->GetComponent(id,1);<br class=""> cout << "retrieved = " << retrieved << endl;<br class=""> retrieved = flame->GetComponent(-1,1);<br class=""> cout << "retrieved = " << retrieved << endl;<br class=""><br class=""> return 0;<br class="">}<br class=""><br class="">Output:<br class=""><br class="">4.58589e-41, 0<br class="">2.13737e+11, 1<br class="">4.58589e-41, 2<br class="">0, 3<br class="">0, 4<br class="">1.99685e-42, 5<br class="">0, 6<br class="">2.13737e+11, 7<br class="">4.58589e-41, 8<br class="">1.97443e-42, 9<br class="">nTuples = 10<br class="">Contents of flame:<br class="">i = 0, flame[0] = 1<br class="">i = 1, flame[1] = 2<br class="">i = 2, flame[2] = 3<br class="">i = 3, flame[3] = 4<br class="">i = 4, flame[4] = 5<br class="">i = 5, flame[5] = 6<br class="">i = 6, flame[6] = 7<br class="">i = 7, flame[7] = 8<br class="">i = 8, flame[8] = 9<br class="">i = 9, flame[9] = 1.97443e-42<br class="">retrieved = 1<br class="">retrieved = 99<br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><br class="">--<br class="">View this message in context: <a href="http://vtk.1045678.n5.nabble.com/filling-a-vtkFloatArray-first-element-tp5738146.html" class="">http://vtk.1045678.n5.nabble.com/filling-a-vtkFloatArray-first-element-tp5738146.html</a><br class="">Sent from the VTK - Users mailing list archive at <a href="http://nabble.com" class="">Nabble.com</a>.<br class="">_______________________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" class="">http://www.vtk.org/Wiki/VTK_FAQ</a><br class=""><br class="">Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" class="">http://markmail.org/search/?q=vtkusers</a><br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class=""><a href="http://public.kitware.com/mailman/listinfo/vtkusers" class="">http://public.kitware.com/mailman/listinfo/vtkusers</a><br class=""></div></div></blockquote></div><br class=""></div></body></html>