VTK for visualizing 3D Networks

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

VTK for visualizing 3D Networks

VTK - Users mailing list
Hi all!
I am relatively new to VTK but still surprised by the opportunities provided
by the visualization tool kit. For this reason, I am currently trying to
visualize a network using VTK. I saw some youtube videos concerning this
objective, but I was not able to achieve this objective and struggled hard
the last month..

What I did so far:
-I used networkx (python) to calculate the 3D positions of the node
-Python VTK to plot spheres which represent the nodes and tubes which
represent the edges.

What I am not able to do:
-I have information about the nodes which I would like to use to define the
importance (=size?) of the nodes. Furthermore, this information is used to
calculate the edge weigths.
-Regarding the edge weights, it would be great to use this information for
defining the tube color/diameter.

I already found some threads directing to the MutableUndirectedGraph class
for example. However, it seems to me that there is not clear way of doing it
in a 3D manner.

Maybe someone of you has some experience regarding this and could give me a
helping hand?
I would be really grateful!

Thanks and cheers
Benny




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VTK for visualizing 3D Networks

VTK - Users mailing list
Hi Benny,
It certainly shows that what you want is possible....
I'd also advise looking at more of the VTK examples - I think there's a Glyph Mapper which will change the size/color of the spheres based on a data value for you.
HTH,
Aron

On Sun, Mar 10, 2019 at 10:07 AM BennyS via vtkusers <[hidden email]> wrote:
Hi all!
I am relatively new to VTK but still surprised by the opportunities provided
by the visualization tool kit. For this reason, I am currently trying to
visualize a network using VTK. I saw some youtube videos concerning this
objective, but I was not able to achieve this objective and struggled hard
the last month..

What I did so far:
-I used networkx (python) to calculate the 3D positions of the node
-Python VTK to plot spheres which represent the nodes and tubes which
represent the edges.

What I am not able to do:
-I have information about the nodes which I would like to use to define the
importance (=size?) of the nodes. Furthermore, this information is used to
calculate the edge weigths.
-Regarding the edge weights, it would be great to use this information for
defining the tube color/diameter.

I already found some threads directing to the MutableUndirectedGraph class
for example. However, it seems to me that there is not clear way of doing it
in a 3D manner.

Maybe someone of you has some experience regarding this and could give me a
helping hand?
I would be really grateful!

Thanks and cheers
Benny




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers

_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VTK for visualizing 3D Networks

VTK - Users mailing list
VTK - Users mailing list wrote
> Hi Benny,
> Have you seen this?
> https://www.westgrid.ca/events/westgrid_online_workshop_3d_graphs_networkx_vtk_and_paraview
> It certainly shows that what you want is possible....
> I'd also advise looking at more of the VTK examples - I think there's a
> Glyph Mapper which will change the size/color of the spheres based on a
> data value for you.
> HTH,
> Aron

Hi Aron, thanks for your response!
Yes, I've already came across this youtube tutorial/Powerpoint slides.
Unfortunately, most of the magic is part of his "writeObjects" functions,
which he does not show neither in his slides nor in his video. Afterwards,
he using the data and working on it using paraview.
My approach was (or still is) to do all work required in Python (.py).





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VTK for visualizing 3D Networks

VTK - Users mailing list
I am not sure if I can edit my post here, so I am adding a second reply


I found a way to do it but I am struggling at converting scalar values to
RGB values for my tubes:
For the spheres I used

/
inputData = vtk.vtkPolyData()
inputData.SetPoints(nodePoints)
inputData.GetPointData().SetScalars(scalararray)
[...]
glyphPoints = vtk.vtkGlyph3D()
glyphPoints.SetInputData(inputData)
glyphPoints.SetSourceConnection(sphere.GetOutputPort())
glyphPoints.ClampingOff()
glyphPoints.SetColorModeToColorByScalar()
glyphPoints.SetScaleFactor(0.05)
/

and for the tubes I currently use:

/
edgeData.SetPoints(points)
edgeData.SetLines(lines)
edgeData.GetPointData().SetScalars(scalarvalues)
/

 

However, I am still struggling at converting my scalar tube values to an RGB
array which I can use for the mapper with the command
/
profileMapper.SetScalarModeToUsePointFieldData()
profileMapper.SelectColorArray("Colors")
/


I found the class vtkScalarsToColors which seems pretty useful in my case,
but I think I am too stupid to understand how it is working after crawling
through the class library and some posts/threads.

Can somebody support me at converting a scalar value to an RGB color for the
tubes?

Thanks!



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VTK for visualizing 3D Networks

mmusy
Hi
you can check out these two examples which make use of vtkplotter:
https://github.com/marcomusy/vtkplotter/blob/master/examples/basic/tube.py
(tubes of varying size and colors)
and
https://github.com/marcomusy/vtkplotter/blob/master/examples/basic/manyspheres.py
(large nr of spheres of varying size and colors)

you can convert easily scalrs to color arrays etc..
using vtkplotter methods will not prevent you from using any of the existing
vtk standard
features,
hope that helps




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers