<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Great! I just experimented with your plugin, I have to say that's
pretty cool!<br>
<br>
<div class="moz-cite-prefix">On 05/31/2014 04:47 PM, Andrew Maclean
wrote:<br>
</div>
<blockquote
cite="mid:CAHDsG9NBjsfEXrwbyjVZrxxv2Z2N=hk=LdAhD6e7iKRc2meZBw@mail.gmail.com"
type="cite">
<div dir="ltr">Burlen,
<div> Thankyou so much for your quick response. The script
works fine. I am a bit of a ParaView novice when it comes to
scripting so thanks for the help!</div>
<div><br>
</div>
<div>This problem arose because I was looking at the VTK
Parametric Functions and wondering why they looked so terrible
in ParaView and yet there were no issues displaying them in
VTK. </div>
<div>So I wrote an XML plugin and discovered that I couldn't
access the scalars or normals. In the case of normals, for
non-orientable surfaces the normals become really important
and they are generated with the surface, so you need access
the data. Paraview can do this if it knows the name of the
dataset.</div>
<div><br>
</div>
<div>It turns out that when I wrote vtkParametricFunctionSource
(way back in 2003 I think!) I never named the normal or scalar
arrays. So I will fix this, modernise the code and update the
documentation in this coming week.</div>
<div><br>
</div>
<div>If you are interested, here is a first attempt at the xml
plugin. With your script we get some beautiful results in
Paraview. Of course I need to add in the parameters for all
the other surfaces. I have only done ParametricConicSpiral
and ParametricMobius.</div>
<div><br>
</div>
<div>First: Use Manage Plugins to import the xml script.</div>
<div>Then:</div>
<div>1) Find ParametricSource in Sources and select a function
e.g Mobius, (Minimum V = -0.2, Maximum V = 0.2) specify a
scalar mode and you will get a very ordinary mobius strip.</div>
<div>2) Apply your script as a programmable filter and select
the coloring to be scalars and you get a beautifully shaded
surface.</div>
<div>3) Then apply the Glyph filter using the Normals as vectors
and you get a nice display of the vectors on the surface. Use
a scale of (-1,-1,-1) if you want to invert the normals.</div>
<div><br>
</div>
<div>You get some beautiful images.</div>
<div><br>
</div>
<div>Regards</div>
<div> Andrew</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Sun, Jun 1, 2014 at 3:03 AM, Burlen
Loring <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:bloring@lbl.gov" target="_blank">bloring@lbl.gov</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div 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
<div class=""><br>
<br>
pdi = self.GetPolyDataInput()<br>
pdo = self.GetPolyDataOutput()<br>
</div>
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
<div>
<div class="h5"><br>
<br>
On 05/30/2014 07:29 PM, Andrew Maclean wrote:<br>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<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 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></fieldset>
<br>
</div>
</div>
<pre>_______________________________________________
Powered by <a moz-do-not-send="true" href="http://www.kitware.com" target="_blank">www.kitware.com</a>
Visit other Kitware open-source projects at <a moz-do-not-send="true" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the ParaView Wiki at: <a moz-do-not-send="true" href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a>
Follow this link to subscribe/unsubscribe:
<a moz-do-not-send="true" href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a>
</pre>
</blockquote>
<br>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
___________________________________________<br>
Andrew J. P. Maclean<br>
<br>
___________________________________________
</div>
</blockquote>
<br>
</body>
</html>