File: TestPointConnectivityFilter.py

package info (click to toggle)
vtk7 7.1.1%2Bdfsg2-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 127,396 kB
  • sloc: cpp: 1,539,584; ansic: 124,382; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 126; objc: 83
file content (67 lines) | stat: -rwxr-xr-x 1,579 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/env python
import math
import vtk
import vtk.test.Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

npts = 1000

# Create a pipeline with variable point connectivity
math = vtk.vtkMath()
points = vtk.vtkPoints()
i = 0
while i < npts:
    points.InsertPoint(i,math.Random(0,1),math.Random(0,1),0.0)
    i = i + 1

profile = vtk.vtkPolyData()
profile.SetPoints(points)
# triangulate them
#
del1 = vtk.vtkDelaunay2D()
del1.SetInputData(profile)
del1.BoundingTriangulationOff()
del1.SetTolerance(0.001)
del1.SetAlpha(0.0)

conn = vtk.vtkPointConnectivityFilter()
conn.SetInputConnection(del1.GetOutputPort())
conn.Update()

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(conn.GetOutputPort())
mapper.SetScalarModeToUsePointFieldData()
mapper.SelectColorArray("Point Connectivity Count")
mapper.SetScalarRange(conn.GetOutput().GetPointData().GetArray("Point Connectivity Count").GetRange())
print ("Point connectivity range: ", mapper.GetScalarRange())

actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(1,1,1)

# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)

ren1.AddActor(actor)
camera = vtk.vtkCamera()
camera.SetFocalPoint(0,0,0)
camera.SetPosition(0,0,1)
ren1.SetActiveCamera(camera)

ren1.SetBackground(0, 0, 0)

renWin.SetSize(250,250)

# render and interact with data

iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
ren1.ResetCamera()
renWin.Render()

iRen.Initialize()
#iRen.Start()