<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Both arguments to GetComponent are zero based -- so to get the first component of the first tuple, you should call GetComponent(0, 0), not GetComponent(0, 1).</div><div class="gmail_quote"><br></div><div class="gmail_quote">HTH,</div><div class="gmail_quote">Dave</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Thu, May 19, 2016 at 12:26 PM, jbouffar <span dir="ltr"><<a href="mailto:julian.m.bouffard@erdc.dren.mil" target="_blank">julian.m.bouffard@erdc.dren.mil</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a strange question.  It seems the first element I put into a<br>
vtkFloatArray is missing, so that if I construct a new floatArray element by<br>
element from some other arrays, they are out of sync by one element.  I have<br>
written some code in c++ to illustrate this (below).  Even weirder (to me)<br>
it seems I can access the [-1] component, and it works! What is going on<br>
here? I have tried also using SetNumberOfTuples and SetTuple, but this<br>
doesn't even work. This is VTK 6.3.<br>
<br>
int main(int argc, char** argv){<br>
<br>
  vtkSmartPointer<vtkFloatArray> flame =<br>
vtkSmartPointer<vtkFloatArray>::New();<br>
  flame->SetNumberOfComponents(1);<br>
<br>
  for(int i = 0; i < 10; i++){<br>
    flame->InsertNextTuple1(i);<br>
    vtkIdType id = i;<br>
    cout << flame->GetComponent(id,1) << ", " << flame->GetComponent(id-1,1)<br>
<< endl;<br>
  }<br>
<br>
  cout << "nTuples = " << flame->GetNumberOfTuples() << endl;<br>
<br>
  cout << "Contents of flame: " << endl;<br>
  for(int i = 0; i < flame->GetNumberOfTuples(); i++){<br>
    vtkIdType id = i;<br>
    cout << "i = " << i << ", flame[" << i << "] = " <<<br>
flame->GetComponent(id,1) << endl;<br>
  }<br>
<br>
  //Okay, maybe if we use SetNumberOfTuples and SetTuple1 it will work.<br>
Nope!<br>
  vtkIdType id = 0;<br>
  flame->SetTuple1(id, 99);<br>
  float retrieved = flame->GetComponent(id,1);<br>
  cout << "retrieved = " << retrieved << endl;<br>
  retrieved = flame->GetComponent(-1,1);<br>
  cout << "retrieved = " << retrieved << endl;<br>
<br>
  return 0;<br>
}<br>
<br>
Output:<br>
<br>
4.58589e-41, 0<br>
2.13737e+11, 1<br>
4.58589e-41, 2<br>
0, 3<br>
0, 4<br>
1.99685e-42, 5<br>
0, 6<br>
2.13737e+11, 7<br>
4.58589e-41, 8<br>
1.97443e-42, 9<br>
nTuples = 10<br>
Contents of flame:<br>
i = 0, flame[0] = 1<br>
i = 1, flame[1] = 2<br>
i = 2, flame[2] = 3<br>
i = 3, flame[3] = 4<br>
i = 4, flame[4] = 5<br>
i = 5, flame[5] = 6<br>
i = 6, flame[6] = 7<br>
i = 7, flame[7] = 8<br>
i = 8, flame[8] = 9<br>
i = 9, flame[9] = 1.97443e-42<br>
retrieved = 1<br>
retrieved = 99<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/filling-a-vtkFloatArray-first-element-tp5738146.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/filling-a-vtkFloatArray-first-element-tp5738146.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div></div>