On Mon, Nov 7, 2016 at 9:00 AM, Christian Gabriel <
cgabr...@matrix-solutions.com> wrote:

> Good day.
>
>
>
> I found this example code
> <http://www.paraview.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/Cell3DDemonstration>
> :
>
>
>
>     # Create the points
>
>     points = vtk.vtkPoints()
>
>     points.InsertNextPoint(0.0, 0.0, 0.0)
>
>     points.InsertNextPoint(1.0, 0.0, 0.0)
>
>     points.InsertNextPoint(1.0, 1.0, 0.0)
>
>     points.InsertNextPoint(0.0, 1.0, 0.0)
>
>     … … …
>
>
>
> which had me wonder if there is a way to assign data in a vectorized
> fashion instead of point by point?
>
>
>
> Let’s say I can read in 3 1D arrays (vectors) with X, Y, Z data or one 2D
> array (matrix, dataframe) with the same data in columns, is there a way to
> assign that data to the points all at once instead of iteratively?
>
>
>
>     points = vtk.vtkPoints()
>
>     points.InsertNextPoint(X, Y, Z)    - just saying; this is obviously
> not correct!
>
>
>
> Obviously, any data could be combined and reshaped first to whatever
> format required ….
>
>
>
> Given that ParaView/VTK was designed to work with (very) large data sets
> I’d be surprised if there were no vectorized operations implemented.
>

In C++, there are a number of ways to do this by modifying the data array
directly (instead of going through the vtkPoints interface). You can
extract the data array from the points by calling points.GetData(). You can
also create a points array separately and assign it to the vtkPoints
instance by calling points.SetData(myArray).

There are two types of arrays in VTK, AoS (Array-of-Structs, the default
used for e.g. vtkFloatArray, etc), and SoA (Struct-of-Arrays, still
somewhat experimental at this point):

These doxygen pages describe the specific APIs for them:

http://www.vtk.org/doc/nightly/html/classvtkAOSDataArrayTemplate.html
http://www.vtk.org/doc/nightly/html/classvtkSOADataArrayTemplate.html

There are several ways to do low-level copying of data using methods like
AoS::SetArray, SoA::SetComponentArray, AoS::GetPointer,
SoA::GetComponentArrayPointer, etc, which will allow you to set the array's
memory buffer explicitly, or just get low-level access to it for for
modifications.

However, I'm not sure how much of this is exposed in the python/numpy
layers, so it might take some experimentation. Hopefully someone more
familiar with the python bindings will chime in.

HTH,
Dave
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to