<div dir="ltr">Jaap,<div><br></div><div>There should be no need to append the different array components in this scenario. It should be handled directly by the numpy_support.numpy_to_vtk function.<br><div><br></div><div>Try this:</div><div><br></div><div>import vtk</div><div>import vtk.util.numpy_support as ns<br></div><div>import numpy as np</div><div><br></div><div>Array = np.empty([235,3])<br></div><div>vtkarr = ns.numpy_to_vtk(num_array=Array, deep=True, array_type=vtk.VTK_DOUBLE)<br></div></div><div><br></div><div><div>>>> vtkarr.GetNumberOfTuples()</div><div>235L</div></div><div><div>>>> vtkarr.GetNumberOfComponents()</div><div>3</div></div><div><br></div><div>HTH,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 25, 2015 at 4:14 AM, Jaap Verheggen <span dir="ltr"><<a href="mailto:jpmverheggen@gmail.com" target="_blank">jpmverheggen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hello, <br>
    <br>
    I am Looking for an easy way to create my point data with Python. I
    can make three single component arrays, but do not know how to
    combine that into one three component array which I can feed into a
    vtkpoints container.<br>
    <br>
    # Let's say I have an array of point data, large enough that a loop
    should be avoided<br>
    Array = np.empty([235, 3])<br>
    #I can deconstruct the array in x, y and z<br>
    VTK_datax = numpy_support.numpy_to_vtk(num_array=Array[:,0].ravel(),
    deep=True, array_type=vtk.VTK_DOUBLE)<br>
    VTK_datay = numpy_support.numpy_to_vtk(num_array=Array[:,1].ravel(),
    deep=True, array_type=vtk.VTK_DOUBLE)<br>
    VTK_dataz = numpy_support.numpy_to_vtk(num_array=Array[:,2].ravel(),
    deep=True, array_type=vtk.VTK_DOUBLE)<br>
    # Maybe I will need a VTK ID array (0..235) Lets just make one<br>
    VTK_ID =
    numpy_support.numpy_to_vtk(num_array=np.arange(shape(Array)[0]).ravel(),
    deep=True, array_type=vtk.VTK_ID_TYPE)<br>
    # Now I would like to combine x, y and z data into a single array<br>
    VTK_data = vtk.vtkDoubleArray()<br>
    VTK_data.SetNumberOfComponents(3)<br>
    VTK_data.SetNumberOfTuples(235)<br>
    # However, I do not know how to do this, it could be something like
    this, VTK_data.SetTuple3(VTK_ID, VTK_datax, VTK_datay, VTK_dataz )
    but that doesn't work with arrays. <br>
    # Afterwards, I would like to fill the data array into a points
    container<br>
    points = vtk.vtkPoints()<br>
    points.SetData(pcoords)<br>
    <br>
    Is there a way to combine three single component arrays into a three
    component array?<br>
    <br>
    Thanks in advance, <br><span class="HOEnZb"><font color="#888888">
    <p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br>
      </p>
    
    <br>
    <br>
    <br>
    <br>
    <pre cols="72">-- 
---------------------------
Jaap Verheggen
</pre>
  </font></span></div>

<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>