<div dir="ltr"><div>Thanks. I tried a similar approach but I have a number of filters lined up so I can't cast things back<br></div> to polydata at the end without breaking everything. I basically need to be able to do the same thing (manually add the arrays back in), but without having to create new polydata. I guess I need a filter that adds array data to the poly data? Does something like that exist? Is there any other way around this?<br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 29, 2017 at 4:11 PM, Charles Kind <span dir="ltr"><<a href="mailto:charles.kind@bristol.ac.uk" target="_blank">charles.kind@bristol.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Robby,<br>
<br>
Below is a function where I warp points back by half a vector in order that<br>
the vector glyph arrow is drawn later on with the center of the vector in<br>
plane. You will note that I create the warp vector field, apply it to the<br>
warp, copy these points to a polydata then extract all relevant arrays and<br>
copy the whole lot back. This may not be the correct way of doing things, I<br>
am just hacking at VTK, but it works. If you designated arrays as vector or<br>
scalar you will need to do that again afterwards.<br>
<br>
# Generate warp vectors, these vectors warp the point data<br>
# Warp centers vectors on plane, but warps base geometry<br>
def CenterVectors(self):<br>
numPoints = self.thinPD.GetNumberOfPoints(<wbr>)<br>
mtrans = vtk.vtkFloatArray()<br>
mtrans.SetNumberOfTuples(<wbr>numPoints)<br>
mtrans.SetNumberOfComponents(<wbr>3)<br>
mtrans.SetNumberOfValues(3*<wbr>numPoints)<br>
mtrans.SetName("mtrans")<br>
# Warp of -(1/2)v centers vectors if vector origin is z=0 plane<br>
for x in range(numPoints):<br>
mtrans.SetTuple3(x, \<br>
-self.thinPD.GetPointData().<wbr>GetAbstractArray('m').\<br>
GetTuple(x)[0]/2, \<br>
-self.thinPD.GetPointData().<wbr>GetAbstractArray('m').\<br>
GetTuple(x)[1]/2, \<br>
-self.thinPD.GetPointData().<wbr>GetAbstractArray('m').\<br>
GetTuple(x)[2]/2)<br>
wpd = vtk.vtkPolyData()<br>
wpd.SetPoints(self.thinPD.<wbr>GetPoints())<br>
wpd.GetPointData().SetVectors(<wbr>mtrans)<br>
# Warp vector origins<br>
warpVector = vtk.vtkWarpVector()<br>
warpVector.SetInputData(wpd)<br>
warpVector.Update()<br>
# Cast warped points and original vectors into PolyData<br>
warped = vtk.vtkPolyData()<br>
warped.SetPoints(warpVector.<wbr>GetOutput().GetPoints())<br>
noarrays = self.thinPD.GetPointData().<wbr>GetNumberOfArrays()<br>
for x in range(noarrays):<br>
warped.GetPointData().<wbr>AddArray(self.thinPD.<wbr>GetPointData()\<br>
.GetAbstractArray(x))<br>
self.thinPD = warped<br>
<br>
Luck,<br>
<br>
Charlie<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.<wbr>com/VTK-Users-f1224199.html</a><br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<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/<wbr>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_<wbr>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=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://vtk.org/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://vtk.org/mailman/<wbr>listinfo/vtkusers</a><br>
</div></div></blockquote></div><br></div>