mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
from vtk import *
|
||||
|
||||
vertexDegree = vtkProgrammableFilter()
|
||||
|
||||
def computeVertexDegree():
|
||||
input = vertexDegree.GetInput()
|
||||
output = vertexDegree.GetOutput()
|
||||
|
||||
output.ShallowCopy(input)
|
||||
|
||||
# Create output array
|
||||
vertexArray = vtkIntArray()
|
||||
vertexArray.SetName("VertexDegree")
|
||||
vertexArray.SetNumberOfTuples(output.GetNumberOfVertices())
|
||||
|
||||
# Loop through all the vertices setting the degree for the new attribute array
|
||||
for i in range(output.GetNumberOfVertices()):
|
||||
vertexArray.SetValue(i, output.GetDegree(i))
|
||||
|
||||
# Add the new attribute array to the output graph
|
||||
output.GetVertexData().AddArray(vertexArray)
|
||||
|
||||
vertexDegree.SetExecuteMethod(computeVertexDegree)
|
||||
|
||||
|
||||
# VTK Pipeline
|
||||
randomGraph = vtkRandomGraphSource()
|
||||
randomGraph.SetNumberOfVertices(25)
|
||||
randomGraph.SetStartWithTree(True)
|
||||
vertexDegree.AddInputConnection(randomGraph.GetOutputPort())
|
||||
|
||||
view = vtkGraphLayoutView()
|
||||
view.AddRepresentationFromInputConnection(vertexDegree.GetOutputPort())
|
||||
view.SetVertexColorArrayName("VertexDegree")
|
||||
view.SetVertexLabelVisibility(True)
|
||||
view.SetVertexColorArrayName("VertexDegree")
|
||||
view.SetColorVertices(True)
|
||||
view.SetVertexLabelFontSize(20)
|
||||
|
||||
theme = vtkViewTheme.CreateMellowTheme()
|
||||
theme.SetLineWidth(3)
|
||||
theme.SetPointSize(10)
|
||||
view.ApplyViewTheme(theme)
|
||||
theme.FastDelete()
|
||||
view.ResetCamera()
|
||||
view.Render()
|
||||
view.GetInteractor().Start()
|
||||
|
||||
Reference in New Issue
Block a user