File: CylinderAndPolarAxes.py

package info (click to toggle)
paraview 5.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 367,928 kB
  • sloc: cpp: 2,870,477; ansic: 1,329,317; python: 132,607; xml: 98,045; sh: 5,265; java: 4,541; yacc: 4,385; f90: 3,099; perl: 2,363; lex: 1,950; javascript: 1,574; objc: 143; makefile: 135; tcl: 59; pascal: 50; fortran: 27
file content (97 lines) | stat: -rw-r--r-- 2,933 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python
############################################################
from vtk import *
############################################################

# Create pole for camera aim and polar axes pole
pole = [1., 12., 3.]

# Create camera
camera = vtkCamera()
camera.SetClippingRange(1.0, 100.0)
camera.SetFocalPoint(pole)
camera.SetPosition(10., 10., 13.)

# Create cylinder
cylinder = vtkCylinderSource()
cylinder.SetRadius(6.)
cylinder.SetCenter(1., 2., 3.)
cylinder.SetHeight(15)
cylinder.SetResolution(32)
cylinder.Update()

# Create mappers for surface and wireframe representations
mapperS = vtkPolyDataMapper()
mapperS.SetInputConnection(cylinder.GetOutputPort())
mapperS.SetResolveCoincidentTopologyPolygonOffsetParameters(0, 1)
mapperS.SetResolveCoincidentTopologyToPolygonOffset()
mapperW = vtkPolyDataMapper()
mapperW.SetInputConnection(cylinder.GetOutputPort())
mapperW.SetResolveCoincidentTopologyPolygonOffsetParameters(1, 1)
mapperW.SetResolveCoincidentTopologyToPolygonOffset()

# Create actor for surface representation
surfactor = vtkActor()
surfactor.SetMapper(mapperS)
surfactor.GetProperty().SetColor(.89, .66, .41)
surfactor.SetOrigin(pole)
surfactor.RotateX(90.)

# Create actor for wireframe representation
wireactor = vtkActor()
wireactor.SetMapper(mapperW)
wireactor.GetProperty().SetColor(.1, .1, .1)
wireactor.GetProperty().SetRepresentationToWireframe()
wireactor.SetOrigin(pole)
wireactor.RotateX(90.)

# Create renderer
renderer = vtkRenderer()
renderer.SetActiveCamera(camera)
renderer.GradientBackgroundOn()
renderer.SetBackground(.2, .2, .2)
renderer.SetBackground2(.8, .8, .8)

# Create polar axes
polaxes = vtkPolarAxesActor()
polaxes.SetPole(pole)
polaxes.SetAutoScaleRadius(0)
polaxes.SetMaximumRadius(4.5)
polaxes.SetMinimumAngle(-60.)
polaxes.SetMaximumAngle(210.)
polaxes.SetNumberOfRadialAxes(10)
polaxes.AutoSubdividePolarAxisOff()
polaxes.SetNumberOfPolarAxisTicks(5)
polaxes.SetCamera(renderer.GetActiveCamera())
polaxes.SetPolarLabelFormat("%6.1f")
polaxes.GetRadialAxesProperty().SetColor(0., 0., 1.)
polaxes.GetPolarArcsProperty().SetColor(1., 0., 0.)
polaxes.GetPolarAxisProperty().SetColor(0., 0, 0.)
polaxes.GetPolarAxisTitleTextProperty().SetColor(0., 0., 0.)
polaxes.GetPolarAxisLabelTextProperty().SetColor(0., 0., 0.)
polaxes.SetEnableDistanceLOD(1)
polaxes.SetDistanceLODThreshold(.6)
polaxes.SetEnableViewAngleLOD(1)
polaxes.SetViewAngleLODThreshold(.4)
polaxes.SetScreenSize(8.)

# Create render window
window = vtkRenderWindow()
renderer.AddViewProp(surfactor)
renderer.AddViewProp(wireactor)
renderer.AddViewProp(polaxes)
window.AddRenderer(renderer)
window.SetSize(500, 500)

# Create interactor
interactor = vtkRenderWindowInteractor()
interactor.SetRenderWindow(window)

# Start interaction
window.Render()
polaxes.SetMinimumAngle(40.)
polaxes.SetMaximumAngle(220.)
polaxes.SetNumberOfRadialAxes(10)
polaxes.SetNumberOfPolarAxisTicks(10)

interactor.Start()