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:
59
ParaView-5.0.1/VTK/Examples/VisualizationAlgorithms/Python/VisQuad.py
Executable file
59
ParaView-5.0.1/VTK/Examples/VisualizationAlgorithms/Python/VisQuad.py
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This example demonstrates the use of the contour filter, and the use of
|
||||
# the vtkSampleFunction to generate a volume of data samples from an
|
||||
# implicit function.
|
||||
|
||||
import vtk
|
||||
|
||||
# VTK supports implicit functions of the form f(x,y,z)=constant. These
|
||||
# functions can represent things spheres, cones, etc. Here we use a
|
||||
# general form for a quadric to create an elliptical data field.
|
||||
quadric = vtk.vtkQuadric()
|
||||
quadric.SetCoefficients(.5, 1, .2, 0, .1, 0, 0, .2, 0, 0)
|
||||
|
||||
# vtkSampleFunction samples an implicit function over the x-y-z range
|
||||
# specified (here it defaults to -1,1 in the x,y,z directions).
|
||||
sample = vtk.vtkSampleFunction()
|
||||
sample.SetSampleDimensions(30, 30, 30)
|
||||
sample.SetImplicitFunction(quadric)
|
||||
|
||||
# Create five surfaces F(x,y,z) = constant between range specified. The
|
||||
# GenerateValues() method creates n isocontour values between the range
|
||||
# specified.
|
||||
contours = vtk.vtkContourFilter()
|
||||
contours.SetInputConnection(sample.GetOutputPort())
|
||||
contours.GenerateValues(5, 0.0, 1.2)
|
||||
|
||||
contMapper = vtk.vtkPolyDataMapper()
|
||||
contMapper.SetInputConnection(contours.GetOutputPort())
|
||||
contMapper.SetScalarRange(0.0, 1.2)
|
||||
|
||||
contActor = vtk.vtkActor()
|
||||
contActor.SetMapper(contMapper)
|
||||
|
||||
# We'll put a simple outline around the data.
|
||||
outline = vtk.vtkOutlineFilter()
|
||||
outline.SetInputConnection(sample.GetOutputPort())
|
||||
|
||||
outlineMapper = vtk.vtkPolyDataMapper()
|
||||
outlineMapper.SetInputConnection(outline.GetOutputPort())
|
||||
|
||||
outlineActor = vtk.vtkActor()
|
||||
outlineActor.SetMapper(outlineMapper)
|
||||
outlineActor.GetProperty().SetColor(0,0,0)
|
||||
|
||||
# The usual rendering stuff.
|
||||
ren = vtk.vtkRenderer()
|
||||
renWin = vtk.vtkRenderWindow()
|
||||
renWin.AddRenderer(ren)
|
||||
iren = vtk.vtkRenderWindowInteractor()
|
||||
iren.SetRenderWindow(renWin)
|
||||
|
||||
ren.SetBackground(1, 1, 1)
|
||||
ren.AddActor(contActor)
|
||||
ren.AddActor(outlineActor)
|
||||
|
||||
iren.Initialize()
|
||||
renWin.Render()
|
||||
iren.Start()
|
||||
Reference in New Issue
Block a user