WangWentao | 17 May 2013 18:09
Picon

Plugin for rendering vtkGraph in ParaView


Hi, all.

I hope to render vtkGraph in ParaView, which is available in VTK. The related classes are
vtkGraphLayoutView, vtkRenderedGraphRepresentation. There is also a source class: vtkRandomGraphSource.

My plan is to realize a customized view for vtkGraph. As an experiment, there are at least 3 things to to: 
1. a source for vtkGraph, which is the easiest part. Just load a xml file wrapping vtkRandomGraphSource.
2. a view. May be a subclass of vtkPVRenderView, with its RenderView replaced by vtkGraphLayoutView. I
have tried that, and the view shows in MainWindow, but I don't know if it really works.
3. a representation. vtkGraphLayoutView uses vtkRenderedGraphRepresentation by default. But I don't
know how to use this representation class in ParaView, only find that every representation class in 
Paraview is derived from vtkPVDataRepresentation.

I am trying to write a custumized grapg view according to my plan. Before everything is done, I have to figure
out how view and representaion work in Paraview. 

My questions are:
1. Does my plan works? Is there any aspect I have ignored? 
2. How to use a vtk representation class in Paraview?
3. What is the best way to visualize graph in Paraview?

Any advices will be appreciated!  
Guillaume Jacquenot | 17 May 2013 17:34
Picon

Help for DataObjectGenerator

Dear Paraview users,

I would like to create, from a script file, some data (lines) with python/vtk instructions and display the result for a Paraview client.

I know I can do it with Programmable Source.
The wiki page here gives some examples
http://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters

However, this presents several drawback for me.
- The code might be long, and is not easily maintenable as it is stored as a single string, when doing some batch operations
- I need to give some input arguments to this code
- I have some python functions

Therefore, I have tried to do it with DataObjectGenerator, but I can not use it properly.
I use the comand servermanager.Fetch to retrieve data, I manage to modify it.
Next step would be to ask Paraview to propagate modifications, and display the new data.
But I dont know how to do it.
Any advice?

I know some people had the same problem, but I can not figure out the solution
http://comments.gmane.org/gmane.comp.science.paraview.user/10879

Below is my Python code, that does not work: the final result is not displayed on screen.

try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()
from paraview import vtk

p= DataObjectGenerator(Program='PD1')
p.UpdatePipeline()
output = servermanager.Fetch(p)
output.Initialize()
newPts = vtk.vtkPoints()
numPts=5
newPts.InsertPoint(0, 0.0,0.0,0.0)
newPts.InsertPoint(1, 0.0,0.0,5.0)
newPts.InsertPoint(2, 5.0,0.0,5.0)
newPts.InsertPoint(3, 5.0,5.0,5.0)
newPts.InsertPoint(4, 5.0,9.0,7.0)
output.SetPoints(newPts)
aPolyLine = vtk.vtkPolyLine()
aPolyLine.GetPointIds().SetNumberOfIds(numPts)
[aPolyLine.GetPointIds().SetId(i, i) for i in range(0,numPts)]
output.Allocate(1, 1)
output.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())
print(output)
p.UpdatePipeline()
Render()
Show()
dp=GetDisplayProperties(p)
dp.DiffuseColor=[0.0,0.0,0.0]



Guillaume Jacquenot
<div><div dir="ltr">
<div>
<div>
<div>
<div>
<div>Dear Paraview users,<br><br>I would like to create, from a script file, some data (lines) with python/vtk instructions and display the result for a Paraview client.<br><br>
</div>I know I can do it with Programmable Source.<br>
The wiki page here gives some examples<br><a href="http://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters">http://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters</a><br><br>
</div>However, this presents several drawback for me.<br>
</div>- The code might be long, and is not easily maintenable as it is stored as a single string, when doing some batch operations<br>
</div>- I need to give some input arguments to this code<br>
</div>
<div>- I have some python functions<br><br>
</div>
<div>Therefore, I have tried to do it with DataObjectGenerator, but I can not use it properly.<br>
</div>
<div>I use the comand servermanager.Fetch to retrieve data, I manage to modify it.<br>
</div>
<div>Next step would be to ask Paraview to propagate modifications, and display the new data.<br>
</div>
<div>But I dont know how to do it.<br>
</div>
<div>Any advice?<br>
</div>
<div><br></div>
<div><div><div><div><div>
<div>I know some people had the same problem, but I can not figure out the solution<br><a href="http://comments.gmane.org/gmane.comp.science.paraview.user/10879">http://comments.gmane.org/gmane.comp.science.paraview.user/10879</a><br>
</div>
<div><br></div>
<div>Below is my Python code, that does not work: the final result is not displayed on screen.<br>
</div>
<div>
<br>try: paraview.simple<br>except: from paraview.simple import *<br>paraview.simple._DisableFirstRenderCameraReset()<br>
from paraview import vtk<br><br>p= DataObjectGenerator(Program='PD1')<br>p.UpdatePipeline()<br>output = servermanager.Fetch(p)<br>output.Initialize()<br>newPts = vtk.vtkPoints()<br>numPts=5<br>newPts.InsertPoint(0, 0.0,0.0,0.0)<br>
newPts.InsertPoint(1, 0.0,0.0,5.0)<br>newPts.InsertPoint(2, 5.0,0.0,5.0)<br>newPts.InsertPoint(3, 5.0,5.0,5.0)<br>newPts.InsertPoint(4, 5.0,9.0,7.0)<br>output.SetPoints(newPts)<br>aPolyLine = vtk.vtkPolyLine()<br>aPolyLine.GetPointIds().SetNumberOfIds(numPts)<br>
[aPolyLine.GetPointIds().SetId(i, i) for i in range(0,numPts)]<br>output.Allocate(1, 1)<br>output.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())<br>print(output)<br>p.UpdatePipeline()<br>Render()<br>Show()<br>
dp=GetDisplayProperties(p)<br>dp.DiffuseColor=[0.0,0.0,0.0]<br><br><br><br>
</div>
<div>Guillaume Jacquenot<br>
</div>
</div></div></div></div></div>
</div></div>
Raquel Alves | 17 May 2013 15:06
Picon

Viewing 2D glyphs

Hi.

I'm using Paraview 3.14, or even, 3.98 to visualize the deformation field and respective glyphs of an .vtk or .mha images. 
After open them, I 'Apply' to visualize the MetaImage, which has float as Data Type and [-21.5289, 21.3233], [-22.1109, 21.6821], [0, 0] as Data Ranges. Then, I use the Calculator with MetaImage_X*iHat+MetaImage_Y*jHat, resulting an image with double as data type and [-21.5289, 21.3233], [-22.1109, 21.6821], [0, 0] as data ranges. Finally, I apply the Glyph filter with the following properties:

Vectors = results
Glyph Type = 2D Glyph

     Glyph Type = Arrow

And the other properties used are the default ones.

As final result, I can see an image (attached in the email) with the glyphs approximatelly along the original X axis, but the Y axis was resized, and the glyphs shown are restricted, and not approximatelly along the original Y axis. Why is that occuring?

Thanks for your help!

Raquel Alves
<div><div dir="ltr">
<div>Hi.</div>
<div><br></div>
<div>I'm using Paraview 3.14, or even, 3.98 to visualize the deformation field and respective glyphs of an .vtk or .mha images.&nbsp;</div>
<div>After open them, I 'Apply' to visualize the MetaImage, which has float as Data Type and [-21.5289, 21.3233], [-22.1109, 21.6821], [0, 0] as Data Ranges. Then, I use the Calculator with&nbsp;MetaImage_X*iHat+MetaImage_Y*jHat, resulting an image with double as data type and&nbsp;[-21.5289, 21.3233], [-22.1109, 21.6821], [0, 0] as data ranges. Finally, I apply the Glyph filter with the following properties:</div>
<div><br></div>
<div>Vectors = results</div>
<div>Glyph Type = 2D Glyph</div>
<div><br></div>
<div>&nbsp; &nbsp; &nbsp;Glyph Type = Arrow</div>
<div><br></div>
<div>And the other properties used are the default ones.</div>
<div><br></div>
<div>
As final result, I can see an image (attached in the email) with the glyphs approximatelly along the original X axis, but the Y axis was resized, and the glyphs shown are restricted, and not approximatelly along the original Y axis. Why is that occuring?</div>
<div><br></div>
<div>Thanks for your help!</div>
<span class=""><div><br></div>
<div>Raquel Alves</div></span>
</div></div>
Colin McAuliffe | 17 May 2013 03:24
Favicon

Type error in programmable filter

Hello all,

I am writing a pvpython script which takes a pvd, applies an integrate  
variables filter, then uses a programmable filter to scale out the  
length, area, or volume (depending on whether the data is 1,2, or 3d)  
from each of the point data, then finally applies a plot selection  
over time filter to the result. It works fine most of the time, but  
occasionally the programmable filter gives the following error:

Traceback (most recent call last):
   File "<string>", line 26, in <module>
   File "<string>", line 23, in RequestData
   File  
"/Applications/ParaView.app/Contents/Python/paraview/vtk/dataset_adapter.py",  
line 196, in append
     arr = numpyTovtkDataArray(narray, name)
   File  
"/Applications/ParaView.app/Contents/Python/paraview/vtk/dataset_adapter.py",  
line 53, in numpyTovtkDataArray
     vtkarray = numpy_support.numpy_to_vtk(array)
   File  
"/Applications/ParaView.app/Contents/Python/paraview/numpy_support.py", line  
160, in numpy_to_vtk
     result_array.SetVoidArray(z_flat, len(z_flat), 1)
TypeError: argument 1: value is _c_A
W5 <at> k5?, required type is void_p

The error is occurring in the last line of the script which is below.  
I'm not sure where to start looking for problems since the data I am  
using seems fine. Any suggestions? Thanks!

All the best
Colin

         script = "inp = inputs[0]\n" + \
                  "#Determine length, area, or volume\n" + \
                  "lav = ['Length','Area','Volume']\n" + \
                  "if not inp.GetCellData() is None:\n" + \
                  "    if inp.GetCellData().GetNumberOfArrays() > 0:\n" + \
                  "        for CellArrayIdx in  
range(0,inp.GetCellData().GetNumberOfArrays()):\n" + \
                  "            data =  
inp.GetCellData().GetArray(CellArrayIdx)\n" + \
                  "            name =  
inp.GetCellData().GetArrayName(CellArrayIdx)\n" + \
                  "            if name in lav:\n" + \
                  "                LAV = data.GetTuple(0)[0]\n" + \
                  "#Scale point data by LAV\n" + \
                  "npa = inp.GetPointData().GetNumberOfArrays()\n" + \
                  "nams= [0]*npa\n" + \
                  "if not inp.GetPointData() is None:\n" + \
                  "    if inp.GetPointData().GetNumberOfArrays() > 0:\n" + \
                  "        for PointArrayIdx in  
range(0,inp.GetPointData().GetNumberOfArrays()):\n" + \
                  "            name =  
inp.GetPointData().GetArrayName(PointArrayIdx)\n" + \
                  "            nams[PointArrayIdx] = name\n" + \
                  "for n in nams:\n" + \
                  "    data = inp.PointData[n]\n" + \
                  "    print n,LAV,data\n" + \
                  "    output.PointData.append(data/LAV,n)"

--

-- 
Colin McAuliffe
PhD Candidate
Columbia University
Department of Civil Engineering and Engineering Mechanics
Ben Zhu | 17 May 2013 00:33
Picon

sub-domain visualization by ParaView

Hi everyone,

  I have a MPI programme that split the 3D space into blocks. Therefore, each block is output as a .vti file.
 I can visualize each block in Paraview, but cannot visualize them together.
I guess i need a .pvti file, but not sure how the file looks like. Anyone can send me a simple example showing how to visualize such a goup of files together?

Thank you.


Ben
<div><div dir="ltr">Hi everyone,<div><br></div>
<div>&nbsp; I have a MPI programme that split the 3D space into blocks. Therefore, each block is output as a .vti file.</div>
<div>&nbsp;I can visualize each block in Paraview, but cannot visualize them together.</div>
<div>I guess i need a .pvti file, but not sure how the file looks like. Anyone can send me a simple example showing how to visualize such a goup of files together?</div>
<div><br></div>
<div>Thank you.</div>
<div><br></div>
<div><br></div>
<div>Ben</div>
</div></div>
Scott, W Alan | 16 May 2013 18:08
Picon

Comparison of two datasets

I would like to view the difference between two results.  The results are on identical grids but produced in different manners.  Thanks for your help.
 
Thanks,
 
Alan
 
<div>
<span>
<div>I would like to view the difference between two results.&nbsp; The results are on identical grids but produced in different manners.&nbsp; Thanks for your help.</div>
<div>&nbsp;</div>
<div>Thanks,</div>
<div>&nbsp;</div>
<div>Alan</div>
<div>&nbsp;</div>
</span>
</div>
Michel Dupront | 16 May 2013 15:09
Picon
Favicon

axe with logarithmic scale

Hello,

From a 2D channel flow I draw a cross section of a variable u.
The curve is x ->u(x).

Now I would like to draw u using a logarithmic scale for the abscisse.

I tried to do things with "Filters / Calculator", "Filters / Python Calculator"
and "Sources / Axes" but nothing is working now.

How should I proceed ?

Thanks in advance!




<div><div dir="ltr">Hello, <br><br>From a 2D channel flow I draw a cross section of a variable u.<br>The curve is x -&gt;u(x).<br><br>Now I would like to draw u using a logarithmic scale for the abscisse. <br><br>I tried to do things with "Filters / Calculator", "Filters / Python Calculator"<br>and "Sources / Axes" but nothing is working now. <br><br>How should I proceed ?<br><br>Thanks in advance!<br><br><br><br><br>
</div></div>
Michel Dupront | 15 May 2013 22:22
Picon
Favicon

plotting over lines

Hello,
I am new to paraview.
I have a vtk file with the solution of a 2D flow in a channel.
I can plot a cross section of the velocity at a given position
in the streamflow direction using the filter "Plot Over Line".
I would like to have on the same graphic cross sections of
the velocity at different locations.
How can I do that ?
Thank in advance !



<div><div dir="ltr">Hello,<br>I am new to paraview. <br>I have a vtk file with the solution of a 2D flow in a channel. <br>I can plot a cross section of the velocity at a given position<br>in the streamflow direction using the filter "Plot Over Line".<br>I would like to have on the same graphic cross sections of <br>the velocity at different locations. <br>How can I do that ?<br>Thank in advance !<br><br><br><br>
</div></div>
Matthew Mosby | 15 May 2013 14:54
Picon
Favicon

Using VTK/Utilities/Verdict element metrics in ParaView

I would like to use the Verdict element metrics in ParaView, but I am not sure how to use them through the ParaView interface. Specifically, I want to compute the edge lengths if an unstructured grid. This seems to be possible using the verdict function 'V_edge_metric' which is in the VTK utilities library.

Any help, or pointers to the correct documentation would be greatly appreciated.

Thanks,
Matt Mosby
<div><div dir="ltr">I would like to use the Verdict element metrics in ParaView, but I am not sure how to use them through the ParaView interface. Specifically, I want to compute the edge lengths if an unstructured grid. This seems to be possible using the verdict function 'V_edge_metric' which is in the VTK utilities library.<div>
<br>
</div>
<div>Any help, or pointers to the correct documentation would be greatly appreciated.</div>
<div><br></div>
<div>Thanks,</div>
<div>Matt Mosby</div>
</div></div>
Stephan Rogge | 15 May 2013 08:22
Picon
Favicon

Re: vtkTable Visualization

Hi,

I decided to attach a pv state file to reproduce this issue. The left  
side visualizes the (multiblock) encapsulated vtkTable output of a  
ProgrammableSource with a SpreadSheet-, MatrixPlot- and  
ParallelCoordinatesView. The same view types were used for the direct  
vtkTable output of a ProgrammableSouce (right).

Steps to reproduce the problem with PV git master version:

1. Load attached State file

For the left views:
2. First select an item in the left active plot view (MatrixPlotView)  
with a right mouse click (no drag) => Should work 3. Select a line in  
the SpreadSheetView => Should work; the selection is propagated over  
all views (on the same side) 4. Now repeat step 2. => Message: "Uneven  
size of values." occurs and the selection is not being propagated to  
the other views 5. Select a range in the ParallelCoordinates View =>  
Same message as in step 4. is shown

For the right views:
2. First select an item in the right active plot view (MatrixPlotView)  
with a right mouse click (no drag) => Does not work; I have to click  
an drag 3. Select a line in the SpreadSheetView => Should work; the  
selection is propagated over all views (on the same side) 4. Now  
repeat step 2. => Should word 5. Select a range in the  
ParallelCoordinates View => Should work

Hope that someone could reproduce this.

Cheers,
Stephan

Zitat von Stephan Rogge <Stephan.Rogge <at> tu-cottbus.de>:

> Hello,
>
> I try to visualize a vtkTable with SpreadSheetView, Parallel
> CoordinatesView and PlotMatrixView and observe some strange behavior while
> making a selection of a certain row. To demonstrate the problem I've
> create to scenarios:
>
> ### Scenario 1 with a ProgrammableSource and a Muliblock(vtkTable) output:
>
> NumCols = 15
> NumRows = 100
> math = vtk.vtkMath()
> pdo = self.GetOutput()
> table = vtk.vtkTable()
> for di in range(0, NumCols):
>  d = vtk.vtkDoubleArray()
>  d.SetName("Data Column {0}".format(di))
>  d.SetNumberOfValues(NumRows)
>  for dv in range(0, NumRows):
>     d.SetValue(dv, math.Random() * NumRows)
>  table.AddColumn(d)
> pdo.SetBlock(0, table)
>
> #################################################
>
> ### Scenario 2 with a ProgrammableSource and a vtkTable output:
>
> NumCols = 15
> NumRows = 100
> math = vtk.vtkMath()
> pdo = self.GetTableOutput()
> for di in range(0, NumCols):
>  d = vtk.vtkDoubleArray()
>  d.SetName("Data Column {0}".format(di))
>  d.SetNumberOfValues(NumRows)
>  for dv in range(0, NumRows):
>     d.SetValue(dv, math.Random() * NumRows)
>  pdo.AddColumn(d)
>
> They both produce tables with same structure. The first Source encapsulate
> it within a multi block set. This is being visualized as shown on the
> screenshot (see attached).
>
> When I start to select a row the SpreaSheetView in both cases the PlotView
> and ParallelCoordinatesView highlights their corresponding data sets (as
> expected). But after clicking in the active plot view (in the multi block
> scenario 1) an Debug message occurs which says: "Uneven size for values."
> and the changed selection is not being propagated to the other views. This
> happens only in the Scenario 1 (multi block). In scenario 2 (direct
> vtkTable output) I still can select a point in the active plot view after
> selecting a row in the spread sheet.
>
> Another observation is, that the active plot view recognize a single item
> selection (single right-mouse-click) only in scenario 1 but not scenario
> 2. Here I have to draw small rectangle to select one data point.
>
> Can anyone reproduces this behavior?
>
>
> Best regards,
> Stephan

Attachment (ProgrammableSourceRandomPts.pvsm): application/octet-stream, 41 KiB
Hi,

I decided to attach a pv state file to reproduce this issue. The left  
side visualizes the (multiblock) encapsulated vtkTable output of a  
ProgrammableSource with a SpreadSheet-, MatrixPlot- and  
ParallelCoordinatesView. The same view types were used for the direct  
vtkTable output of a ProgrammableSouce (right).

Steps to reproduce the problem with PV git master version:

1. Load attached State file

For the left views:
2. First select an item in the left active plot view (MatrixPlotView)  
with a right mouse click (no drag) => Should work 3. Select a line in  
the SpreadSheetView => Should work; the selection is propagated over  
all views (on the same side) 4. Now repeat step 2. => Message: "Uneven  
size of values." occurs and the selection is not being propagated to  
the other views 5. Select a range in the ParallelCoordinates View =>  
Same message as in step 4. is shown

For the right views:
2. First select an item in the right active plot view (MatrixPlotView)  
with a right mouse click (no drag) => Does not work; I have to click  
an drag 3. Select a line in the SpreadSheetView => Should work; the  
selection is propagated over all views (on the same side) 4. Now  
repeat step 2. => Should word 5. Select a range in the  
ParallelCoordinates View => Should work

Hope that someone could reproduce this.

Cheers,
Stephan

Zitat von Stephan Rogge <Stephan.Rogge <at> tu-cottbus.de>:

> Hello,
>
> I try to visualize a vtkTable with SpreadSheetView, Parallel
> CoordinatesView and PlotMatrixView and observe some strange behavior while
> making a selection of a certain row. To demonstrate the problem I've
> create to scenarios:
>
> ### Scenario 1 with a ProgrammableSource and a Muliblock(vtkTable) output:
>
> NumCols = 15
> NumRows = 100
> math = vtk.vtkMath()
> pdo = self.GetOutput()
> table = vtk.vtkTable()
> for di in range(0, NumCols):
>  d = vtk.vtkDoubleArray()
>  d.SetName("Data Column {0}".format(di))
>  d.SetNumberOfValues(NumRows)
>  for dv in range(0, NumRows):
>     d.SetValue(dv, math.Random() * NumRows)
>  table.AddColumn(d)
> pdo.SetBlock(0, table)
>
> #################################################
>
> ### Scenario 2 with a ProgrammableSource and a vtkTable output:
>
> NumCols = 15
> NumRows = 100
> math = vtk.vtkMath()
> pdo = self.GetTableOutput()
> for di in range(0, NumCols):
>  d = vtk.vtkDoubleArray()
>  d.SetName("Data Column {0}".format(di))
>  d.SetNumberOfValues(NumRows)
>  for dv in range(0, NumRows):
>     d.SetValue(dv, math.Random() * NumRows)
>  pdo.AddColumn(d)
>
> They both produce tables with same structure. The first Source encapsulate
> it within a multi block set. This is being visualized as shown on the
> screenshot (see attached).
>
> When I start to select a row the SpreaSheetView in both cases the PlotView
> and ParallelCoordinatesView highlights their corresponding data sets (as
> expected). But after clicking in the active plot view (in the multi block
> scenario 1) an Debug message occurs which says: "Uneven size for values."
> and the changed selection is not being propagated to the other views. This
> happens only in the Scenario 1 (multi block). In scenario 2 (direct
> vtkTable output) I still can select a point in the active plot view after
> selecting a row in the spread sheet.
>
> Another observation is, that the active plot view recognize a single item
> selection (single right-mouse-click) only in scenario 1 but not scenario
> 2. Here I have to draw small rectangle to select one data point.
>
> Can anyone reproduces this behavior?
>
>
> Best regards,
> Stephan

sheshu t | 15 May 2013 02:22
Picon

Line Plot Data in Python Scripting

Hi,

I just started using Python scripting for paraview. I have a 3d plot from which I want to take a line plot and then compute the fourier transform of the data in the line plot.

1. What is the best way to get the coordinates and the values of the variable in the line plot.
2. Is it possible to do this completely with GUI(if yes, I can just trace the calls to get a python script from what I unnderstand so far)?
3. Is there a better/direct way to do the fourier transform along a line using vtk classes?

I hope the question is not too vague.

Thanks,
Sheshu
<div><div dir="ltr">
<div>
<div>
<div>Hi,<br><br>
</div>I just started using Python scripting for paraview. I have a 3d plot from which I want to take a line plot and then compute the fourier transform of the data in the line plot. <br><br>1. What is the best way to get the coordinates and the values of the variable in the line plot. <br>
</div>2. Is it possible to do this completely with GUI(if yes, I can just trace the calls to get a python script from what I unnderstand so far)?<br>
</div>
<div>3. Is there a better/direct way to do the fourier transform along a line using vtk classes?<br>
</div>
<br>I hope the question is not too vague. <br><br>Thanks,<br>Sheshu <br>
</div></div>

Gmane