Great! I just experimented with your plugin, I have to say that's pretty cool!

On 05/31/2014 04:47 PM, Andrew Maclean wrote:
Burlen,
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!

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. 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.

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.

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.

First: Use Manage Plugins to import the xml script.
Then:
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. 2) Apply your script as a programmable filter and select the coloring to be scalars and you get a beautifully shaded surface. 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.

You get some beautiful images.

Regards
   Andrew



On Sun, Jun 1, 2014 at 3:03 AM, Burlen Loring <[email protected] <mailto:[email protected]>> wrote:

    Hi Andrew,

    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.

    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.

    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.

    Finally scalars and normals may not be present. I know you'd
    probably handle that in your final script, ;-)

    given all that, here's what I came up with:

        def copyAndNameArray(da, name):
          if da is not None:
            outda = da.NewInstance()
            outda.DeepCopy(da)
            outda.SetName(name)
            return outda
          else:
            return None


        pdi = self.GetPolyDataInput()
        pdo = self.GetPolyDataOutput()
        pdo.CopyStructure(pdi)

        pdo.GetPointData().SetNormals( \
          copyAndNameArray(pdi.GetPointData().GetNormals(), 'Normals'))

        pdo.GetPointData().SetScalars( \
          copyAndNameArray(pdi.GetPointData().GetScalars(), 'Scalars'))

        print 'Normals=%s'%(str(pdo.GetPointData().GetNormals()))
        print 'Scalars=%s'%(str(pdo.GetPointData().GetScalars()))

    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.

    Burlen


    On 05/30/2014 07:29 PM, Andrew Maclean wrote:
    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.
    I thought something like this may work in a Programmable Filter:

    pdi = self.GetPolyDataInput()


    pdo = self.GetPolyDataOutput()


    pdi.GetNormals().SetName('Normals')


    pdi.GetScalars().SetName('Scalars')


    pdo = pdi


    However, I can't see the array names.

    This sort of thing works Ok in a Python Script:
        # Name the arrays
    randomHillsSource.GetOutput().GetPointData().GetNormals().SetName('Normals')
    randomHillsSource.GetOutput().GetPointData().GetScalars().SetName('Scalars')
    #     pd = randomHillsSource.GetOutput().GetPointData()
    #     print pd

    Is it possible to do this on ParaView?

    Thanks in advance for any help.

    Andrew

-- ___________________________________________
    Andrew J. P. Maclean

    ___________________________________________


    _______________________________________________
    Powered bywww.kitware.com  <http://www.kitware.com>

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

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

    Follow this link to subscribe/unsubscribe:
    http://www.paraview.org/mailman/listinfo/paraview




--
___________________________________________
Andrew J. P. Maclean

___________________________________________

_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to