<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Andrew,<br>
<br>
I see a couple of things in your script. First is normals and
scalars are data set attributes. so you need to access them through
one of those classes, ex vtkPointData. <br>
<br>
Correct me if I'm wrong but, although in VTK 6 you generally don't
need to shallow copy the input to filters I think it's still
probably a bad practice to modify the arrays in the input dataset. <br>
<br>
I think what you want to do is copy the geometric structure of the
input and then make a deep copy of normals and scalars arrays, and
rename the copys. Copy structure rather than shallow copy since with
a shallow copy you'd still end up modifying the arrays in the input
dataset.<br>
<br>
Finally scalars and normals may not be present. I know you'd
probably handle that in your final script, ;-)<br>
<br>
given all that, here's what I came up with:<br>
<blockquote>def copyAndNameArray(da, name):<br>
if da is not None:<br>
outda = da.NewInstance()<br>
outda.DeepCopy(da)<br>
outda.SetName(name)<br>
return outda<br>
else:<br>
return None<br>
<br>
pdi = self.GetPolyDataInput()<br>
pdo = self.GetPolyDataOutput()<br>
pdo.CopyStructure(pdi)<br>
<br>
pdo.GetPointData().SetNormals( \<br>
copyAndNameArray(pdi.GetPointData().GetNormals(), 'Normals'))<br>
<br>
pdo.GetPointData().SetScalars( \<br>
copyAndNameArray(pdi.GetPointData().GetScalars(), 'Scalars'))<br>
<br>
print 'Normals=%s'%(str(pdo.GetPointData().GetNormals()))<br>
print 'Scalars=%s'%(str(pdo.GetPointData().GetScalars()))<br>
</blockquote>
Curious to hear from other developers as to if I'm on target about
not modifying arrays in the input or if this is overkill given the
new VTK 6 pipeline.<br>
<br>
Burlen<br>
<br>
On 05/30/2014 07:29 PM, Andrew Maclean wrote:<br>
<blockquote
cite="mid:CAHDsG9ND+FOYCftG2AtoTCYCMCSZ6XJgczA+fYv0UojUhXCSZg@mail.gmail.com"
type="cite">
<div dir="ltr">I have a source object that produces a polydata
object. Unfortunately the normals and scalars are unnamed. How
do I access these and name them in ParaView.
<div>I thought something like this may work in a Programmable
Filter:</div>
<div>
<pre class="" style="padding:0px;border:0px none white;color:rgb(0,0,0);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;vertical-align:top;background-image:none;background-repeat:initial"><p style="margin:0px">
pdi = self.GetPolyDataInput()</p>
<p style="margin:0px">pdo = self.GetPolyDataOutput()</p>
<p style="margin:0px">pdi.GetNormals().SetName('Normals')</p>
<p style="margin:0px">pdi.GetScalars().SetName('Scalars')</p>
<p style="margin:0px">pdo = pdi</p></pre>
<div><br>
</div>
<div>However, I can't see the array names.</div>
<div><br>
</div>
<div>This sort of thing works Ok in a Python Script:</div>
<div>
<div> # Name the arrays</div>
<div>
randomHillsSource.GetOutput().GetPointData().GetNormals().SetName('Normals')</div>
<div>
randomHillsSource.GetOutput().GetPointData().GetScalars().SetName('Scalars')</div>
<div># pd = randomHillsSource.GetOutput().GetPointData()</div>
<div># print pd</div>
</div>
<div><br>
</div>
<div>Is it possible to do this on ParaView?</div>
<div><br>
</div>
<div>Thanks in advance for any help.</div>
<div><br>
</div>
<div>Andrew</div>
<div><br>
</div>
-- <br>
___________________________________________<br>
Andrew J. P. Maclean<br>
<br>
___________________________________________
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the ParaView Wiki at: <a class="moz-txt-link-freetext" href="http://paraview.org/Wiki/ParaView">http://paraview.org/Wiki/ParaView</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.paraview.org/mailman/listinfo/paraview">http://www.paraview.org/mailman/listinfo/paraview</a>
</pre>
</blockquote>
<br>
</body>
</html>