File: TestGetBounds2.py

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 205,984 kB
  • sloc: cpp: 2,336,570; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 181; javascript: 165; objc: 153; tcl: 59
file content (78 lines) | stat: -rwxr-xr-x 1,755 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from vtkmodules.vtkCommonCore import vtkPoints
from vtkmodules.vtkCommonDataModel import (
    vtkCellArray,
    vtkPolyData,
)
import sys

# Test bounds computation for mixed cells in polydata.
# Create some points that are unused by any cell as well.
polyData = vtkPolyData()
pts = vtkPoints()
verts = vtkCellArray()
lines = vtkCellArray()
polys = vtkCellArray()
strips = vtkCellArray()

pts.SetNumberOfPoints(13)
pts.SetPoint(0, 0,0,0)
pts.SetPoint(1, 1,0,0)
pts.SetPoint(2, 2,0,0)
pts.SetPoint(3, 3,0,0)
pts.SetPoint(4, 4,0,0)
pts.SetPoint(5, 3,1,0)
pts.SetPoint(6, 4,1,0)
pts.SetPoint(7, 5,0,0)
pts.SetPoint(8, 6,0,0)
pts.SetPoint(9, 5,1,0)
pts.SetPoint(10, 6,1,0)
pts.SetPoint(11, 7,0,0)
pts.SetPoint(12, 8,0,0)

verts.InsertNextCell(1)
verts.InsertCellPoint(0)

lines.InsertNextCell(2)
lines.InsertCellPoint(1)
lines.InsertCellPoint(2)

polys.InsertNextCell(4)
polys.InsertCellPoint(3)
polys.InsertCellPoint(4)
polys.InsertCellPoint(6)
polys.InsertCellPoint(5)

strips.InsertNextCell(4)
strips.InsertCellPoint(7)
strips.InsertCellPoint(8)
strips.InsertCellPoint(9)
strips.InsertCellPoint(10)

polyData.SetPoints(pts)
polyData.SetVerts(verts)
polyData.SetLines(lines)
polyData.SetPolys(polys)
polyData.SetStrips(strips)

box = [0.0,0.0,0.0,0.0,0.0,0.0]

print("Input data:")
print("\tNum Points: {0}".format(polyData.GetNumberOfPoints()))
print("\tNum Cells: {0}".format(polyData.GetNumberOfCells()))

# Compute bounds on polydata
polyData.GetBounds(box)

assert box[0] == 0.0
assert box[1] == 8.0
assert box[2] == 0.0
assert box[3] == 1.0
assert box[4] == 0.0
assert box[5] == 0.0

# CellsBounds consider only points that belong to at least one cell.
polyData.GetCellsBounds(box)
assert box[1] == 6.0